![]() |
|
name of object - Printable Version +- AB4D Forum (https://forum.ab4d.com) +-- Forum: Products Forums (https://forum.ab4d.com/forumdisplay.php?fid=4) +--- Forum: Viewer3ds and Ab3d.Reader3ds (https://forum.ab4d.com/forumdisplay.php?fid=5) +--- Thread: name of object (/showthread.php?tid=3922) |
name of object - fred_2420 - 11-07-2014 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 RE: name of object - abenedik - 11-19-2014 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]; RE: name of object - fred_2420 - 01-04-2015 Perfect that has saved me a load of time thanks. fred |