I’m trying to create a script that will add materials to a SketchUp model.
This is pretty standardly adding the image, color, alpha etc… into the active model.
It’s then selecting the material that was just added, and it’s activating the paint bucket tool via Sketchup.send_action(“selectPaintTool:”) to allow someone to paint with this material.
The problem is that it seems to be popping open the side panel of sketchup when using that selectPaintTool: command.
Is this behavior that is inherent in SketchUp? Or is there an elegant way to override this behavior?
I hadn’t replied, because Doug knows that the materials tray, or the Colors window, will open. He talked about a side panel, and I was wondering if he meant something different.
Would it be possible to have your own non-paint bucket tool that assigned the material to the face under the cursor, without triggering the usual paint bucket?
When you call model.materials.current = <a material>, the Paint Bucket tool is automatically activated (it’s been a nightmare to find a workaround for ThruPaint).
I just tested this on Windows with SketchUp 2020.1 and setting the current material via a Ruby API call does not activate the PaintBucket tool, nor does the tray change to display the Materials panel or it’s tray tab*.
(* I have the Materials and Components panels in a tray tab together labeled “RESOURCES”.)
So …
I would say yes at least on Windows. You can use a PickHelper object.
And somewhere I was involved in a topic on what the native SketchUp cursor IDs were so you could just reuse what was already loaded by the application for the PaintBucket cursor.
For MVP I think I’ll just keep the tray popping open. Then when I add some extra functions I think I’ll need to jump into this pick helper business. If I read between the lines correctly it might not work in Mac? Or I might need an alternate method?
Dan,
You are right. model.materials.current= does not activate the paint tool. There must be some other odysseys with this method. I would need to check.
I do remember there being some issue with changing the current material back around 2015 or so.
I think perhaps, that the Ruby pointer was not following the user’s manual pick, or something similar.