|
|
|
Tell us what you think of the site.
|
Autodesk Media & Entertainment User Community
|
Autodesk® 3ds Max®
|
|
Autodesk® Maya®
|
|
Autodesk® Softimage®
|
|
Autodesk® MotionBuilder®
|
|
Autodesk® Mudbox™
|
|
Autodesk® ImageModeler™
|
|
Autodesk® Sketchbook® Pro
|
|
Autodesk® Smoke on Mac®
|
|
hi,
i got 21000 objects in my scene and there are 1500 scenematerials.
i want to attach all objects with the same material applied.
in the end there should be 1500 objects.
i think it is not possible to do it manually for this quantity of objects (pick material - select objects by material - attach ...)
i think there should be a better maxscript solution ... i am really new to maxscript, so any help would be appreciated.
one way could be. replace objectname with materialname (they are unique) >> check if objectname is assigned multiple times >> if so >> select objects by this name >> attach >> if not it is already processed ... end of loop
thank you
regards sebastian
|
|
|
|
Things to note…
If you managed to get 2 or more materials with the same name, this will fail. It assumes that the materials are Instanced to the objects.
Attaching that many objects is slow and fills up the Undo stack rapidly, which uses a lot of memory. The code attempt to mitigate those problems, but it means there is no going back once you have run the script. You MUST ensure your scene is saved before running it.
( suspendEditing() disableSceneRedraw() with undo off
(
for m in sceneMaterials do
(
newObj = Editable_Mesh()
convertTo newObj Editable_Poly
newObj.name = "Object_" + m.name
for o in geometry where (o.material == m) do
polyOp.attach newObj o
centerPivot newObj
)
) enableSceneRedraw() resumeEditing()
)
Max 4.2 through 2013.
XP-64 (SP2)
NVidia 9800GTX-512 (Driver 266.58).
Core 2 Quad Q6600 2.4GHz, 8Gb Ram, DX9.0c.
|
|
|
|
hi,
wow thank you for your fast response.
i think in principle this exactly what i need.
i run this on a simple test scene and getting an unknown system exception here.
polyOp.attach newObj o
any idea?
using max 2010
my test scene consits of 5 primitives and 2 scenematerials applied to those
so in the end there should be to editable polys
thank you!
|
|
|
|
I can only assume that you somehow have a scene material which is not actually applied to any geometric objects.
You should end up with an Editable Poly object for each material in the scene. It should attach objects which are not already Editable Polys because the Attach method is supposed to automatically convert the object to a Polymesh, so a Box primitive or even an Editable Mesh object should attach just fine. The code does work here, so if the modified version below doesn’t, then it will be difficult to work out what is wrong without having the actual scene to look at.
( suspendEditing() disableSceneRedraw() with undo off
(
for m in sceneMaterials do
(
newObj = Editable_Mesh()
convertTo newObj Editable_Poly
newObj.name = "Object_" + m.name
objs = for o in geometry where (o.material == m) collect o
if objs.count > 0 then
(
for o in objs do
(
polyOp.attach newObj o
centerPivot newObj
)
)
)
) enableSceneRedraw() resumeEditing()
)
Max 4.2 through 2013.
XP-64 (SP2)
NVidia 9800GTX-512 (Driver 266.58).
Core 2 Quad Q6600 2.4GHz, 8Gb Ram, DX9.0c.
|
|
|
|
thank you very very very much!!!
you saved my day :) it is working ...
regards sebastian
|
|
|
|
Cool - glad it helped. :)
Max 4.2 through 2013.
XP-64 (SP2)
NVidia 9800GTX-512 (Driver 266.58).
Core 2 Quad Q6600 2.4GHz, 8Gb Ram, DX9.0c.
|
|
|
|
|
|