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.
fn attachSameNameObj convertObjToPoly:off =
(--filter function for geometry objects
fn filterGeo obj = (isKindOf obj GeometryClass and classof obj != TargetObject)--collections of geo-objects
objArr = for obj in geometry where filterGeo obj collect obj
if objArr.count == 0 then (messagebox "No geometry objects on the scene!" title:"Warning" beep:false)else(while objArr.count > 1 do(
local lastNode = objArr[objArr.count]--last node in arrayfor i = objArr.count-1 to 1 by -1 where lastNode.name == objArr[i].name do(-- check if base object is editable mesh (this is recomanded for attach operations)if not isKindOf lastNode.baseobject Editable_mesh do(converttomesh lastNode)
attach lastNode objArr[i]--attach objects with same name
deleteItem objArr i -- remove attached item from objArr)-- place pivot at center
lastNode.pivot = lastNode.center
-- if convertObjToPoly is set to 'on' then convert attached object to poly or use default meshif convertObjToPoly do(convertToPoly lastNode)-- remove last item from objArr
objArr.count = objArr.count-1)))
Thanks Barigazy.....I have written something like this:
for o in geometry do
(
if classof o == editable_poly do
(
append newworking o
)
)
i = 1
while i <= newworking.count do
(
b = newworking[i]
j = i + 1
while j<= newworking.count do
(
if (newworking[j].name == b.name) then
(
b.attach (newworking[j]) b
deleteItem newworking j
select b
weldverts b
)
else
(
j = j +1
)
)
newworking = for o in geometry where isKindOf o editable_poly collect o
i = 1
while i <= newworking.count do(
b = newworking[i]
j = i + 1
while j <= newworking.count do(if(newworking[j].name != b.name) then j += 1 else(
b.attach (newworking[j]) b
deleteItem newworking j
select b
weldverts b
))
i+=1)
But your version is working only with epoly object.
My code works with any type of geometry except splines.
Comments
Try this code
bga
Thanks
Thanks Barigazy.....I have written something like this:
for o in geometry do
(
if classof o == editable_poly do
(
append newworking o
)
)
i = 1
while i <= newworking.count do
(
b = newworking[i]
j = i + 1
while j<= newworking.count do
(
if (newworking[j].name == b.name) then
(
b.attach (newworking[j]) b
deleteItem newworking j
select b
weldverts b
)
else
(
j = j +1
)
)
i = i + 1
)
Edit
This is corrected code
But your version is working only with epoly object.
My code works with any type of geometry except splines.
bga
attach by name
I have several meshes with similar names:
1_01
1_02
1_03
2_01
2_03
3_01
3_04
3_05
It's posible attach the meshes by initial names?
I get
1
2
3
thanks in advance