[Closed] Maxscript: Merge/attach parents with children
Hey all.
Let’s say I have 100 objects in my scene, each with 100 other objects linked to it – 10100 objects total.
I want to merge all children with its parent, and end up with 100 objects.
I’ve found a script in this thread that almost does what I need, but not quite.
for i in selection do (
for g in i.children do (
i += g
)
)
For me, it has the following bugs:
[ul]
[li] Although I’d think “for i in selection” would run the script on any number of selected parents, it only works on one.[/li][li] The original children are still left as seperate objects. This is not a showstopper, but leaves some cleaning up to do.[/li][/ul]
Any help would be greatly appreciated!
Thanks,
- Jonas
(
max create mode
/**************************/
/***********************/
--let's create a little test setup
local nParents = 4;
local maxNchilds = 20;
convertToMesh (for i = 1 to nParents collect
(
local b = box pos:[random -2000 2000, random -2000 2000, random -2000 2000] wireColor:orange
local col = random black white
for o = 1 to random 1 maxNchilds do
(
sphere segments:8 smooth:false parent:b pos:[random -2000 2000, random -2000 2000, random -2000 2000] wireColor:col
)
b
))
/***********************/
/**************************/
--here comes the actual attaching
select for o in geometry where o.children.count > 0 collect
(
o.wireColor = o.children[1].wireColor --this is just for displaying purposes, delete or comment in production
for i = o.children.count to 1 by -1 do
(
attach o o.children[i]
)
o
)
)
of course this is just a quick example, maybe you wanna mix it with a cluster attach method
Hey, thanks a lot for the reply!
But I couldn’t really get it to work on my selection. Propably because you included a scene creation in the script. I tried to modify it, but I really really don’t know my Maxscript.
Anyways, I got a working solution in this (Danish) thread:
http://www.3dmaxer.dk/forum/topic.asp?TOPIC_ID=27607
Cheers!
- Jonas