name of object
#1
Hi,

I have been struggling with getting the name of a clicked object,

using the following code i can grasp the 3d model hit and change its color but i am struggling to get its name.

................
If rayMeshResult IsNot Nothing Then
Dim hitgeo As GeometryModel3D = TryCast(rayMeshResult.ModelHit, GeometryModel3D)

Dim mo As Model3D = (rayMeshResult.ModelHit)

end if

How can i now get the "GetNamedObjectsText"

any help much appreciated

fred
#2
If you have read the 3D models with Ab3d.Reader3ds, than Reader3ds fills NamedObjects dictionary (Dictionary<string, object>) that have names as keys and objects as values. This dictionary can be used to get the object from its name.

But if you need to get name from the object, I would recommend to convert the NamedObjects dictionary into objectNames dictionary where object is set as key and name as value.

The following code in csharp (sorry I am not very familiar with VB):

// create a new dictionary with objects as values
objectNames = new Dictionary<object, string>();
foreach (KeyValuePair<string, object> namedObject in namedObjects)
{
if (namedObject.Value != null)
objectNames[namedObject.Value] = namedObject.Key;
}

Than you can get the name of your object simply with:

string objectsName = objectNames[hitModel];
Andrej Benedik
#3
Perfect that has saved me a load of time thanks.

fred
  


Forum Jump:


Users browsing this thread:
1 Guest(s)