Jump to content

Create selection set for previous objects


broncos15

Recommended Posts

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.php?81175-select-result-lisp-modification#5 to do that since 2008. It's loaded in my acaddoc.lsp as it must be preloaded.

Link to comment
Share on other sites

Retrieve the last entity in the drawing database using the following function prior to running the _AeccCreateFeatureLines command:

;; 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.:

(setq ent (LM:entlast))
(command "_AeccCreateFeatureLines")
(while (< 0 (getvar 'cmdactive)) (command "\\"))
(while (setq ent  (entnext ent)) (setq lst (cons ent lst)))

Link to comment
Share on other sites

Retrieve the last entity in the drawing database using the following function prior to running the _AeccCreateFeatureLines command:

;; 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.:

(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?
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.
Link to comment
Share on other sites

Lee, thank you for the help!

 

You're welcome.

 

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.

Link to comment
Share on other sites

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!
Link to comment
Share on other sites

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:

;;;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)
)

Link to comment
Share on other sites

Lee, no it doesn't (I know that reactors can't make use of commands). The link to the lisp is here:http://www.cadtutor.net/forum/showthread.php?94534-Automation-Error-No-Description-provided

You along with Hippe013 were able to help me get it working. It primarily just makes use of vlax functions.

Link to comment
Share on other sites

Lee, no it doesn't (I know that reactors can't make use of commands). The link to the lisp is here:http://www.cadtutor.net/forum/showthread.php?94534-Automation-Error-No-Description-provided

You along with Hippe013 were able to help me get it working. It primarily just makes use of vlax functions.

 

Thanks - I assume that you have rewritten the c:FeatureLineCrossing function found in that thread to remove the user input and accept three arguments?

Link to comment
Share on other sites

Thanks - I assume that you have rewritten the c:FeatureLineCrossing function found in that thread to remove the user input and accept three arguments?
Lee, you will have to pardon my ignorance, but why can't I just give the information to the lisp routine where the user would typically, like how I would with a normal command?
Link to comment
Share on other sites

Lee, you will have to pardon my ignorance, but why can't I just give the information to the lisp routine where the user would typically, like how I would with a normal command?

 

AutoLISP functions do not operate in that way - evaluating the function c:featurelinecrossing is no different to evaluating any other AutoLISP function. Since AutoLISP runs on the single GUI processor thread and does not allow multiple threads, operations must be performed in sequence; therefore, when the c:featurelinecrossing function is evaluated, the calling function must wait until the evaluation of the c:featurelinecrossing function has completed before continuing evaluation.

Link to comment
Share on other sites

AutoLISP functions do not operate in that way - evaluating the function c:featurelinecrossing is no different to evaluating any other AutoLISP function. Since AutoLISP runs on the single GUI processor thread and does not allow multiple threads, operations must be performed in sequence; therefore, when the c:featurelinecrossing function is evaluated, the calling function must wait until the evaluation of the c:featurelinecrossing function has completed before continuing evaluation.
Lee, thank you for the information, I didn't know that. I will create another featurelinecrossing lisp routine that doesn't require user input. Thanks again for the help!
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...