Changing an object's layer

Hi Dan,

I have not tried it yet, but I will. Your edit optional context menu handler sounds exactly what I was looking for.

Thanks,
Velina

I can’t try your method because I’m on macOS, not Windows. I imagine a right click pulling a layers submenu on the contextual menu, with the ability to only select a layer (for the selected entity/group), not create one.

It is not OS dependant code. The menu position indexes might apply only on Windows but should still work on Mac.

Yes, this is exactly what the second context menu handler code does.

1 Like

Is it confirmed that the index doesn’t cause an ArgumentError or other issues on Mac? I’ve always wrapped menu items with positioning with a method that only passes on the index to the native method if known to be supported by the platform.

Re, creating a rb file ...

It is plain text file containing Ruby scripting code, with a .rb file extension instead of a .txt file extension.

A simple basic text editor for simple small snippets like this is fine.

Only the right-click “send to compressed zip folder” might be Windows only.
Mac users have other means (I suppose) of gathering files into a zip archive.

Renaming a file (from a .zip to .rbz extension) is basic computing 101.

The SketchUp Help Center has a treatment of manually installing an extension from a .rbz archive.


I don’t know as I do not have a Mac to test. I “think” I remember that the index doesn’t work on Mac.

1 Like

Your second bit of code works on the Mac. Thanks!

Kewl! Does the “Layers reasssign” appear at the top or bottom of the context menu ?

Here’s how it looks on the Mac (I removed “reassign” from the script). Exactly what I wanted, and I believe also what the original poster wanted. Really cool, thanks again.

3 Likes

Yea, okay. The position indexes are ignored it looks like.


So the Mac edition has no Layers toolbar huh ? sad … it’s a nifty little toolbar.

There is, but it can only live in the Toolbar (it doesn’t float). I don’t have a Windows machine to compare, but based on your earlier screenshots, it’s not exactly the same.

Ah okay. I understand. Yes on Windows we can have floating or docked toolbars.
I think the Mac could also if they switched to using a 3rd party GUI framework like Qt or GTK+.

So, yes the references to LAYERS_TOGGLE can be removed for Mac, and it also looks like it is ignoring the menu separator call on for both platforms (although somehow the Dynamic Components item is adding separators. Not that important I suppose.)

1 Like

That is so cool. I don’t know where to paste the code, so I haven’t gotten this far yet. But I did change my trays around and they autohide on the right side of my screen. I LOVE THAT!! So much better work flow when I have multiple models open.
So, please forgive my ignorance, but where do I cut and paste the code, or how do I make the .rb file that Dan has posted?

Here’s a file that you need to put in the Plugins folder. On a Mac it’s in the user’s Library under Application Support. On Windows, @DanRathbun said:

layer context sketchup.rb (493 Bytes)

If you’d made an RBZ file, it would be easier to install. Find it from Install Extension in the Extension Manager.
layer context sketchup.rbz (450 Bytes)

Yes. And offering the OP an easier way to install without needing to find the correct folder to put the file in. Let SketchUp handle it automatically and correctly.

YAY!!! Check it out! Thanks guys!

2 Likes

There’s no need to be so ‘sensitive’.
There is no ‘shortcoming’ on your part.
But @DaveR simply points out that there are some steps that you could use to simplify things.

Rather than finding your particular system’s Plugins folder and adding your RB file into it and restarting SketchUp…
Make the RB into an RBZ, then use the native installer in Extension Manager > Install… [red button]

To make an RBZ from an RB [or if you have an RB and a supporting subfolder using the same name], select the file[s] and make a ZIP file of the selection.
On Windows it’s a context menu ‘Send to > Compressed…’ action, there are similar MAC functions [e.g. Compress Items…]
Once you have the .ZIP file you can change its ‘file-type’ by changing its suffix to .RBZ
An RBZ is simply a ZIP with an alternative suffix.
The RBZ Installer will then extract the RBZ file’s contents into your Plugins folder, avoiding any potential ‘user-error’…

1 Like

I never said there was.

Evidently you misunderstood what I wrote. I didn’t say or imply there’s anything wrong with your advice. You haven’t been helping other users with SketchUp as long as folks like TIG and I so you haven’t seen the ways users have screwed up installing plugins and extensions when they do it manually. One of the reasons for the Install Extension button in the Extension Manager is to make it easier for users to install extensions and plugins and get it done correctly. It also means that the plugin will load automatically while SketchUp is open. If you just drop the rb file into the directory while SketchUp is open, the plugin won’t appear. You’ll have to do something such as restarting SketchUp to get it to load.

Excellent ! I noticed the up and down menu scroll buttons on your screenshot.
So I went back and tested again myself and realized that when SketchUp is on my secondary display, that the bottom menu scroll button is offscreen and unusable. There is no problem accessing the menu scroll buttons when SketchUp is on the primary display. Weird. (MS Win7)