attach multiple objects script?

attach multiple objects script?

avolution
Advocate Advocate
11,765 Views
8 Replies
Message 1 of 9

attach multiple objects script?

avolution
Advocate
Advocate
i have 5004 boxes
Box01....Box 5004


I always have to attach Box02....Box5004
to Box01 in small batch of 500, press hold
add another 500 or so, press hold etc, etc




Is there a script that will allow me to attach
all the boxes together in one step, else if i try via edit mesh
/attach multple, my max will run out of memory!




thanks
0 Likes
11,766 Views
8 Replies
Replies (8)
Message 2 of 9

miauuuu
Collaborator
Collaborator
Check this thread.
https://miauu-maxscript.com/
0 Likes
Message 3 of 9

avolution
Advocate
Advocate
Using this script



undo off
(
while selection.count > 1 do
(
selcount = selection.count
for i = selcount to 2 by -2 do
(
polyop.attach selection selection
)
)
update selection
)



and the supplied scene

i get this error...

-- Error occurred in i loop
-- Frame:
-- i: 2910
-- Error occurred during fileIn in <File:C:\3DSMAX6\scripts\attachfast2.ms>
>> MAXScript FileIn Exception: -- Unknown system exception <<


this script


---pass an array of geometry nodes to this function and it will return the combined result

function clusterAttach objArr =
(

j = 1
count = objArr.count

undo off
(
while objArr.count > 1 do
(
if classof objArr != Editable_Poly then converttopoly objArr

polyop.attach objArr objArr
deleteItem objArr (j+1)

j += 1

if (j + 1) > objArr.count then j = 1

)
)
return objArr
)



will not work on scene at all

Check this thread.

3000_attach_fails.zip

0 Likes
Message 4 of 9

miauuuu
Collaborator
Collaborator
This:

function linearAttach objArr =
(
converttopoly objArr
undo off
(
for q in 2 to objArr.count do
(
polyop.attach objArr objArr
)
)
return objArr
)
linearAttach (selection as array)


And this:

function clusterAttach objArr =
(

j = 1
count = objArr.count

undo off
(
while objArr.count > 1 do
(
if classof objArr != Editable_Poly then converttopoly objArr

polyop.attach objArr objArr
deleteItem objArr (j+1)

j += 1

if (j + 1) > objArr.count then j = 1

)
)
return objArr
)
clusterAttach (selection as array)


Works fine in max9, 2009, 2012, 2013.
Did you use max6? Try with 10 objects in the scene and if the two functions works, then, propably, the problem is not in the finctions. The first error message means that the error in the code occurs when the 2910 object is processed.
https://miauu-maxscript.com/
0 Likes
Message 5 of 9

barigazy
Enthusiast
Enthusiast
Or you can use this tool. I implement fast attach and detach with some option.
0 Likes
Message 6 of 9

avolution
Advocate
Advocate
Using this script



undo off
(
while selection.count > 1 do
(
selcount = selection.count
for i = selcount to 2 by -2 do
(
polyop.attach selection selection
)
)
update selection
)


If I reset the XFORM on all 3000 objects, reconvert to poly, then this script works!
Any idea why the XFORM reset is needed?
0 Likes
Message 7 of 9

miauuuu
Collaborator
Collaborator
No. But why you want to use this code and not the codes proposed by me and barigazy? If this code is faster than the others, but you have to reset XFOrm, then the code will become too slow, copmared to others.

I added your scene with 300 objects in max9 and executed the code from your last post and it works fine. Which version of 3ds max did you use?
https://miauu-maxscript.com/
0 Likes
Message 8 of 9

Anonymous
Not applicable
Or you can use this tool. I implement fast attach and detach with some option.

it's fast but not the fastest way of attach... we've discussed it on the cgtalk forum.
0 Likes
Message 9 of 9

barigazy
Enthusiast
Enthusiast
Or you can use this tool. I implement fast attach and detach with some option.

it's fast but not the fastest way of attach... we've discussed it on the cgtalk forum.

I realized that :). Detach is OK but Attach... 😞
I tried to speed up the process but without success.
0 Likes