Script check-->materials
-
This is my script:
ss.each{|e| mat= e.get_attribute 'xdid_dict', 'sumatdisplay' if not mat UI.messagebox("no material specs in dict.") if e.material.display_name UI.messagebox("has a material") else UI.messagebox("has no material") end end }
What i want it to do is:
A. See if the selected object already has dictionary attributes defined:ss.each{|e| mat= e.get_attribute 'xdid_dict', 'sumatdisplay' if not mat UI.messagebox("no material specs in dict.")
These values are written in an earlier stage after some command is executed (this command writes the folowing values:
orig_name=e.material.name orig_materialtype=e.material.materialType orig_display_name=e.material.display_name orig_texture=e.material.texture orig_color=e.material.color orig_alpha=e.material.alpha e.set_attribute 'xdid_dict', 'sumatname', orig_name e.set_attribute 'xdid_dict', 'sumattype', orig_materialtype e.set_attribute 'xdid_dict', 'sumatdisplay', orig_display_name e.set_attribute 'xdid_dict', 'sumattexture', orig_texture e.set_attribute 'xdid_dict', 'sumatcolor', orig_color e.set_attribute 'xdid_dict', 'sumatalpha', orig_alpha
)
Question: Isn't it just possible to get the ID of the material the object has? Instead of the need to keep all these seperate variables?B. Now i have noticed that fresh created objects who have no material attached do not have any material values (how does SU stores their color-visual representation?). So i check these:
if e.material.display_name UI.messagebox("has a material") else UI.messagebox("has no material") end
This does not work. If there is no material assigned, then the script stops and does not sign "has no material". If there is a material assigned then the message "has a material" shows up ok.
Now maybe i'm a bit on the wrong path here, so i'll try to explain what i try to do:
Store the material-color (the visual part of an entity-group-...) in an attribute dictionary.
So when i do changes to them then i can get the original back.
It would be great if each material in SU had an ID and each object had this ID so i just have to store that one in the attribute dict.Thanks!!
-
Have a look at the Greyscale plugin recently posted. It saves a material's original color before changing the material's color to greyscale.
-
Pout
You should turn on the Ruby Console, and use "puts <message>", instead of UI.messagebox. This will help you to understand what's going wrong.
You could also take some inspiration from an old script I wrote, which toggle the selection between xray and normal.
I reattach it here
-
works, thank you very much
Advertisement