Notifications
Clear all

[Closed] Rename all linked dummy/ object from last child name

I need a maxscript to rename all linked dummy’s name to the last child object name with additional sub and prefix text to that name.

Example –
dummy01 < dummy02 < dummy03 < model name ” Body ” [ Last child in the hierarchy ]

Result –
001-Body -Upper < 001-Body-Mid < 001-Body-Lower < Body

7 Replies

the ‘renaming’ task is simple…
the problem is to specify the task.

simple difference:
— i want to select a child and rename all its hierarchy UP using the ‘naming convention ->’
or
— i want to select a root and rename its hierarchy DOWN using the ‘name convention ->’

So make … (it calls) a ‘technical specification’ or a ‘statement of work’

that’s normally what ‘technical team’ works with.

try to ask your question again following this area’s standards.

Thanks for the reply densiT. Sorry, I dont know maxscript but trying to learn. So I not sure how I should re ask my question.

To help clarify. I want to select a child and rename all its hierarchy UP using the ‘naming convention

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

let me think

fn nameMeRight node base:"Body" id:1 = 
(
	local patterns = #("Lower", "Mid", "Upper")
	
	local k = 1
	while isvalidnode node and k <= patterns.count do
	(
		node.name = (formattedPrint (id as integer) format:"#03d") + "-" + base + "-" + patterns[k] 
		-- format "% % > %\n" node.parent k node.name
		node = node.parent
		k +=1 
	)
)

/**********************

delete objects

b0 = box pos:[0,0,0]
b1 = box pos:[40,0,0] parent:b0
b2 = box pos:[80,0,0] parent:b1

nameMeRight b2

print (for n in #(b0, b1, b2) collect n.name)

***********************/

use the function… you can use $ as argument for the function (which means a single selected node in our case)

you have options:
— specify a “base” name (in your case it’s “Body”)
— specify id (in your case it’s 1)

any questions are welcome

edited

the function should to be named “nameUsRight”

Here and in some other forums some people call me an evil troll … I’m not evil. The thing is that we are
here to share our knowledge and experience. And also we are trying to help those who is coming to the world of Max Script, or just need help for a moment. We spend our time on this, and we are not paid by Autodesk.
Just … ask a question the way so that we will answer you faster and more accurately.

Hi denisT, I don’t know if I’m doing it right, but it doesn’t work. it just return “nameMeRight()”

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

you have to select a child … and use:

--- $ means single selected node
nameMeRight $

if you have a child you need in a variable:

--- n = <your child node>
nameMeRight n