ScriptSpot is a diverse online community of artists and developers who come together to find and share scripts that empower their creativity with 3ds Max. Our users come from all parts of the world and work in everything from visual effects to gaming, architecture, students or hobbyists.
I have a scene with with 1,400 single objects each within it's own group. the objects are named object001. 002,003 etc etc, and the group has the name I want the object to be.
Is this possible via maxscript ?
Here is the solution.After you run this open Schematic View to see result
hendles = #()
groups = for g in objects where isGroupHead g collect g
fn isGroupHeadMember head node act:off =
(while isvalidnode node and isgroupmember node and not (act = (node.parent == head))do node = node.parent
act
)
fn getAllGroupMembers head = if isgrouphead head do(for node in (join #() head) where isGroupHeadMember head node collect node
)
fn renameGroupMembers groupNode &hendles sufix =
(if findItem hendles (hnd = (getHandleByAnim groupNode)) == 0 do(
name = groupNode.name
append hendles hnd
groupNode = getAllGroupMembers groupNode
groupNode = for o in groupNode collect
(if isgrouphead o then o else(
o.name = uniquename (name+sufix) ; dontcollect
))if groupNode.count > 0 dofor g in groupNode do renameGroupMembers g &hendles sufix
))for g in groups do(renameGroupMembers g &hendles "_Object")
free groups ; free handles
for g in objects where isGroupHead g do(
i = 1
for o in g where o != g do(
no = case of ((i <10):("00" + i as string)(i <100):("0" + i as string)
default:(i as string))
o.name = g.name + no
print o.name
i += 1))
The question is more complex if U need to consider group inside group.
Take look this thread where I and DenisT "wage a war" about groups. :) http://forums.cgsociety.org/showthread.php?f=98&t=1224794
Also to get "no" variable in your for loop try eazy way
Comments
Heroes are there
But you still can use "interactive renamer" from here in scriptspot.
works on the whole scene
happy that i tested on a test scene,
can we get one that works on the selected group only?
and without numbers?
...
Or if you not like random unique name numbering then use this fn
bga
`
ha ! Thank you :)
o_O
Now you see what I talking about :)
Group topics are interesting and mind blowing in the same time :)
bga
~
true true, thanks you for great examples to learn :)
...
Here is the solution.After you run this open Schematic View to see result
bga
`
This should make a job. Take a look.
Best,
Pixamoon
...
The question is more complex if U need to consider group inside group.
Take look this thread where I and DenisT "wage a war" about groups. :)
http://forums.cgsociety.org/showthread.php?f=98&t=1224794
Also to get "no" variable in your for loop try eazy way
bga
`
Thank you !
Still so much to learn :)
And yes, of course to groups inside groups... but it is just simple renaming tool base on group names
simplified code :