Sketchup.active_model.materials.current behaviour
-
I am writing a script to change the material for specific part of the model. The idea is that the user will select a material from the Materials window then they will run the script which will use the current material to change some parts of the active model. To get the current material I am using Sketchup.active_model.materials.current. This seems to return the last material that was used (i.e. you actually have to apply it to a face), selecting a new material in the Materials window is not sufficient to change the value of Sketchup.active_model.materials.current.
Any suggestions on how I can determine the material that is selected in the Materials window?
-
I don't see that behaviour. When the selected material is changed,
Sketchup.active_model.materials.current
reflects that.
(SU7) -
When do you call that method?
-
Here is a simple example using the Ruby Console:
Show the current material:
> printf "%s\n", Sketchup.active_model.materials.current.name \[Color_D05] nil
Select a new material in the materials window, check the current material again:
> printf "%s\n", Sketchup.active_model.materials.current.name \[Color_D05] nil
Fill a face with the new material, then check the current material:
> printf "%s\n", Sketchup.active_model.materials.current.name \[Color_F09] nil
Sketchup.active_model.materials.current does not change until the last step
-
Maybe it's a Mac bug. Because on my PC it updates correctly.
I'll test on my mac later when I get time.
Advertisement