+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Senior Member
    Using
    Map 3D 2008
    Join Date
    Sep 2009
    Posts
    114

    Default select last "n" entities drawn inside a lisp

    Registered forum members do not see this ad.

    Hello guys,
    Using a lisp, i draw few entities; how can i select them? I mean, last "n" entities drawn inside a lisp. Thanks!

  2. #2
    Forum Deity Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draftsman
    Discipline
    Mechanical
    Using
    AutoCAD 2014
    Join Date
    Oct 2009
    Location
    Lives in Abu Dhabi
    Posts
    2,633

    Default

    Here are two examples .

    Code:
      (setq line1 (entmakex (list (cons 0 "LINE")(cons 10 p1) (cons 11 p2))))
    Or..

    Code:
    (entmakex (list (cons 0 "LINE")(cons 10 p1) (cons 11 p2)))
    (setq line1 (entlast))
    Tharwat

  3. #3
    Senior Member LibertyOne's Avatar
    Using
    Mechanical 2009
    Join Date
    Apr 2011
    Location
    Germany
    Posts
    111

    Default

    how about something like this?

    Code:
     
    ;;--------------------------------------------------------------;;
    ;; SINCE
    ;; Creates a selection set of all objects created SINCE the
    ;; selected one.
    (defun since (/ ss en)
     (setq ss (ssadd))
     (setq en (car (entsel "\nSelect first object: ")))
     (setq ss (ssadd en ss))
     (while (setq en (entnext en))
      (setq ss (ssadd en ss))
     )
     ss
    )

  4. #4
    Super Member irneb's Avatar
    Computer Details
    irneb's Computer Details
    Operating System:
    Win7 Pro 64bit
    Computer:
    Antec One Hundred
    Motherboard:
    ASUS P8P67-Pro P67
    CPU:
    Intel i7 2600 @ 3.4GHz
    RAM:
    16GB-1600MHz
    Graphics:
    GeForce GT 430 (1GB)
    Primary Storage:
    Seagate1TB SATA2 - 7200rpm
    Monitor:
    Samsung 2333TN 23" 1920 x 1080 Full HD LCD Monitor2GW
    Discipline
    Architectural
    irneb's Discipline Details
    Occupation
    Architectural Technician and Programmer
    Discipline
    Architectural
    Using
    AutoCAD 2013
    Join Date
    Sep 2010
    Location
    Jo'burg SA
    Posts
    1,635

    Default

    Another way could be to save the value of entlast just before creating the entities. Then use entnext to step through all that have been made thereafter. E.g.:
    Code:
    (defun c:MyFunc (/ lastEnt ss)
      ;; Save the last entity
      (setq lastEnt (entlast))
      ;; Do some stuff
      ;; ....
      ;; Select all entities created in this function
      (setq ss (ssadd))
      (while (setq lastEnt (entnext lastEnt))
        (ssadd lastEnt ss)
      )
      (sssetfirst nil ss) ;Grip select the set
      (princ) ;Exit cleanly
    )

  5. #5
    Senior Member LibertyOne's Avatar
    Using
    Mechanical 2009
    Join Date
    Apr 2011
    Location
    Germany
    Posts
    111

    Default

    Quote Originally Posted by irneb View Post
    Another way could be to save the value of entlast just before creating the entities. Then use entnext to step through all that have been made thereafter. E.g.:
    Code:
    (defun c:MyFunc (/ lastEnt ss)
    ;; Save the last entity
    (setq lastEnt (entlast))
    ;; Do some stuff
    ;; ....
    ;; Select all entities created in this function
    (setq ss (ssadd))
    (while (setq lastEnt (entnext lastEnt))
    (ssadd lastEnt ss)
    )
    (sssetfirst nil ss) ;Grip select the set
    (princ) ;Exit cleanly
    )
    This is also a good idea, but I would make a function to set a marker, and another to then retrieve the entities that were made after the marker.
    Code:
    (defun set-bookmark ()
       (setq ent-mark (entlast))
    )
    once this function is defined, you can go about placing it in your code where ever you see fit.
    Code:
    ;; ...your code...
    (set-bookmark)
    ;; ...your code...
    once a bookmark is set, there are endless possibilities of what you can do with the selection sets.

    You can even set multiple markers and use them to create selection sets "in between" and not just from a certain entity to the end.

  6. #6
    Super Member irneb's Avatar
    Computer Details
    irneb's Computer Details
    Operating System:
    Win7 Pro 64bit
    Computer:
    Antec One Hundred
    Motherboard:
    ASUS P8P67-Pro P67
    CPU:
    Intel i7 2600 @ 3.4GHz
    RAM:
    16GB-1600MHz
    Graphics:
    GeForce GT 430 (1GB)
    Primary Storage:
    Seagate1TB SATA2 - 7200rpm
    Monitor:
    Samsung 2333TN 23" 1920 x 1080 Full HD LCD Monitor2GW
    Discipline
    Architectural
    irneb's Discipline Details
    Occupation
    Architectural Technician and Programmer
    Discipline
    Architectural
    Using
    AutoCAD 2013
    Join Date
    Sep 2010
    Location
    Jo'burg SA
    Posts
    1,635

    Default

    Registered forum members do not see this ad.

    Exactly! It's how I created my Select Result routine.

Similar Threads

  1. Can I make "Select boundary objects" default hatch action? (2011)
    By bodejodel in forum AutoCAD 2D Drafting, Object Properties & Interface
    Replies: 3
    Last Post: 14th Sep 2010, 10:09 am
  2. line doesn't drawn "bylayer"
    By salmonrose in forum AutoCAD Beginners' Area
    Replies: 7
    Last Post: 26th Nov 2009, 12:26 am
  3. "select shape file" & TgCad.shx
    By astral_realm in forum AutoCAD Beginners' Area
    Replies: 2
    Last Post: 15th Nov 2009, 10:25 pm
  4. Replies: 3
    Last Post: 23rd Apr 2009, 05:40 pm
  5. "Select shape file"
    By bbfirebird in forum AutoCAD Drawing Management & Output
    Replies: 1
    Last Post: 6th Jan 2006, 06:14 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts