Community
3ds Max Programming
Welcome to Autodesk’s 3ds Max Forums. Share your knowledge, ask questions, and explore popular 3ds Max SDK, Maxscript and Python topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

what is the second line in this variable do

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
maxehrlich
570 Views, 6 Replies

what is the second line in this variable do

I am reverse engineering an existing script to learn.  Can anyone tell me what the second line below the variable in line one does?

 

1  RBmod = (MassFX_RBody ())
addmodifier $ RBmod

 

Thanks!

6 REPLIES 6
Message 2 of 7
Steve_Curley
in reply to: maxehrlich

Adds the modifier created in line 1 to the current selection. "$" is a shorthand for "selection" - a built-in collection of currently selected objects.

Max 2016 (SP1/EXT1)
Win7Pro x64 (SP1). i5-3570K @ 4.4GHz, 8Gb Ram, DX11.
nVidia GTX760 (2GB) (Driver 430.86).

Message 3 of 7
maxehrlich
in reply to: Steve_Curley

Thanks Steve.  That makes sense.  

Message 4 of 7
paulneale
in reply to: maxehrlich

Never use $ in a script. This is not a good solution. Always use selection instead. 

 

$ can return one of two things, either a node or an array of nodes. This can cause bugs in your code if you are testing with multiple objects selected you will have properties like .count for an array but when only one object is selected and it doesn't represent an array there is no .count property. 

 

Selection will always return an array and will keep your code clean. 

Paul Neale

http://paulneale.com


Paul Neale




EESignature

Message 5 of 7
maxehrlich
in reply to: paulneale

Paul,

Thanks for the advice.  Would this be the proper syntax?

 

RBmod = (MassFX_RBody ())
addmodifier selection RBmod

Message 6 of 7
paulneale
in reply to: maxehrlich

Yes, it is a mapped function to it will apply the modifier to all the objects selected. 

Paul Neale

http://paulneale.com


Paul Neale




EESignature

Message 7 of 7
blakestone
in reply to: maxehrlich

The script you have provided will add the "MassFX" modifier to all selected objects as an "Instance", meaning if you adjust the values of one of these modifiers it will adjust all Instances of this with the same values, something you may/may-not want?

Here is another example how this can be achieved without being Instanced.

 

 

-- Applies MassFX_RBody Modifier to ONLY Geometry Objects in selection AND only 
-- if they don't already have the MassFX_RBody Modifier already applied.
-- Script inside UNDO function so users may perform an UNDO if script has been run accidentally.

(
  with undo on
  (
    for o in selection where superClassOf o == GeometryClass and o.modifiers[#MassFX_RBody] == undefined do addModifier o (MassFX_RBody())
  )
)

 

--------------------------------------------------------------------------------------
Technical 3D Graphic Artist
Autodesk 3dsMax 2015 - Service Pack 4
--------------------------------------------------------------------------------------

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report