Using Metadata
The Pixyz Plugin for Unity has the ability to import Metadata from CAD software, such as types, manufacturers, physical properties, ownership, ...
When a model is imported with the plugin with the Metadata option, nodes holding metadata information will be transposed in Unity with GameObjects with a Metadata MonoBehaviour component.
Get Metadata on an imported model
To get the Metadata block on a GameObject, use :
Metadata metadata = gameObject.GetComponent<Metadata>();
NOTE Not all GameObjects imported with Pixyz Plugin for Unity contains Metadata. Only nodes that have metadata in the original CAD file.
Check if a property exists
To check if a property exists or not based on its name, use :
bool hasWeight = metadata.containsProperty("Weight");
Get or a property value
To get a property value, use :
string value = metadata.getProperty("Weight");
This will throw an error if no property with the given name exists.
Add or a property
To add a property to the Metadata block, use :
metadata.addOrSetProperty("Weight", "756kg");
Set a property value
To set a property value, use the same method as above. If the property already exists, it will set the value with the new given value.
metadata.addOrSetProperty("Weight", "354kg");
Get properties as a dictionary
To get all properties in the shape of a dictionary (unique keys), use :
Dictionary<string, string> properties = metadata.getProperties();
Remove a property
To remove a property in a Metadata block, use :
metadata.removeProperty("Weight");
This will return true if a property was removed, and false if it failed (if no property with that name exists for example)
For more information, please check the API Documentation.