Skip to main content
15-Moonstone
February 21, 2022
Solved

Model metadata in 2D view

  • February 21, 2022
  • 1 reply
  • 2694 views

Hello, is it possible to use model metadata in a 2D view? I just need to display some information about the model in a separate 2D view of the experience and don't know how to access those data. how to do that?

many thanks

Best answer by SteveGhee

simple example attached.

i had forgotton to mention that you need to pull the metadata in first, which you do in the 3d view (i had something else doing that, forgot it was there. sorry about that)

 

so, in the 3d view, you'll see a simple 'loaded'()' function which pulls in the metadata by doing a dummy call to the API.  it doesnt actually need to do anything with the data, although you pbviously could use this in the 3d view if you needed to.

 

once in memory, you can switch to the "details" view, which you can then see is doing a specific query. The results are displayed in a label.

 

hope this example clears things up.

1 reply

21-Topaz I
February 21, 2022

Hi @GianVal , 

I think the meta data API as documented in the Help http://support.ptc.com/help/vuforia/studio/en/#page/Studio_Help_Center%2Fcad_metadata_api.html

could not be used in 2D view. But you can download the JSON file correspoinding to the PVZ to the Upload  project folder or to a string variable via TWX LoadJSON service . In this case you can  use some old techniques as described in first section  of the tech tip https://community.ptc.com/t5/Vuforia-Studio-and-Chalk-Tech/Incorporate-CAD-Metadata-Into-an-Experience-version-8-5-13-and/ta-p/693341

Further when I tes some code like this:

 

$rootScope.$on('modelLoaded', function() { 
 PTC.Metadata.fromId('model-1').then ((metadata) => { console.warn(metadata); console.log(JSON.stringify(metadata)) })
})

 

this will print in the console

2022-02-21_16-25-23.jpg

so seems that this object of the meta data with api methods is not so easy to be importetd as json to the project. (my opinon after first look) otherwise each javascript structure could be imported as text and then converted with eval function- when we know the exact code 😊

 

12-Amethyst
March 5, 2022

The metadata will persist across views, so if you load a model in a 3d view, keep a record of the element name (e.g. "model-1") and then you call the metadata API within another view e/g/ a 2D view, you can make all the metadata calls.  

12-Amethyst
March 5, 2022

let me know if you need an example.