Are the individual setting for materials programmable through the API?
I was looking at the Elgato Streamdeck+ (Stream Deck + | Elgato) and It got me thinking how nice it would be to be able to adjust the selected material’s setting via the dials, specifically I’d like to be able to:
Change the mode between RGB and HLS (a press of one of the dials)
Change the value of R,G,B,A or H,L,S,A (rotate the dials)
Scale the Texture (press to toggle between A and Texture and rotate the dial)
All my work is rendered so being able to quickly and easily ‘play’ with colours and instantly see the results would be if nothing else a lot of fun.
This is of course all moot if the values are inaccessible via the API, so the question is, are they?
However, the GUI interface is a user interface not an API interface. It does not make sense to directly “flip a switch” in the GUI, or “spin a dial” from the API. This is not what the API is for
Instead the API setter methods directly set a color value to what is intended in one step. There is no need to step through a bunch of intermediate color values to get to the value needed.
The current GUI interface does this for the SketchUp view. But SketchUp’s API will not effect external renderings in say V-Ray. The V-Ray (or whatever renderer) interface would need to do this.
I use Enscaple which is a real-time renderer and I can dynamically change the SU material properties and see it instantly in the render window.
Other material properties such as roughness/bump etc are controlled through the Enscape materials dialog but once set for a particular material type I rarely change them.
So are you saying that I could affect the currently selected material’s colour/ texture size via the api? ( I only posted the screenshot for context)
Yes, but I think your not being clear in how you would want to “change” the currently selected material’s properties that would be better or different than through the Materials inspector panel ?
I’ll try and be clearer:
I would like to select a material either through the panel or more often via the eyedropper tool
Change the mode (click action on 1st dial) to either RGB or HLS
Assuming we are in RGB mode
I’d want to be able to change the red value via the 1st dial between 0 and 255
the blue value via the 2nd dial between 0 and 255
the green value via the 3rd dial between 0 and 255
the opacity (alpha) via the 4th dial between 0 and 100
Assuming we are in HLS mode
I’d want to be able to change the Hue value via the 1st dial between 0 and 360
the lightness value via the 2nd dial between 0 and 100
the saturation value via the 3rd dial between 0 and 100
the opacity (alpha) via the 4th dial between 0 and 100
Clicking the 4th dial would change to texture mode, rotating it would increase/decrease the width of the texture (height linked) by NNmm
Okay, still I do not see much difference why you cannot use the native Materials panel.
But YES … if you like, you can program up a HTML Dialog with mirrored controls that affect the same settings you have in the native Materials panel. The learning curve may be steep if you do not know HTML, JavaScript, CSS and Ruby.
There is a quirk with the Sample tool in that after picking a painted face, the Paint Bucket tool is activated. This might be undesired. A workaround might be to code a custom Ruby tool using the PickHelper class.
Sketchup on the Right Monitor and Enscape on the Left, I can fly around the entire house in realtime using the keyboard or the xbox controller.
Picture the SD+ where the xbox controller is and me playing with the wall paint colour in real time.
Hard for me to do, as I don’t know what an SD+ is. A Bing search is of no help.
Speaking of keyboard control, it would likely be possible to code a custom Ruby Tool that accepts certain keypresses to increment or decrement the various material properties.
R - increase Red component
SHIFT+R - decrease Red component
G - increase Green component
SHIFT+G - decrease Green component
W - increase Texture width
SHIFT+W - decrease Texture width
I’m following this thread - I’ve been looking at making a new colour picker that isn’t SRGB based.
There are lots of better perceptual alternatives now - SketchUp for i.pad has OKLAB or OKHSL which is so much better for humans.
I’m not well versed in this stuff , but after @thomthom and @ChrisFullmer 's Ruby 401 class at Basecamp , I’ve been trying
# Get the active material
model = Sketchup.active_model
materials = model.materials
# Create a color object from RGB values
red_color = 199
blue_color =75
Green_Color =137
new_color = Sketchup::Color.new(red_color, blue_color, Green_Color)
# Assign the color object to the active material's color property
active_material.color = new_color
now all you need is a way to get your streamdeck to change those SRGB values and a way to send that ruby script to SketchUp
I think that just after SketchUp loads a model, there is no current material and nil will be returned.
This means either your code or the user must select a material from the “In Model” materials collection.
If the setup on the SD+ causes the PC to send a key press event to SketchUp, there would be no difference in handling it in a Ruby Tool than if a real key is pressed.
If the rb was assigned an obscure SketchUp keyboard shortcut such as Ctrl-Alt-Shift-R then it should work.
I do see a problem though as we need ones for Red+, Red-, Blue+, Blue-, Green+, Green- and the same for HLS, the mode switch (RGB>HLS) and transparency… that’s a lot of shortcuts.
There is an SDK for the Elgato products but that’s seriously beyond me… I’m just a user