I have a CADModel loaded in HOOPS, and I’m able to get the list of Metadata from the model. I’m trying to iterate over the list of Metadata objects to get the name and value of each metadata object.
I’m writing this in C#.
List<CADModel> cadModels = Factory.GetCADModels().ToList();
Console.WriteLine("Number of CAD Models: " + cadModels.Count);
CADModel cadModel = cadModels[0];
List<Metadata> metadatas = cadModel.GetAllMetadata().ToList();
foreach (Metadata metadata in metadatas)
{
string name = metadata.GetName();
// this line throws a System.InvalidCastException: "Unable to cast object type HPS.Metadata to type HPS.StringMetadata.
StringMetadata str = (StringMetadata)cadModel.GetMetadata(name);
Console.WriteLine(metadata.GetName() + str.GetValue());
}
I’m using the Hoops BIM Viewer Tutorial as an example. In the BIM viewer example, this line of code works fine.
Any advise would be greatly appreciated.