Give a material to clusters with same name?
Give a material to clusters with same name?
I have a bunch of objects that were imported and these all have clusters with same naming system. What is the easiest way to give a material to all this clusters in different objects?
- Hirazi Blue
- Administrator
- Posts: 5107
- Joined: 04 Jun 2009, 12:15
Re: Give a material to clusters with same name?
It could well be, that I misunderstand the problem, but couldn't this be relatively easily done with some clever use of wildcards (such as "*") in the so-called "Object Selection and Sub-object Selection text boxes"? To find a more practical answer (it probably is scriptable as well) you might want to post a little more about the naming that's in place.
Stay safe, sane & healthy!
Re: Give a material to clusters with same name?
Thanks. I wan't able to get via Sub-object Selection text boxes, it just returns to the number of objects selected.
The naming is just Glass_2 these are a bunch of windows.
The naming is just Glass_2 these are a bunch of windows.
Re: Give a material to clusters with same name?
The easiest way I could think of, without scripting, would be wildcards like Hirazi Blue said but in your Script Editor.
If I understood you, you want to asign a material "X" to all your objects clusters named "Glass_2"
You could use
To select the all the polymeshes clusters called "Glass_2" in your scene, and then use Assign Material.
note: Using wildcards in SelectObj could be a little slow, but you can also use wildcards in your cluster name.
Or you could script something like this:
This will assign the material called "Glass_Material" from the Material Library called "DefaultLib" to all the Polygon Meshes Clusters called "Glass_2"
If I understood you, you want to asign a material "X" to all your objects clusters named "Glass_2"
You could use
Code: Select all
#Python
Application.SelectObj("*.*.polymsh.cls.Glass_2")
note: Using wildcards in SelectObj could be a little slow, but you can also use wildcards in your cluster name.
Or you could script something like this:
Code: Select all
#Python
# Name your cluster
sCluster = "Glass_2"
# Name your Material and Material Library
sMat = "Glass_Material"
sMatLib = "DefaultLib"
#--------------------------------
si = Application
oPolys = si.ActiveSceneRoot.FindChildren("","polymsh")
oMat = si.ActiveProject.ActiveScene.MaterialLibraries(sMatLib).items(sMat)
for oPoly in oPolys:
cl = oPoly.activeprimitive.geometry.clusters(sCluster)
if (cl): si.CopyPaste ( oMat, "", cl )
M.Yara
Character Modeler | Softimage Generalist (sort of)
Character Modeler | Softimage Generalist (sort of)
Re: Give a material to clusters with same name?
Weird, i tried what Hirazi Blue and you said today and it worked, just selecting in the sub component. Don't know what mistake i have made the other day. Many thanks Myara.
Who is online
Users browsing this forum: No registered users and 53 guests