Guide lines and macros

One of the limitations of SU is that it can be difficult to keep guide lines that might be useful. That is because the Delete Guides command is all encompassing and will delete guide lines even when “protected” inside a Group or Component. A workaround I have found is to Select All, then Select Guides (might require Selection Toys extension) before deleting. That will only select the guides in the current level, leaving those in any nested levels untouched.

I would like to replace the shortcut key I use for the inbuilt Delete Guides command with one that runs the above sequence. There is advice about how to use Automator here but I am not sure whether it can be made to work for what I want to do. The tutorial is 7 years old and I am not sure it still applies. Does anyone know?

Copy/paste this text into a new text-file using a plain-text editor like TextWrangler [MAC] - or Notepad++ [PC].
Name the file DeleteActiveGuides.rb
Make or put it in the …/Plugins folder.
After SketchUp restarts and loads it, it creates a new entry in the Extensions menu, named DeleteActiveGuides
It deletes the guides in the current context, leaving any nested inside groups etc unaffected.
It’s one-step undo-able.
You can easily make a shortcut to this…

# encoding: UTF-8
module TIG
  module DeleteActiveGuides
    unless @loaded
      UI.menu("Plugins").add_item("DeleteActiveGuides"){self.run()}
      @loaded = true
    end 
    def self.run()
      model = Sketchup.active_model
      model.start_operation("DeleteActiveGuides", true)
        ents = model.active_entities
        glns = ents.grep(Sketchup::ConstructionLine)
        ents.erase_entities(glns) if glns[0]
      model.commit_operation
    end
  end
end
10 Likes

Did exactly as you said and bingo, it works like a dream. Put a smile on my face today. Thanks @TIG. A much more elegant solution than using Automator, I’m sure.

Interestingly, I see that the script deletes guidelines but not guide points. Is that intentional?

I thought it was what you asked for ! :wink:
But if you want to included guide-points, then try this…

# encoding: UTF-8
module TIG
  module DeleteActiveGuides
    unless @loaded
      UI.menu("Plugins").add_item("DeleteActiveGuides"){self.run()}
      @loaded = true
    end 
    def self.run()
      model = Sketchup.active_model
      model.start_operation("DeleteActiveGuides", true)
        ents = model.active_entities
        glns = ents.grep(Sketchup::ConstructionLine)
        glns = glns + ents.grep(Sketchup::ConstructionPoint) ###
        ents.erase_entities(glns) if glns[0]
      model.commit_operation
    end
  end
end
1 Like

You’re quite right. I assumed it would work much like the native Delete Guides by deleting points too. But I will try out your new version. The old version works fine and is useful whatever.

I’m trying it with line 5 as …

      UI.menu("Edit").add_item("Delete Active Guides",8){self.run()}

… so it appears as …

image

2 Likes

Just tested the new version and with @DanRathbun’s suggested tweak. It all works as expected. So thanks guys, that’s going to give me a new string to my bow.

Now if we could just make the guide lines within a group only visible when you are editing it… I know, I know, now I’m really pushing my luck!

1 Like

Sounds like a good general FR for the application.

Please note that Guides (points and lines) as well as dimensions and callout text are NOT geometric primitives, so they can use special layers so you can control their visibility.

If you do this, then an extension could likely be written to automatically show and hide the group’s guides by using an InstanceObserver. Actually might not even need guide layers. (I just prefer them to using the specific entity hidden property.)

I’d be surprised if there wasn’t already an extension to do this.


Another thing to consider. IF a group or component instance’s guide are unhidden, then they’ll be unhidden in all instance’s of that group or component.

1 Like