[Closed] Merge with children
Hi!
is there any method in maxscript too merge an object and automatically merge his children too?
not that i know of but you could try something like:
for i in selection do (
for g in i.children do (
i += g
)
)
thats the quick boolean way
you could also attach the meshes to the parents mesh if you want them to stay seperate subObjects
no, I mean when merging objects from a file, how can you know the relations between objects before merging them? I want to force to merge the children too when I merge an object
afaik cant directly
but you can save your currrent nodes into an array then check the scene after merging and exclude every one that was in the earlier array.
this way you build an array of the new nodes and can check them, delete everything that is .parent : false
but probably there is a 3line way to do this i simply dont know of so lets wait for some other replies
…or
you can intruduce special naming system for your assets.
like parent.name = box
child1.name = child01_box
child2.name = child02_box
then you get the node names from the file with getMAXFileObjectNames filter them out and if the names match after a lil stringplay you merge them too.
edit2 : of course then youd have to write a little tool for your artists that names the childNodes automatically
Or you can do something like this to merge specific objects:
clearlistener()
mObjs=#("Box03")
xMerge=#()
xrefs.deleteAllXRefs()
xrefs.addnewxreffile @"C: este_xref.max" #noLoad
aXRef=xRefs.getXRefFile 1
aXRef.hidden=true
updateXRef aXRef
for i in aXRef.tree.Children do
(
if i.children.count!=0 then
(
mBol=finditem mObjs i.name
if mBol!=0 then
(
append xMerge i.name
for j in i.children do append xMerge j.name
)
)
)
xrefs.deleteAllXRefs()
if xMerge.count!=0 then mergeMaxFile @"C: este_xref.max" xMerge else print "No matches found."
Or this to merge all objects that have childrens:
clearlistener()
xMerge=#()
xrefs.deleteAllXRefs()
xrefs.addnewxreffile @"C: este_xref.max" #noLoad
aXRef=xRefs.getXRefFile 1
aXRef.hidden=true
updateXRef aXRef
for i in aXRef.tree.Children do
(
if i.children.count!=0 then
(
append xMerge i.name
for j in i.children do append xMerge j.name
)
)
xrefs.deleteAllXRefs()
mergeMaxFile @"C: este_xref.max" xMerge
it works, Kameleon! Good trick! i never thought about using Xrefs to get what I think!
Thanks all for your answers!