Trying to create an extension 'Tag Folder Visibility' to hide and show specific tag folders

Oh - I see now. The scenario I would usually not want is to switch the layer and then begin adding tagged geometry. But bringing a component in from the Component Panel with an alternate Tag/Layer set as current tags the component. I did not know that.

Do you know what the difference is between toggling the visibility of Tags and toggling the visibility of Groups/Components in the Outliner vs. Fade rest of model → Hide? Everything else is not hidden in the Outliner and their visibility toggle status appears active.

I also tested by selecting a component and then selecting View Hidden Objects. That doesn’t make the hidden groups/components appear.

I did another test by creating Dummy Tag, a tag that is not in any folder. I set it as current. When I toggle the visibility of Untagged, all of the groups/components in the model space have their visibility toggled. But they are also dimmed in the Outliner - which is not their behavior when Untagged is current and any other tag or tag layer is current (normally their display is dimmed when visibility toggling is performed in the Outliner).

1 Like

This does not display objects assigned to tags that are switched off.
But does not change their individual visibility property.
It is just a display override.

This does change their individual visibility property for what is changed in Outliner.

This does not display objects outside the current edit context.
But does not change their individual visibility property.
It is just a display override.

I think TIG has a plugin that uses observer(s) to watch things and if it is active and the user tries to add primitive geometry it either pops up a warning or automatically switches back to the “Untagged” layer.

It is likely hosted over at SketchUcation.

If you are within an edit context of a group / component, and Fade Rest → Hide is checked, then anything outside the context is not displayed whether View > Show Hidden Objects is on or not.

But anything within the edit context or nested below it that is hidden, will show as dashed edges and faces when View > Show Hidden Objects is on.

I think that there was another recent questioning of this being strange or perhaps a bug.

We would think that, if all the primitive geometry was assigned to “Untagged” and if it’s parent instance was assigned to a visible tag, … that if we switched off “Untagged” then all the primitive edges and faces would not be displayed.

But, this is not the case and it has worked like this since at least 2017.

1 Like

I have some reading to do…

I don’t know. My brain is still looping on why I’d want to move the pencil from Untagged to make anything else the active layer.

Drafsmen today, maybe in the past also, have to be very disciplined. Mistakes are unavoidable, though. Even though we teach people -always- to draw raw geometry untagged, my experience is that Sketchup is fairly forgiving.

What I’m trying to express is that it seems very natural to move from a general state to a specific state and then to be able to return to this former general state. Which TIG’s method does very well.

Our simple human minds seem to be able to follow this quite easily.

I can’t replicate this. What I see is when ever a tag is hidden the groups with that tag are dimmed in the outliner, regardless of the current tag.

afaik Sketchups default behaviour has always been that untagged geometry (on ‘Layer 0’) gets hidden when untagged gets hidden, unless it’s in a tagged group (on another ‘layer’). This is what makes untagged different from tagged. The qualities of untagged elements ‘are attributed’ to those of it’s parent group tag (I hope I’m frasing this correctly).

Okay, I see what you mean. I did not state that correctly. They are not dimmed if inside of untagged groups. What I did was to have tagged groups/components inside of untagged top-level groups (because I was using color by tag - a separate issue). The other way is to have the tags for groups/components inside of tag folders.

Not dimmed via folder visibility: untagged top level, tags in folders:

Dimmed via untagged: untagged top level, tags in folders, Dummy Tag current layer:

I guess I hadn’t changed the current layer from Untagged enough to realize that Untagged is like a tag itself.

Please avoid using the term “on layer” as layers (tags) are not geometric collections. They are simply display property sets used by the display engine that can be shared by multiple objects. So geometric objects have a tag (layer) property that are assigned to point at a layer object or nil.

Yes, you phrased it correctly. It is similar to how nested faces that are unpainted with materials (i.e., equal to nil,) are displayed using their parent instance’s material (if assigned.)

1 Like

Here’s a version that toggle’s folders ‘below’, although at first site it might work contrary to what one would expect. It’s not completely foolproof yet either, because it can’t hide all folders as was demonstrated in version 0.0.8.

It is, I think, a way to swifty be able to approach nested geometry without using the outliner (haven’t tested it yet, though).

Edit: this now works regardless whether the active tag is in a folder or not.

module SUForum
  module FolderVisibility
    extend self
    VERSION ||= "0.3.1"
    MENU ||= "View"

    def all_folders(folders = [], root_folder = Sketchup.active_model.active_layer.parent)
      root_folder.each_folder do |folder|
        folders << folder
        all_folders(folders, folder)
      end
      folders
    end
    
    def toggle_tags(state)
      model = Sketchup.active_model
      active_tag = model.active_layer

      model.layers.each { |tag| tag.visible = state unless tag == active_tag }
    end
    
    #based on: https://community.sketchucation.com/post/1323194
    def toggle_folders()
        model = Sketchup.active_model
        
        model.start_operation("Toggle Floders", true)
        unless @visible and @visible[0] ### hide and remember
          @visible=[]
          all_folders.each{|e| @visible << e if e.visible?}
          @visible.each{ |e| e.visible=false } if @visible[0]
          state = @visible[0] ? 'invisible' : 'no previous selection'
        else ### show and forget
          @visible.each{ |e| e.visible=true if e.valid? }
          @visible = []
          state = 'visible'
        end
        model.commit_operation
        puts state
  end
  
  unless defined?(@ui_loaded)
      add_separator_to_menu(MENU)
      menu = UI.menu(MENU).add_item("Toggle Folders") { toggle_folders() }
      
      @ui_loaded = true
    end
  end
end

1 Like