[Closed] Combining all Objects that Share a Material?
Hi guys,
Is there a way to combine several objects in a scene that use the same Material ID? Are there any scripts that could do that or any guidance would be greatly appreciated!
Newton
Can you define what you mean by combine? Do you want them to be one object, grouped, booleaned etc.?
This was the first script I’ve ever made like 2 years ago. From what I understand you want to attach all the geom with the same material.
for i = 1 to sceneMaterials.count do
(
f = for g in geometry where ( g.material == sceneMaterials[i]) collect g
convertToPoly f[1]
gCount = f.count – 1
for j = 1 to gCount do
(
polyop.attach f[1] f[2]
)
)
I’d like them to be attached to each other and then become 1 object. MoreInfoPlz I ran your script, and it gave me an error…
– Runtime error: Attempt to access deleted scene object
Thank you though, I’ll play around with it and see what I can figure out
ah ok, so basically you just need to attach all the geometry in the scene.
geom = geometry as array
undefinedGeom = #()
convertToPoly geom[1]
for i = 2 to geom.count do
(
if(geom[i].material != undefined) then
(
polyop.attach geom[1] geom[i]
)
else
(
append undefinedGeom geom[i]
)
)
if undefinedGeom[1] != undefined then
(
convertToPoly undefinedGeom[1]
for i = 2 to undefinedGeom.count do
(
polyop.attach undefinedGeom[1] undefinedGeom[i]
)
)
This script combines all the objects and if there are undefined materials on the object it combines the undefined. Didn’t thoroughly test it so it will most likely have bugs.