PDA

View Full Version : getModifier ?


cridalab
09-18-2009, 03:17 AM
hello,

I have been using addModifier o mod too add modifiers to an object. Is it possible to get the modifiers on an object?

My use case is I have a template object and I want to copy its modifiers to all other objects in the scene. But the API seems to only support clearing and adding modifiers.

thanks,
Richard

Bobo
09-18-2009, 04:19 AM
hello,

I have been using addModifier o mod too add modifiers to an object. Is it possible to get the modifiers on an object?

My use case is I have a template object and I want to copy its modifiers to all other objects in the scene. But the API seems to only support clearing and adding modifiers.

thanks,
Richard


Every scene node has a .modifiers property which gives you access to an array of the modifiers. You can access them by name or by index, from top to bottom.

For example,

s= Sphere()
addModifier s (Bend())
s.modifiers[1] --> gives you access to the new modifier

cridalab
09-18-2009, 05:08 AM
thanks Bobo - just what I needed.
With Python (in Maya) I can use dir(object) to find all the available methods and properties of an object. Is there an equivalent in maxscript?

Bobo
09-18-2009, 05:27 AM
thanks Bobo - just what I needed.
With Python (in Maya) I can use dir(object) to find all the available methods and properties of an object. Is there an equivalent in maxscript?

This is a tricky question, since "objects" are a complex system of various things including Base Object, Modifiers, Transforms with their Controllers, Space Warps / World Space Modifiers, Material etc. You can call show() or showProperties() on an object to see its properties. But this won't show you for example the Object Properties (Node Common Properties) like .isHidden, .renderable etc. because they are derived from the Node class, every node has them and if they would show up in a show() call, you could not distinguish what comes from where (look at the "Node Common Properties, Operators and Methods" topic in the MXS Help and you will see how many there are).

When it comes to Methods, only methods exposed by Function Publishing Interfaces will be listed (along with properties) if you call showInterfaces() on an object that exposes some.

Since MAXScript is a wrapper around the SDK and not a native part of the system (there was no MAXScript in version 1.0), most objects have no knowledge of all methods MAXScript might provide to operate on them, unless the method is exposed by the object itself. You might want to take a look at the "Class and Object Inspector Functions" topic for some possibilities.

Consulting the Help is how we work. I consult the Help every day. I advise you to RTFineM when you want to know something. I am the first to admit it is not always perfectly structured, but it contains tons of info. (except where it doesn't, for which I apologize in advance ;) )

PEN
09-18-2009, 12:18 PM
Indeed a Fine manual Bobo. You have no reason to apologize as since you took it over it has only become better. I have it open all day long every day.

cridalab
09-22-2009, 09:05 AM
RTFineM
hahaha


I found that texture maps need to be flattened when copying a modifier and after some testing I have this partially working solution:


select $my_object
addModifier $ $other_object.modifiers[1]

max modify mode
subobjectLevel = 3
$.modifiers[#Unwrap_UVW].flattenMap 45 #([1,0,0], [-1,0,0], [0,1,0], [0,-1,0], [0,0,1], [0,0,-1]) 0.02 true 0 true true


However the textures are not being positioned or scaled correctly. Can you see what I am missing?

Richard

cridalab
09-29-2009, 03:09 AM
I think the problem is related to using $.modifiers[#Unwrap_UVW] instead of the modifier directly. But when I try applying flatten to the modifier directly the texture is not visible at all.

Any ideas what I am missing?

CGTalk Moderation
09-29-2009, 03:09 AM
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.