PDA

View Full Version : how know if an object is a primitive ?


prettyPixel
02-24-2005, 11:18 AM
Somebody knows the way to know if an object is a primitive like a box, cylinder and not a light or a helper for example... in one test ?

I know this way
if classof obj == Box then ()
if classof obj == Cylinder then ()
if classof obj == Sphere then ()
...

I search the way to make only one test.

any help would be greatly appreciated...

galagast
02-24-2005, 11:32 AM
just bumped in to this function:

canconvertto $ nurbssurface

it says in the helpfile:
These functions work on those primitive geometry and shape classes that support conversion to NURBS (such as boxes, spheres, circles, lines, etc.). If an object does not support conversion, the function returns undefined.

it may work as a checker.

or maybe a u could use strings to check for the word "Editable_" in the baseobject...

well... just my two cents! hope this helps!

marktsang
02-24-2005, 11:56 AM
hi there,
i think this is what you are looking for

iskindof $ box

change box for other primitve names

mark

prettyPixel
02-24-2005, 12:07 PM
yessss this helps galagast :) Thanks a lot...

with this method and for any geometry:

for obj in selection where canConvertTo obj Editable_Poly do ()

thanks marktsang

Bobo
02-24-2005, 04:26 PM
Somebody knows the way to know if an object is a primitive like a box, cylinder and not a light or a helper for example... in one test ?

I know this way
if classof obj == Box then ()
if classof obj == Cylinder then ()
if classof obj == Sphere then ()
...

I search the way to make only one test.

any help would be greatly appreciated...

Technically, every GeometryClass object with the sorry exception of the TargetObject can be converted to a Mesh. It is not a test for being a primitive because this includes all EMesh, EPoly, NURBS, Patches, Primitives with modifiers which evaluate to PolyMesh or EMesh etc.

So most of the time you could also use

allGeometry = for o in geometry where classof o != TargetObject collect o

Of course, you could exclude all the Patch, NURBS, EPoly and EMesh objects if you want only the Primitives, Extended Primitives, Doors, Windows, Stairs etc. found in the Create > Geometry panel...

prettyPixel
02-24-2005, 06:50 PM
Technically, every GeometryClass object with the sorry exception of the TargetObject can be converted to a Mesh. It is not a test for being a primitive because this includes all EMesh, EPoly, NURBS, Patches, Primitives with modifiers which evaluate to PolyMesh or EMesh etc.

So most of the time you could also use

allGeometry = for o in geometry where classof o != TargetObject collect o

Of course, you could exclude all the Patch, NURBS, EPoly and EMesh objects if you want only the Primitives, Extended Primitives, Doors, Windows, Stairs etc. found in the Create > Geometry panel...

Thank you for this explanation very usefull, bobo

Really, there is no easy way in maxscript to find the class of several objects at the same time.
If anybodies interested by subject ( I presume Bobo already knows that isn't ;) )
I have just found this tips that return the class of the current selected object (in the listener)
classof $
--for example it return > PolyMeshObject
To know the upperclass, you can look in the doc or just type:
showclass "PolyMeshObject"
--for example it return > PolyMeshObject : GeometryClass {5d21369a,0}
In this case the superClass is GeometryClass.

It's interesting to note that
classof $==geometryClass -- return FALSE
but
isKindOf $ geometryClass -- return TRUE
I hope this will help some people...

CGTalk Moderation
02-24-2006, 07:00 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.