PDA

View Full Version : Scripting for hidden modifier properties


Karnageddon
06-26-2009, 10:44 PM
Hello all,

I am trying to figure out a small script that can either globally or manually* switch all flex modifiers in the scene between On and Off/Off In Viewport.
*by manually i mean having a controller for a specific group of wires belonging to a leg and turning them on and off rather than going into each wire and doing it manually.

Flex is being heavily used for accurate wire movement wobbles and affects viewport quality a lot.

The problem is: I don't know how to access any of the modifier options in the rightclick menu while scripting, so any helpful code hints are appreciated.
Thanks

Jsnyder
06-26-2009, 10:59 PM
I'm quite sure there is a better way to do this (someone will post i'm sure)

but this will just go through all geometry in the scene, if it has a flex modifier it will either turn it on or off depending on it's previous state


allobjects = geometry as array

for i = 1 to allobjects.count do
(
for r = 1 to allobjects[i].modifiers.count do
(
x = allobjects[i].modifiers[r]
if (x.name == "Flex") then
(
x.enabled = not x.enabled
)
)

)

SoLiTuDe
06-27-2009, 12:49 AM
a little bit cleaner, and not reliant on the name of the modifier.. also toggles (good idea!) all of them depending on state


themods = getclassinstances Flex
for o in themods do
(
o.enabled = not o.enabled
)

Karnageddon
06-27-2009, 02:34 AM
Thanks a lot guys, I turned it into a macroscript controlled by a check box, works perfectly and on the fly; exactly how i wanted it.

Solitude: I learned something from "getclassisntances" so thanks for that. One thing im unable to understand though is what o refers to in
for o in themods do

eek
06-27-2009, 04:24 AM
Thanks a lot guys, I turned it into a macroscript controlled by a check box, works perfectly and on the fly; exactly how i wanted it.

Solitude: I learned something from "getclassisntances" so thanks for that. One thing im unable to understand though is what o refers to in
for o in themods do

theMod is a reference to all the instanced modifiers in the scene, like 'for o in objects' means for every object in the scene.

So for o in theMods mean for every instanced of the flex modifier in the scene.

Karnageddon
06-27-2009, 04:42 AM
theMod is a reference to all the instanced modifiers in the scene, like 'for o in objects' means for every object in the scene.

So for o in theMods mean for every instanced of the flex modifier in the scene.

Makes sense.
So does o actually stand for "object", sort of like I refers to "iterations" in for i=1 to 10

eek
06-27-2009, 02:56 PM
Makes sense.
So does o actually stand for "object", sort of like I refers to "iterations" in for i=1 to 10

No no, the 'o' can be anything, its just the assigned variable:

for n in objects
for i in objects
for q in objects

Karnageddon
06-27-2009, 06:26 PM
No no, the 'o' can be anything, its just the assigned variable:

for n in objects
for i in objects
for q in objects

Ah, so the for statement is assigning the variable; ok now i get it.

Sorry for the questions, I have no time to left to learn programming so I'm picking it up as i go along.

JHN
06-28-2009, 01:20 PM
I think there are some conventions like the use of "i" in a itterating for loop.
I tend to use the letter of the type of object/variable as the itterator.

for o in objects
for n in nodes
for i in integerArray
for m in modifiers

It helps me identifying the variable. But you can ofcourse use whatever you want.

-Johan

eek
06-28-2009, 05:57 PM
I think there are some conventions like the use of "i" in a itterating for loop.
I tend to use the letter of the type of object/variable as the itterator.

for o in objects
for n in nodes
for i in integerArray
for m in modifiers

It helps me identifying the variable. But you can ofcourse use whatever you want.

-Johan

Yep same here, though once i start hitting 4-5 nested loops i have to start thinking imaginatively :)

for spoons in toast do...

floopyb
06-29-2009, 01:59 AM
One of my script was actually born through the want of being able to turn turbosmooths off / on in viewport:
http://www.scriptspot.com/3ds-max/modifier-modifier-zorb
Works for selection/all has hidden filter and an "exclude" filter for changing modifiers states, and more!

Karnageddon
06-29-2009, 02:16 AM
One of my script was actually born through the want of being able to turn turbosmooths off / on in viewport:
http://www.scriptspot.com/3ds-max/modifier-modifier-zorb
Works for selection/all has hidden filter and an "exclude" filter for changing modifiers states, and more!

I can understand why, it's so convenient having something for global control. I got fed up enabling-disabling modifiers constantly.

This was actually my first interfaced script (normally just expressions or controller scripting) because i was tired of turning on/off flex modifiers for dozens of objects at a time since the majority of the wires need to have independent modifiers. I am currently trying to figure out ways to create groups through a multi-list selection box and applying the changes to those specific groups, ie. enabling/disabling flex on a group of wires on left arm; rather than all the objects in the scene.
After its done it will be up for share on scriptspot.

floopyb
06-29-2009, 02:26 AM
I can understand why, it's so convenient having something for global control. I got fed up enabling-disabling modifiers constantly.

True that! I actually end up doing most of my work using my ModifierZorb script interface rather than max's!!


I am currently trying to figure out ways to create groups through a multi-list selection box and applying the changes to those specific groups, ie. enabling/disabling flex on a group of wires on left arm; rather than all the objects in the scene.

Sounds like you would almost want to embed a script in a custom attribute and add a button to execute it on part of the rig to do that so it is more of a rig control.

Jsnyder
06-29-2009, 06:03 PM
Thanks SoLiTuDe
That getClassInstances will be helpfull in the future!

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