Change Color Object....
I have a simple(?) question for your.
I have create a little script that allows to assign a standard material in an object:
---------------------------------------------------------------------------------------
mat_obj = StandardMaterial()-- create standard material
rollout testcolor "Test Color"
(
colorPicker col "Bmc" color:(color 81 81 81)--create color pick
button ins "Assign Color to selection" --create button
on col changed new_col do mat_obj.diffuse = new_col --create new diffuse color for the StandardMarterial
on ins pressed do
(
$.material = mat_obj --- assign the color to the object
)
)
createdialog testcolor
------------------------------------------------------------------------------------
Now, if I have one object in the scene no problem.
With two or more object (Sphere,Box ecc.), when I assign the color of the first object is updated continuously...To understand the problem better evaluate the script above with two object.
My question is this:
How do I assign different colors in the different selected object without updated the color assigned and without closed the script rollout?
The workflow must be:
Select Object
Assign color with color picker to the object
Select second object
Assign new color to the second object
ans so..
Any Help?
Thanks in advance Michele
Comments
select objects by wirecolor
How can I select objects by wirecolor with MAX script
There is already a
There is already a macroscript built in Max for this. Customize UI -> Quads/Tabs whatever -> Category: All Commands -> "Select by Color".
with maxscript it could work like this:
Never get low & slow & out of ideas
You assign material as
You assign material as instance, there's why the color changed
but Marco posted yet a good snippet, you can use it.
my recent MAXScripts RSS (archive here)
Anubis Thanks for you reply!.
Anubis Thanks for you reply!. The suggestion of Marco is the best solution for me. However your solution is very useful to understand!
Again Thanks Michele
The problem is the scope of
The problem is the scope of the variables, by defining mat_obj before the rollout you are giving it a higher scope (and probably even making it global if that's the whole script). However if I understand correctly you need to create a new material every time that you assign the color to the selected object. A simple solution could be:
This way whenever you hit the button, the script creates a NEW material using the color currently in the colorPicker as diffuse color.
Yes Marco, You've hit the
Yes Marco, You've hit the target! :)
Honestly, I do not believe that the problem was the variable(mat_obj)! I never finish to learn new things...
So, if I understand correctly, this type of variable it is better to include in the execution strings?
So, Thanks 1000 Marco! :) :)
hi, Michele ... i try to help
hi, Michele ...
i try to help you a bit by example, seem like this :
I think you must compare the count between object and color first, and the count must be identical...
hope that's helped
regards
budi
Thanks Budi, but your answer
Thanks Budi, but your answer does not solve the problem...
The problem is when I insert the new color (or even the same) in the object selected.
If I select a object and assign any color to it (with pickcolor button), then I select a second object and assign with pickcolor another color to it, is also updated the first color set (my example written above)!
However, your example, I was of help. I try it with another solution ;)
Many thanks Michele.
ops... sory :D ... ok no
ops... sory :D ... ok no problem ;)
I want to answer your question... but the anubis and marco have resolve your problem ... exactly they're right
regards
Budi no problem! You I've
Budi no problem! You I've been helpful anyway and I thank you again :) With your response I learned something I did not know so, Thanks!!! :) :) :)