sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    [Plugin] Select component instances on right click

    Scheduled Pinned Locked Moved Plugins
    28 Posts 16 Posters 33.9k Views 16 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • K Offline
      kwistenbiebel
      last edited by

      That is really handy!

      Thank you very much.

      1 Reply Last reply Reply Quote 0
      • Didier BurD Offline
        Didier Bur
        last edited by

        Hi,

        Very handy. May I suggest to change last line of the script

        file_loaded "fr_cleanup.rb"
        

        to

        file_loaded "select_instance.rb"
        

        and it would be nice to have the option in the context menu ONLY if selection is not empty AND all objects selected are components.

        For instance, the following function should do it:

        
        def compos_valid_selection
        s=Sketchup.active_model.selection
        return false if s.empty?
        types=[]
        s.each { |e| types.push(e.typename) }
        types.uniq!
        return false if types.length != 1
        return false if types[0]!= "ComponentInstance"
        return true if types[0]== "ComponentInstance"
        end
        
        

        Then in the menu definition:

        
        UI.add_context_menu_handler do |menu|
          if compos_valid_selection
          menu.add_separator
          menu.add_item("Select Instances") { select_component_instance }
          end
        end
        
        

        Regards,

        DB

        1 Reply Last reply Reply Quote 0
        • C Offline
          confitex architure
          last edited by

          The new version (v2) has been posted!
          See above.

          1 Reply Last reply Reply Quote 0
          • boofredlayB Offline
            boofredlay
            last edited by

            Thank you very much.

            http://www.coroflot.com/boofredlay

            1 Reply Last reply Reply Quote 0
            • S Offline
              sepo
              last edited by

              I have just tried with simple component. Copied it couple of times and make one unique. Went into component and changed colour of the group (also made unique). In the context menu I have "select instances" but not "select families". I have installed the version 2 from the top of this tread.
              Thanks

              1 Reply Last reply Reply Quote 0
              • R Offline
                RickW
                last edited by

                Wow, I need to do more marketing! Instances has been available at Smustard for a couple of years, now. 😄

                You've added some nice additional functionality.

                RickW
                [www.smustard.com](http://www.smustard.com)

                1 Reply Last reply Reply Quote 0
                • C Offline
                  confitex architure
                  last edited by

                  @rickw said:

                  Wow, I need to do more marketing! Instances has been available at Smustard for a couple of years, now. 😄

                  You've added some nice additional functionality.

                  Oops, I wish I could know this a couple of years ago 😕
                  Thanks Rick!

                  1 Reply Last reply Reply Quote 0
                  • W Offline
                    watkins
                    last edited by

                    Dear Rick,

                    I have been using your script for quite a while now, and find it very useful. Particularly for making arrays of holes. I draw the first circle on the surface and then make it a component - say Hole_1. I then use move and copy to array the component on the surface. Then I select one of the hole components and go to "select instances". I then explode the components which makes all the circles sink nicely into the surface (no need to trace over circles). This is followed by the push/pull tool to drive the holes through the component (double click if uniform thickness).

                    Thanks once again.

                    Regards,
                    Bob

                    1 Reply Last reply Reply Quote 0
                    • S Offline
                      sepo
                      last edited by

                      OK found the culprit. Did not remove old selectinstance.rb. Now have the select families and it works like charm.... Thanks for very useful script.

                      Coen 😄 did not get your comment.

                      1 Reply Last reply Reply Quote 0
                      • J Offline
                        Jorgensen
                        last edited by

                        Would it be possible to change the script so that it don't select instances that are hidden, or instances that are on a hidden layer ?

                        Just an idea, don't know if others have this need 😄

                        Thanks
                        Jorgensen

                        sketchup pro 2016 16.1.1449 64 bit | windows 10 pro | i7-3770k @3.5 GHz | 16gb ram | gtx 780 ti / gtx 980 ti | nvidia driver 368.39

                        1 Reply Last reply Reply Quote 0
                        • C Offline
                          confitex architure
                          last edited by

                          @jorgensen said:

                          Would it be possible to change the script so that it don't select instances that are hidden, or instances that are on a hidden layer ?

                          Yes it is. It's even far better. The link on the first post has been refreshed

                          1 Reply Last reply Reply Quote 0
                          • C Offline
                            confitex architure
                            last edited by

                            @sepo said:

                            I have installed the version 2 from the top of this tread.
                            Thanks

                            Hi sepo, What are the name of your instances? select instances only works when components are selected, no groups allowed in the selection set.
                            Are you sure you've deleted the first version of the plugin?

                            1 Reply Last reply Reply Quote 0
                            • M Offline
                              Morpeth
                              last edited by

                              very impressed.

                              1 Reply Last reply Reply Quote 0
                              • JClementsJ Offline
                                JClements
                                last edited by

                                Doesn't work for me for the Families.

                                If I select either a unique component version or the original component, right-click, choose Families from the menu the result is that the geometry is DESELECTED.

                                I copied the script at the top of the posting 31 May 08 (a.m.).

                                Also, note that the there are two .rb's listed in the script, one with "v2", the other without.

                                John | Illustrator | Beaverton, Oregon

                                1 Reply Last reply Reply Quote 0
                                • JClementsJ Offline
                                  JClements
                                  last edited by

                                  This is a copy of part of the script's code. See the reference to the .rb in the 1st and last line:

                                  @unknownuser said:

                                  if (not file_loaded?("select_instance.rb") )
                                  UI.add_context_menu_handler do |menu|
                                  if compos_valid_selection
                                  menu.add_separator
                                  menu.add_item("Select Instances") { select_component_instance }
                                  menu.add_item("Select Families") { select_component_made_unique }
                                  end
                                  end
                                  end

                                  file_loaded "select_instancev2.rb"

                                  Attached is a test file. Now when I run the script, choosing Select Families recogizes a family component and selects one family instance.

                                  Try right-clicking on each component instant and the choose Select Families; for me the resulting selection always changes to Object B. Is the script intended to work or is it supposed to select all family instances at once?


                                  Instances.skp

                                  John | Illustrator | Beaverton, Oregon

                                  1 Reply Last reply Reply Quote 0
                                  • C Offline
                                    confitex architure
                                    last edited by

                                    Hi John,
                                    I don't understand what's wrong with the list. Do you mean in your plugins folder? You should erase the former version, the one without the "v2", from this folder.
                                    I tried again and again and everything is ok on my side. What are the name of your components ?

                                    1 Reply Last reply Reply Quote 0
                                    • C Offline
                                      confitex architure
                                      last edited by

                                      Hi John,

                                      @unknownuser said:

                                      Is the script intended to work or is it supposed to select all family instances at once?
                                      ❗

                                      it has been fixed (DL on the first post)

                                      1 Reply Last reply Reply Quote 0
                                      • JClementsJ Offline
                                        JClements
                                        last edited by

                                        Thank you.

                                        John | Illustrator | Beaverton, Oregon

                                        1 Reply Last reply Reply Quote 0
                                        • A Offline
                                          Abdullah
                                          last edited by

                                          Hi,
                                          I want to select multiple components with similar definition names (like "compo" and "comp#1") in the entire Model. It means, it means not only those inside the selected object, but also the others ones which are inside other objects.

                                          I have the following plugins:
                                          [] "Selection Toys", which selects components from everywhere, but only those with same name.
                                          [
                                          ] "Select Instances", which selects component families with similar names (like "compo" and "comp#1"), but only inside the selected object and not everywhere.

                                          1 Reply Last reply Reply Quote 0
                                          • TIGT Offline
                                            TIG Moderator
                                            last edited by

                                            Take care making selection sets that span different contexts - you can Bugsplat it you try to manipulate them !
                                            To select instances of similar named definitions this will work

                                            n="match";m=Sketchup.active_model;s=m.selection;s.clear;m.definitions.each{|d|s.add d.instances if d.name=~/#{n}/}
                                            

                                            Change the string 'match' within the "" to the pattern match you want - I suggest that you read-up of pattern-matching - e.g. n="[Cc]at" finds all definitions like 'Cat', 'cat1', 'tomcat', whereas anchoring the pattern to the start/end like this n="^[Cc]at" only matches 'Cat and 'cat1', or n="m[Cc]at$" to only matches '#tomcat' and 'TomCat'...

                                            TIG

                                            1 Reply Last reply Reply Quote 0
                                            • 1
                                            • 2
                                            • 1 / 2
                                            • First post
                                              Last post
                                            Buy SketchPlus
                                            Buy SUbD
                                            Buy WrapR
                                            Buy eBook
                                            Buy Modelur
                                            Buy Vertex Tools
                                            Buy SketchCuisine
                                            Buy FormFonts

                                            Advertisement