AB4D Forum
Hierarchy of NamedObjects - 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: Hierarchy of NamedObjects (/showthread.php?tid=3917)

Hierarchy of NamedObjects - fred_2420 - 07-19-2014


I have just purchased reader3ds and power tools, so far really impressed but I am a bit lost on how i get the named objects in a model.

This is the code i am using to load in the model (In vb)
Dim file As String = "some location"

Dim modelgroup As New Model3DGroup

Dim Ab4dReader As New Ab3d.Reader3ds
modelGroup = Ab4dReader.ReadFile(file)
Dim ModelVisual3d As New ModelVisual3D
ModelVisual3d.Content = modelGroup
Dim myreader3ds As New Ab3d.Reader3ds

How can i now see the Hierarchy as a set of strings or lists? Ive looked at the robot arm demo and that is what i am after but i am not quite getting it.

any help would be great



RE: Hierarchy of NamedObjects - abenedik - 07-20-2014

After reading the 3ds file with Reader3ds you can get the names of read objects from NamedObjects dictionary - it is a dictionary where key is the name of the object and value is the 3D object (Model3DGroup, GeometryModel3D, et.)

NamedObjects is very useful if you want to access the read objects by its name - for example:

((GeometryModel3D)myReader3ds.NamedObjects["headObject"]).Material = new DiffuseMaterial(Brushes.Red);

But if you want to iterate though read objects and get their names I would recommend you to convert the NamedObjects dictionary to ObjectNames dictionary - for example:

var namedObjects = myReader3ds.NamedObjects;
var objectNames = new Dictionary<object, string>();
foreach (KeyValuePair<string, object> namedObject in namedObjects)
if (namedObject.Value != null)
objectNames[namedObject.Value] = namedObject.Key;

RE: Hierarchy of NamedObjects - fred_2420 - 11-07-2014

Perfect that has solved it :) :)