The 3D Canvas model is a database. I consider it as a database of arrays in order to manipulate it. For example all the model objects are numbered and stored in an array. Remember all array indexing starts from 0, so if you n objects, they will be numbered from 0 to n-1.
This snippet shows how to get the names of each object in your model. I use this because I sometimes use materials from one object and paste them onto another. In a script you can access the objects by using their number in the objects array.
'get the scene Set Scene = CanvasApp.GetActiveScene 'get the active object count TotalObjects = Scene.GetObjectCount MsgBox("Total Objects "&TotalObjects) For Counter=0 to TotalObjects-1 Set CurrentObject=Scene.GetObject(Counter) ItsName = CurrentObject.GetName() Message="Object "&Counter&" is called "&ItsName MsgBox(Message) Next
Here is a truncated heirarchy of the model as it is used in scripting.
So lets assume you build a model with 3 objects in it - a car, a truck and an outside loo. This table shows how you can access them.
|Object Number||Object Name|
Now assume the car object contains 21 points and 12 faces. The faces are triangles so have 3 points each. These tables show how that data is stored. The important thing to remember is that faces and points are stored separately. So the object contains a list of points and a list of faces. This means points can be referred to by more than one number.
Look. Face number 3 of the Car object is a triangle. The points in that triangle, as far as the face is concerned, are numbered 0,1 and 2. But for the Car object as a whole, they might be points 12,0 and 7. In this way a point can be used in any number of faces.
|Point Number||X Coord||Y Coord||Z Coord||U Coord||V Coord|
|FaceNumber||Points in Face||Material Index|
I'm getting confused myself now, so let's move on. Here's a script to explore the UV coordinates of a face. To use it, select any face of any object, then run the script. It works by looping through the points in the face, finding the Object number of that point, then looking up the UV coordinates of that Object number.