All On/All Off Tags

I have two scenes in my default template entitled All On and All Off. They refer to tags (apart from the Untagged category).

But what about using the unused box in the Tag tray to perform this task? It might look like this:

It would save me having those two pre-set scenes in my template. More importantly, I would think it is common to want to toggle wholesale tag visibility like this, if only to check for rogue elements.

1 Like

Are you suggesting that you would select the tags you want to show or hide and click the visibility button to the left of Name?

No.

At present (and without scenes set up to do the job), if you want to turn all tags off, you have to highlight them all, excluding Untagged, and toggle the visibility. When you want to turn them all back on again, you do the reverse. Itā€™s not too hard but it would just be quicker still if you could avoid having to do any selection by toggling the ā€œeyeā€ next to Name.

I see.

I have some code that will toggle various layers on or off with keyboard shortcuts, e.g.

def toggle_NewTag
		
	if (Sketchup.active_model.layers["CONDITION_New"].visible? == true)
		Sketchup.active_model.layers["CONDITION_New"].visible = false
		Sketchup.active_model.layers["CONDITION_Modified"].visible = true
	else
		Sketchup.active_model.layers["CONDITION_New"].visible = true
		Sketchup.active_model.layers["CONDITION_Modified"].visible = false
	end
		
end
toggle_Layer = UI.menu("Tools").add_submenu("Toggle Layers")

    toggle_Layer.add_item("Toggle New Tag") { toggle_NewTag }

Iā€™m not familiar enough with the API to know if itā€™s possible to have some code that will toggle all layers (except untagged) on / off.

A rightclick option with ā€˜Isolate layer Tag would be nice per tag and ā€˜show allā€™ and ā€˜hide allā€™ on top.
Ofcourse, this is allready implemented in Trimble Connect:

Jack, I guess that would achieve much the same thing. Presumably, if you Isolate Untagged that would be the only tag left showing and Unisolate would reverse the filter.

Iā€™m not sure of the difference between Unisolate and Show All. I also canā€™t think why you would want to Hide All if that means all tags, including Untagged, are off (something that is not currently possible in SU).

Show all is when you didnā€™t isolate a layer, but just turned some off with the eye-icon. Having the option to turn all off just means that you wonā€™t see anything, handy if you want to load another model ( you can view different models at the same time)

Simon, am I missing something here? Group Your tags is an option that is available.
Group tags

I guess youā€™re right that I could group all my tags under one folder and use that to turn everything on and off in one go. And if you could have more than one level of nesting, that would be a realistic option. But I wouldnā€™t want to use up all my folder options just for that one task. In your example, you didnā€™t turn all tags off I noticed.

To expand on that, I mainly use All Off to check that I donā€™t have any loose geometry left ungrouped. So I just want a quick and dirty way to do that without laboriously selecting a long list. And then to toggle and return to All On just as quickly. At present, I have two ways to do that. One is to set up a scene with all tags set to off. The problem with that is that, as you add tags, you have to remember to go back into the scene and turn the new tag off. The other way is to select the whole list of tags in the dialog box and hit the eye icon.

I know I am suggesting a very small degree of improvement but it is a facility that is commonly found elsewhere so you could argue that it might be expected.

Thanks to @DanRathbun and @slbaumgartner on another thread, I worked out this script that works for meā€¦

def toggle_OnOff
model = Sketchup.active_model
layers = model.layers
model.active_layer = layers[0]
layers_toggle = (model.layers.to_a) - [model.active_layer]
	if ( layers_toggle.any? {|l| l.visible? == false } )
   	layers_toggle.each {|l| l.visible = true }
	else
	layers_toggle.each {|l| l.visible = false } 
	end	
end

add_separator_to_menu("Tools")
UI.menu("Tools").add_item("Toggle Layers On/Off") { toggle_OnOff }

It creates a menu item in Tools (Iā€™ve set up a shortcut) and will set the active layer to untagged then will toggle all tags except untagged on / off.

Iā€™m not fluent in Ruby so the above might not be quite right or efficient.

1 Like

Interesting.

Not being a coder myself I am not even sure where this script would be put. Also, is there any way to tell if it will work on a Mac without the trial and error?

I wrote the script in a text editor and saved it with a rb extension ( e.g. toggle_OnOff.rb ) to the plugin folder ( donā€™t know where it is on a mac ).

When you next start SketchUp the script will be active.

If it doesnā€™t work then you can delete it from the plugins folder.

( Thereā€™s probably a ā€˜properā€™ procedure to do thisā€¦? )

Oh dearā€¦

This is what the text file looks like but I canā€™t see the error.

:thinking:

I canā€™t see anything thatā€™s obvious.

I donā€™t know if it matters but perhaps you could try renaming the file to tag_toggle.rb ( i.e. without the space )ā€¦?

Ha! I noticed that too and changed it, then reloaded. But I still got the error message. Iā€™m guessing maybe scripts work a little differently in the Mac OS? Maybe @DanRathbun or @slbaumgartner know?

That looks like a cut-n-paste error, like maybe you picked up some extra html from the page.

I agree, Steve, but all I did was highlight Paulā€™s text, then copied and pasted it into TextEdit. Admittedly, I wasnā€™t allowed to save it with the .rb suffix. So I saved it without and then changed the suffix afterwards. Could that have screwed it up?

My TextEd screenshot above was after changing the suffix. The text doesnā€™t look any different to the original.

I just tried using an online html editor and pasted the text into that. But that also created an error message (though a bit different).

OK, Iā€™m out of my depth now and looking for some water wings.

Try this file

toggle_tags.rb (435 Bytes)

Iā€™m thinking now that is some control markup added by your text editor to indicate RTF (rich text format).

1 Like

Yes, (Steve is correct it got saved as RTF) ā€¦ it needs to be saved as UTF-8 encoded plain text with a .rb file extension. (You can always save it as .txt and then rename it after the save.)