Notifications
Clear all

[Closed] Scripting for hidden modifier properties

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

13 Replies

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
		)
	)
	
)

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
 )
  

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
4 Replies
 eek
(@eek)
Joined: 11 months ago

Posts: 0

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)
Joined: 11 months ago

Posts: 0

Makes sense.
So does o actually stand for “object”, sort of like I refers to “iterations” in

for i=1 to 10
 eek
(@eek)
Joined: 11 months ago

Posts: 0

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)
Joined: 11 months ago

Posts: 0

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

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

1 Reply
 eek
(@eek)
Joined: 11 months ago

Posts: 0

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

for spoons in toast do…

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.

1 Reply
(@floopyb)
Joined: 11 months ago

Posts: 0

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

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.

Thanks SoLiTuDe
That getClassInstances will be helpfull in the future!