Default tray opening when adding material from script

Hi Guys,

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?

SketchUp 2020, Windows 10.


I think this is inherent to SketchUp. Activating Paint tool seems to always open the Material inspector.

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?

That’s another problem, which is even worse.

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 was thinking about ThruPaint while I wrote my thing. Does that mean you found a solution?

I’m confused… Doug, aren’t you Product Manager at SketchUp?

Once was, but I’ve left Trimble and moved back to New Zealand.

Currently writing a book on design and product management. And also playing around with a Sketchup extension while looking for a job.

It’s certainly been interesting seeing it from the extension developers side of the equation. I’m appreciating the effort that goes into things.

Thanks Fredo, I might get my thinking cap on and try some things.

I’ll check out that extension to see the user experience of it.

Oh I see! Good luck in your new ventures

1 Like

Really man, you should get familiar with the basics of SketchUp first.

(disclaimer, Doug knows that I’m teasing)

I normally just do the advanced stuff and skip the basics :wink:

Not sure how that’s working out though.

1 Like

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.

I have nothing to add, but just wanted to thank Dan for the many times that he knows the right answer.

1 Like

Ok thanks everyone + Dan.

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?

What might not work on Mac? Certainly pick helper works fine.

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.