Multithread in maxscript:
Also since we are in on the topic,
I did something different to attach massive scenes,
I exported as obj, then imported back in with the “import as single mesh” option set.
(through script).
Thanks for sharing that. The export to OBJ is a pretty cool way to “think outside the box” to get attaching done. Does OBJ export/import support more than one UVW channel? Also, material ID’s would probably be lost using that technique. But an option to definitely keep in mind.
stigale: That’s a great idea… never thought of that But time and memory wise is it worth it? Is it faster than doing a fast attach?
Dimentia: Sorry, I thought you knew the multithreaded dotnet code, there are lot of examples here on the forum and of course Lonerobot is the main reference for a snippet and detailed explanation.
Yeah, the export as OBJ is very interesting. Although, u’d have to apply your materials again after, and like someone else said, u might lose your smoothing groups, but I’m not sure on that one.
Also, is it alot faster than just waiting for the attach?
it’s much slower… also when we export as OBJ we convert all geometry to mesh format. Attaching of meshes is a lot faster than attaching of polys, but we are talking about polys.
Attaching of meshes is a lot faster than attaching of polys, but we are talking about polys.
Yeah, way faster. Example:
try(destroydialog teaRoll)catch()
rollout teaRoll "Roll"
(
spinner numPots "# Teapots: " type:#integer range:[1,500000,250]
button pressMe "Cluster Attach"
button pressMe2 "Linear Attach"
button pressMe3 "Mesh Attach"
progressbar prog1 "" value:0
function makeTeapots total=
(
teaArr = #()
posX = 0
posY = 0
for q in 1 to total do
(
posX += 10
if posX > 1000 then
(
posY += 50
posX = 0
)
teaArr[q] = teapot()
teaArr[q].pos.x = posX
teaArr[q].pos.y = posY
)
return teaArr
)
function clusterAttach objArr =
(
j = 1
count = objArr.count
undo off
(
while objArr.count > 1 do
(
if classof objArr[j] != Editable_Poly then converttopoly objArr[j]
polyop.attach objArr[j] objArr[j+1]
deleteItem objArr (j+1)
j += 1
if (j + 1) > objArr.count then j = 1
)
)
return objArr[1]
)
function linearAttach objArr =
(
converttopoly objArr[1]
undo off
(
for q in 2 to objArr.count do
(
prog1.value = (q/objArr.count as float)*100
polyop.attach objArr[1] objArr[q]
)
)
return objArr[1]
)
fn meshAttach objArr =
(
--local myMesh = editable_mesh()
--for h=1 to objArr.count do attach myMesh objArr[h]
j = 1
count = objArr.count
undo off
(
while objArr.count > 1 do
(
if classof objArr[j] != Editable_Mesh then converttomesh objArr[j]
attach objArr[j] objArr[j+1]
deleteItem objArr (j+1)
j += 1
if (j + 1) > objArr.count then j = 1
)
)
return objArr[1]
)
on pressMe pressed do
(
delete $*
teaArr = makeTeapots numPots.value
tStart = timestamp()
clusterAttach teaArr
prog1.value = 0
tEnd = timestamp ()
print ("Attach finished. Total time: " + ((tEnd-tStart)/1000.0) as string + "s")
)
on pressMe2 pressed do
(
delete $*
teaArr = makeTeapots numPots.value
tStart = timestamp()
linearAttach teaArr
prog1.value = 0
tEnd = timestamp ()
print ("Attach finished. Total time: " + ((tEnd-tStart)/1000.0) as string + "s")
)
on pressMe3 pressed do
(
delete $*
teaArr = makeTeapots numPots.value
tStart = timestamp()
meshAttach teaArr
prog1.value = 0
tEnd = timestamp ()
print ("Attach finished. Total time: " + ((tEnd-tStart)/1000.0) as string + "s")
)
)
createdialog teaRoll
Why can’t we just use mesh attach, and then convertToPoly the resulting mesh?
Is there a modifier in max that brings all selected meshes together quickly?
Maybe a modifier would be the fastest, since its using the base SDK, and not going through maxscript?
Edit: Blob Mesh Modifier is actually somewhat close. Or the principal at least.
no… this is not sdk or not sdk issue. max just algorithmically does do multiple attaching wrong.
read this thread. it explains the problem…
Or, if you apply an EditPoly Modifier to something like 150 objects, its almost instant, then you can access the Geometry. But I’m not sure if/how that would help any.
I understand that if you attach them in order, as the mesh grows, it gets exponentially slower when adding geometry to other geometry and rebuilding.
I’ve done tests of my own with attaching out of order, which helps, but still can be slow.
I’ve taken a look at the soulburn script that does this too.