You may have just saved a mans life with this script. The waiting was driving me mad. Thank you.
Wow, thanks guys for sharing this, I am really new to Maxscript and was looking for the code needed to attach poly objects. I find it difficult finding the exact thing I need within the help documentation.
If either of you could take 5 minutes to explain briefly what the symbols in your scripts mean it would help me a lot in furthering my understanding If not no worries.
Cheers, K
turns off the undo as attaching many objects could fill your memory with all the undo data causing max to crash.
undo off
starts and continues a loop if there are more than 1 object selected
while selection.count > 1 do
create a variable to hold the initial number of objects selected in this iteration of the while loop. I made this to use instead of using the selection count 'live' cause the selection count changes as objects are attached ot each other.
selcount = selection.count
makes a 'for' loop to iterate backwards thru the selected objects attaching every second object to every other second object.
so with 10 objects, 10 would be attached to 9, 8 to 7, 7 to 6 etc. I did it this way cause if you count up, when you attach 1 to 2, all objects shift down 1 spot and it gets a bit less neat and not quite as easy to manage.
for i = selcount to 2 by -2 do
This is the line that does the attaching. For example, when i is 10 it will attach object 10 to object i-1 (which is 9)
polyop.attach selection[i] selection[i-1]
and finally, a function to update the single object left over
update selection[1]
But if all you were looking for was the code to attach one object to another, this is it:
polyop.attach object1 object2
where object2 will be attached to object1 leaving you with just object1 with the geo of object2 included.
Hope some of this helps,
Cg.
Thank you very much for taking the time to explain, It is extremely useful. Sometimes the scripts can seem overwhelming but it helps when they are broken down
Cheers
I wonder if the array could be splitted and then threaded to two separate threads… hmmmm xD
Well, I was actually able to do it… kind of, the problem is something related to viewport updates, I’ve tried alot of different aproaches but none was flawless on a large number of objects, worked well in small numbers though.
There is really nothing special about it, I just ran the attach code in a different thread and then tried using disableRedraw enableRedraw and completeRedraw in different places but none worked 100%
Care to share any of your experiences in a way that might help people write multithreaded code?
Like maybe a code snippet? A function name? A place in the help to read?
I’ve searched the help file for this kind of thing and didn’t manage to find anything related.