• Login
sketchucation logo sketchucation
  • Login
ℹ️ GoFundMe | Our friend Gus Robatto needs some help in a challenging time Learn More

Select last entity

Scheduled Pinned Locked Moved Developers' Forum
18 Posts 6 Posters 2.3k Views
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.
  • D Offline
    david_h
    last edited by 20 May 2008, 15:34

    Is anyone aware of a selection ruby that allows one to select the Last Entity Drawn or Placed? similar to the selection option in . .. dare I say it. . .Autocad?

    Thx,

    David

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

    1 Reply Last reply Reply Quote 0
    • D Offline
      Didier Bur
      last edited by 20 May 2008, 20:36

      I wonder if it would be possible in Ruby to get the equivalent of "entlast" in Autolisp ???
      I guess no πŸ‘Ž

      DB

      1 Reply Last reply Reply Quote 0
      • D Offline
        david_h
        last edited by 20 May 2008, 22:13

        M. Didier. .. If there is anyone in the universe who could figure this out, it would be you. So, Hopefully. . ..

        I was thinking. . .a script that Selects last, or Selects previous would be awesome. I have the Seelction Memorize tool and that works okay mosto f the time, but . .. anyway, think about it.

        Thx

        D

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

        1 Reply Last reply Reply Quote 0
        • M Offline
          Matt666
          last edited by 21 May 2008, 06:11

          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
          • D Offline
            Didier Bur
            last edited by 21 May 2008, 13:01

            He Matt Γ§a marche !!! (Hey it works !)

            DB

            1 Reply Last reply Reply Quote 0
            • M Offline
              Matt666
              last edited by 21 May 2008, 13:04

              😎

              Frenglish at its best !
              My scripts

              1 Reply Last reply Reply Quote 0
              • D Offline
                david_h
                last edited by 21 May 2008, 14:16

                okay. . . je suis perdu . . .comment ca marche? πŸ˜•

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

                1 Reply Last reply Reply Quote 0
                • D Offline
                  Didier Bur
                  last edited by 21 May 2008, 14:51

                  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 21 May 2008, 14:59

                    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 21 May 2008, 15:41

                      Hi !
                      Here's the code !


                      entlast.rb

                      Frenglish at its best !
                      My scripts

                      1 Reply Last reply Reply Quote 0
                      • D Offline
                        david_h
                        last edited by 21 May 2008, 18:55

                        @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
                        • D Offline
                          david_h
                          last edited by 21 May 2008, 19:08

                          works great. Thank you!

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

                          1 Reply Last reply Reply Quote 0
                          • D Offline
                            Didier Bur
                            last edited by 21 May 2008, 19:19

                            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 22 May 2008, 19:29

                              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 22 May 2008, 19:45

                                😲
                                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 22 May 2008, 19:56

                                  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 23 May 2008, 15:25

                                    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 6 Mar 2024, 14:56

                                      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