Notifications
Clear all

[Closed] creating pathNames with variables

Is it possible to make a pathName by combining variables together like the example below?

tempStr = “placeHolder” ;
joint = “spine1” ;

select ($tempStr +joint ) ;– this line won’t work

thanks!

5 Replies

oops… better shut my mouth on this forum for a couple of years…

Try to avoid execute() if at all possible.

The function you’re after is getNodeByName()

Yes but here is your problem


     tempStr = "placeHolder" ;
     joint = "spine1" ;
     
     select ($tempStr +joint  ) ;-- this line won't work
 

Firstly, you don’t need semi-colons after each line in maxscript.

You are assigning the string “placeHolder” to the variable tempStr, and “spline1” to the variable spline. Then when selecting you are adding a $ to the beginning of tempStr, but what you are actually doing is telling maxscript to find the node with the name “tempStr” like

select $Box01

What you need to do is use GetNodeByName to get the node, then you can select it however you want.


     tempStr = "placeHolder"  -- stores the varialbes tempStr, and joint
      joint = "spine1"
 
 theObj = getNodeByName (tempStr + joint)  -- uses GetNodeByName() to get the node with the name "placeHolderspine1", saves the node in variable "theObj"
 
 select theObj  -- selects the object
 
1 Reply
(@rustyknight)
Joined: 11 months ago

Posts: 0

You are right, you don’t NEED them, but they will not cause any problems in the code…just been nit-pickey

Bingo. Unnecessary/Undisturbing, but an extra keystroke

-Colin