[MaxScript] Listing all Geometry and Helpers?

Started by
6 comments, last by WOsborn 13 years, 9 months ago
Hello all,
I'm attempting to write an exporter for a specific format by using the MaxScript interface.

I'm having trouble going through all the geometry and helpers currently in the scene. How should I design the For(...) loop to traverse through all the scene objects without having to select any of them?
What kind of colletion has both Geometry and Helpers?

I know it must be something in the lines of the "for obj in [something]" - but my mind can't get around that.

Thanks for the help.
Advertisement
try

for obj in rootScene.world.children do (-- stuff)
But this would cycle me through all the nodes in the scene, right?

Is there a way to filter the Geometries and Helpers (maybe with a Case...Of or something), just so I get these and not all the rest of node kinds when cycling through the Scene?

You could test for each type of object

for obj in rootScene.world.children do (  case superclassof obj of  (    GeometryClass: -- Do stuff with geometry    Helper: -- Do stuff with helpers  ))


Sounds slick. Thanks Ximmer.
MaxScript help for 'ObjectSet Values'


-- helpers in scene
for h in helpers do
(
print h
)

-- geometry in scene
for g in geometry do
(
print g
)
Is that so? I guess I'll have to use that when dealing with materials - although, I don't see a "material" ObjectSet value. How is it done?

About the geometry and helpers, the procedure should join the geometry and helpers (since both these kinds are game nodes) into the same array and loop through them:
for obj in rootScene.world.children do (  cl = superclassof obj  if (cl == GeometryClass) or (cl == Helper) then  (    append obj geometryAndHelper_Array   ))-- And then later on cycle through that:for i = 1 to geometryAndHelper_Array.count do(  geometryAndHelper_Array = -- blablabla)

Is this a good way to approach it?

-- Scene materials:

for s in scenematerials do
(
print s
)

-- Material Editor materials:
-- doesn't mean they are actually used in scene
-- array size I think is 24... number of material slots in material editor

for s in meditmaterials do
(
print s
)

In my opinion, don't worry about creating one big list.. process the two types of objects separately. If they are meant to be used together then go ahead and parent them as such and use the 'obj.parent' or 'obj.children' accessors.

This topic is closed to new replies.

Advertisement