+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 16
  1. #1
    Super Member
    Using
    Civil 3D 2015
    Join Date
    Aug 2015
    Posts
    508

    Default Create selection set for previous objects

    Registered forum members do not see this ad.

    I am curious on how to create a selection set of polylines that were just converted into feature lines. After the _AeccCreateFeatureLines command is run, I am not able to use previous command for the feature lines just created. The reason I am wondering is because I am trying to create a reactor that runs a lisp on these just created feature lines.

  2. #2
    Super Member
    Using
    Civil 3D 2015
    Join Date
    Aug 2015
    Posts
    508

    Default

    I should also add this caveat.I have tried using the last command, but the issue is that it just selects the last created object. For example, if 10 feature lines are created at once, it will only select the last one, not all 10. My only thought is to create another reactor that would run before the objects are converted to feature lines. It would create a selection set of the objects being created and then "feed" the selection set to my reactor that will run after the command is completed. Is there an easier way to do this?

  3. #3
    Super Member
    Computer Details
    tombu's Computer Details
    Operating System:
    Windows 7 64-bit
    Computer:
    Dell
    Discipline
    Civil
    tombu's Discipline Details
    Occupation
    Design Analyst
    Discipline
    Civil
    Details
    Small Street & Stormwater projects. Traffic Calming and other issues.
    Using
    Civil 3D 2018
    Join Date
    Dec 2010
    Location
    Tallahassee, FL USA
    Posts
    814

    Default

    Quote Originally Posted by broncos15 View Post
    My only thought is to create another reactor that would run before the objects are converted to feature lines. It would create a selection set of the objects being created and then "feed" the selection set to my reactor that will run after the command is completed. Is there an easier way to do this?
    Not that I know of I've used Irné Barnard's selresult.lsp http://forums.augi.com/showthread.ph...modification#5 to do that since 2008. It's loaded in my acaddoc.lsp as it must be preloaded.

  4. #4
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Win 7 Pro / Win 10 Pro / Linux Mint
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2018
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,569

    Default

    Retrieve the last entity in the drawing database using the following function prior to running the _AeccCreateFeatureLines command:
    Code:
    ;; entlast  -  Lee Mac
    ;; A wrapper for the entlast function to return the last subentity in the database
    
    (defun LM:entlast ( / ent tmp )
        (setq ent (entlast))
        (while (setq tmp (entnext ent)) (setq ent tmp))
        ent
    )
    And then iterate over all entities added to the drawing database following the command using the entnext function supplied with the previous last entity, i.e.:
    Code:
    (setq ent (LM:entlast))
    (command "_AeccCreateFeatureLines")
    (while (< 0 (getvar 'cmdactive)) (command "\\"))
    (while (setq ent  (entnext ent)) (setq lst (cons ent lst)))
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  5. #5
    Super Member
    Using
    Civil 3D 2015
    Join Date
    Aug 2015
    Posts
    508

    Default

    Quote Originally Posted by Lee Mac View Post
    Retrieve the last entity in the drawing database using the following function prior to running the _AeccCreateFeatureLines command:
    Code:
    ;; entlast  -  Lee Mac
    ;; A wrapper for the entlast function to return the last subentity in the database
    
    (defun LM:entlast ( / ent tmp )
        (setq ent (entlast))
        (while (setq tmp (entnext ent)) (setq ent tmp))
        ent
    )
    And then iterate over all entities added to the drawing database following the command using the entnext function supplied with the previous last entity, i.e.:
    Code:
    (setq ent (LM:entlast))
    (command "_AeccCreateFeatureLines")
    (while (< 0 (getvar 'cmdactive)) (command "\\"))
    (while (setq ent  (entnext ent)) (setq lst (cons ent lst)))
    Thanks Lee! Just to double check that I understand correctly, I would want to use your entlast function with the :vlr-commandWillStart reactor, then use your second code with the :vlr-commandEnded reactor?

  6. #6
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Win 7 Pro / Win 10 Pro / Linux Mint
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2018
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,569

    Default

    If you necessarily wish to use a reactor, then yes - retrieve the last entity within the callback function for the :vlr-commandwillstart event, and process the created entities within the callback function for the :vlr-commandended event.

    Alternatively, just define a wrapper for the _AeccCreateFeatureLines command which would evaluate the command in addition to performing the operations you require.

    Lee
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  7. #7
    Super Member
    Using
    Civil 3D 2015
    Join Date
    Aug 2015
    Posts
    508

    Default

    Quote Originally Posted by Lee Mac View Post
    If you necessarily wish to use a reactor, then yes - retrieve the last entity within the callback function for the :vlr-commandwillstart event, and process the created entities within the callback function for the :vlr-commandended event.

    Alternatively, just define a wrapper for the _AeccCreateFeatureLines command which would evaluate the command in addition to performing the operations you require.

    Lee
    Lee, thank you for the help! I wanted to allow the user to be able to disable my version, which is why I was planning on going the reactor route (plus my company typically doesn't like to redefine commands). I know just redefining it would be much easier though.

  8. #8
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Win 7 Pro / Win 10 Pro / Linux Mint
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2018
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,569

    Default

    Quote Originally Posted by broncos15 View Post
    Lee, thank you for the help!
    You're welcome.

    Quote Originally Posted by broncos15 View Post
    I wanted to allow the user to be able to disable my version, which is why I was planning on going the reactor route (plus my company typically doesn't like to redefine commands). I know just redefining it would be much easier though.
    I'm not suggesting that you redefine the standard command, but rather define a custom command which the user may invoke to start the standard command whilst performing your operations.
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  9. #9
    Super Member
    Using
    Civil 3D 2015
    Join Date
    Aug 2015
    Posts
    508

    Default

    I'm not suggesting that you redefine the standard command, but rather define a custom command which the user may invoke to start the standard command whilst performing your operations.
    Oh, I misunderstood what you were initially saying. My company has a lot of other lisp routines that make use of the CreateFeatureLines command, which is why I don't think making another command would work (then my new one would either have to be placed in all the other lisp routines and .net applications, or it would only work if invoked from the command line). Overall I think your thought is a much more efficient way to code it, but unfortunately I think I will have to just make use of some reactors. Thanks again for your help, and your website has been super helpful for me as well!

  10. #10
    Super Member
    Using
    Civil 3D 2015
    Join Date
    Aug 2015
    Posts
    508

    Default

    Registered forum members do not see this ad.

    Lee, so I have been working on it for a while and I am getting hung up on turning the reactor on or off, and how to feed the variable to my already created lisp function. I have my lisp function "featurelinecrossing" already preloaded, but I figured that I should load it again just in case it didn't load correctly. My code is as follows:
    Code:
    ;;;This reactor used AfraLisp reactor example as a starting point
    (vl-load-com)
    ;;;
    (vlr-command-reactor 
     nil '((:vlr-commandWillStart . startCommand)))
    (vlr-command-reactor 
     nil '((:vlr-commandEnded . endCommand)))
    ;;;Reactor to store information when command first starts
    (defun startCommand (calling-reactor startcommandInfo / 
           thecommandstart ent)
    (setq ent (LM:entlast))
    (setq thecommandstart (nth 0 startcommandInfo))
    (princ)
    )
    ;;;Here is where the real reactor comes into play
    ;;;This reactor runs after the command has ended
    (defun endCommand (calling-reactor endcommandInfo / 
         thecommandend)
    (setq thecommandend (nth 0 endcommandInfo))
    (cond
      ((= thecommandend "_AeccCreateFeatureLines")
       (load "featurelinecrossing" "")
       (while (setq ent  (entnext ent))
         (featurelinecrossing "PI" ent "")
         (setq lst (cons ent lst)))
       )
     
    )
     (princ)
    )
    ;; entlast  -  Lee Mac
    ;; A wrapper for the entlast function to return the last subentity in the database
    (defun LM:entlast ( / ent tmp )
        (setq ent (entlast))
        (while (setq tmp (entnext ent)) (setq ent tmp))
        ent)
    ;;; Command to turn the reactor on or off
    (defun c:InsertPI ( / opt)
     (initget "On Off")
     (setq opt (getkword "\nTurn off or on? [On/Off]: "))
     (if (= opt "Off") (setq "AutoInserPI" "")
                         (setq "AutoInsertPI" opt)
     )
     (princ)
    )

Similar Threads

  1. Printing Lisp for previous plot, Window selection and Preview needed.
    By Saqib_theleo in forum AutoLISP, Visual LISP & DCL
    Replies: 12
    Last Post: 21st May 2015, 04:11 am
  2. How to create Macro Button for previous plot, Window selection and Preview.
    By Saqib_theleo in forum The CUI, Hatches, Linetypes, Scripts & Macros
    Replies: 8
    Last Post: 2nd Dec 2013, 10:41 pm
  3. Viewing how Previous Objects were Created.
    By Jon B in forum AutoCAD General
    Replies: 8
    Last Post: 14th May 2008, 05:41 pm
  4. Previous and Last selection
    By Hardney in forum AutoCAD Drawing Management & Output
    Replies: 6
    Last Post: 23rd Jan 2007, 03:30 pm
  5. Reselect previous selection?
    By James in forum AutoCAD Beginners' Area
    Replies: 7
    Last Post: 22nd Nov 2006, 03:48 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