sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    🫛 Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download

    Select last entity

    Scheduled Pinned Locked Moved Developers' Forum
    18 Posts 6 Posters 2.4k Views 6 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.
    • M Offline
      Matt666
      last edited by

      Or (ssget "_p"), or tool "select", and Key "P" (in AutoCAD)...
      You could do smth Perhaps with the last entity in the active entities selection list ?

      
      def entlast
      	model = Sketchup.active_model
      	sel = model.active_entities
      	ss = model.selection
      	n = sel.length - 1
      	ss.add(sel[n])
      end
      

      I have not tested yet...

      Frenglish at its best !
      My scripts

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

        He Matt ça marche !!! (Hey it works !)

        DB

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

          😎

          Frenglish at its best !
          My scripts

          1 Reply Last reply Reply Quote 0
          • david_hD Offline
            david_h
            last edited by

            okay. . . je suis perdu . . .comment ca marche? 😕

            If I make it look easy...It is probably easy

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

              David,
              Just wait until me or Matt makes it a usable script.
              If you can't wait, 🎉 open the ruby console and when you need to select last entity drawn or inserted, type "entlast" (no quotes).

              DB

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

                David,
                Last year RickW(http://www.sketchucation.com/forums/scf/memberlist.php?mode=viewprofile&u=370) wrote Selection Memory 2. Fantastic tool. Definite must have.

                Hank

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

                  Hi !
                  Here's the code !


                  entlast.rb

                  Frenglish at its best !
                  My scripts

                  1 Reply Last reply Reply Quote 0
                  • david_hD Offline
                    david_h
                    last edited by

                    @rhankc said:

                    David,
                    Last year RickW(http://www.sketchucation.com/forums/scf/memberlist.php?mode=viewprofile&u=370) wrote Selection Memory 2. Fantastic tool. Definite must have.

                    %(#0040FF)[yeah . .that's the one I was referring to. Got it. Thanks! 😄]
                    Didier and Matt!. . .Merci Mille Fois! I will give this one a test drive.

                    %(#801000)[Just as a side note, at the 05 basecamp I went to the Ruby Scripting class to hopefully learn somewhat how to do it. Was totally blown out of the room. So I am glad there are you guys around for us dum dums. 💚]

                    If I make it look easy...It is probably easy

                    1 Reply Last reply Reply Quote 0
                    • david_hD Offline
                      david_h
                      last edited by

                      works great. Thank you!

                      If I make it look easy...It is probably easy

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

                        Here is another one, with context menu. Adds last entity to selection or select last entity only.


                        entlast.rb

                        DB

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

                          You could also create this as a method for the Entities and Selection classes:

                          class Sketchup;;Entities
                           def last
                            return self[-1]
                           end
                          end #class
                          
                          class Sketchup;;Selection
                           def lastent
                            add Sketchup.active_model.entities.last
                           end
                           def lastentonly
                            clear
                            add Sketchup.active_model.entities.last
                           end
                          end #class
                          
                          

                          then add your user interface/dialog/menu item, whatever.

                          This also allows the methods to be called by other scripts in a predictable manner.

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

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

                            😲
                            Wouah !!
                            I wanted to do same thing but I but I didn't know how to...
                            How can you do that : Sketchup.active_model.entlast please ???

                            Frenglish at its best !
                            My scripts

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

                              Like that ?

                              class Sketchup;;Model
                              	def entlast
                              		nb = self.active_entities.length
                              		
                              		return self.active_entities[nb-1]
                              	end
                              end
                              

                              😄

                              Frenglish at its best !
                              My scripts

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

                                Or like this:

                                class Sketchup;;Model
                                
                                def entlast
                                  return entities[-1]
                                end
                                
                                end #class
                                
                                

                                Using entities or active_entities depends on whether you want the absolute last entity created, or the last entity created in that space (ie within a group or component).

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

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

                                  This is quite useful for selecting the last object extension. Could there be a variation of this that selects and zooms into the last object?

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

                                  Advertisement