ScriptSpot

Forum topic · General Scripting

Attaching same named objects

By Goonda · 2012-08-31

Description

How can I attach all the objects having same name in a scene??

Comments (4)

try this.objs = for i in

kimarotta · 2012-08-31

try this.


objs = for i in objects collect i

for z in objs do
(
	for o in objs where z != o do 
	(
		if z.name == o.name then
		(
			z.attach o z
			nProv = finditem objs o
			if nProv != 0 then deleteitem objs nProv
		)
	)
)

Goonda · 2012-09-03

Thanks Kimarotto....I checked the forum today...but before that I have written something like this...please check:

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
)

For Editable_Poly objects.

miauu · 2012-08-31

First select the object to hich will be attached other objects.


(
b = selection[1]
for o in geometry where (o != b and o.name == b.name) do b.attach o b
)

Goonda · 2012-08-31

Thanks miauu.....But for this to work I need to select a object manually....i need to do this for all the objects in the scene.....where I don't have to know which objects to select.