Solved! Go to Solution.
Solved by alanjt_. Go to Solution.
(defun c:Test (/ *error* cmd ent obj) (defun *error* (msg) (and cmd (setvar 'CMDECHO cmd)) (and *AcadDoc* (vla-endundomark *AcadDoc*)) (if (and msg (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*QUIT*,"))) (princ (strcat "\nError: " msg)) ) ) (vla-startundomark (cond (*AcadDoc*) ((setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object)))) ) ) (setq ent (entlast) cmd (getvar 'CMDECHO) ) (setvar 'CMDECHO 0) (princ "\nSpecify start point: ") (command "_.pline") (setvar 'CMDECHO 1) (while (eq (logand 1 (getvar 'CMDACTIVE)) 1) (command PAUSE)) (if (not (equal ent (setq ent (entlast)))) (progn (setq obj (vlax-ename->vla-object ent)) (foreach off '(1. -1.) (vlax-invoke obj 'Offset off)) (vla-delete obj) ) ) (*error* nil) (princ) )
@dwk1204 wrote:.... Once the pline is drawn I would like the lisp routine to select the pline (last ?) instead of the user doing so. I would then like to offset the line 1 (foot) and then erase the original line drawn, so the user does not have to.....
In simplest terms, it could be as little as this:
@alanjt_ wrote:.... (setvar 'CMDECHO 0) (princ "\nSpecify start point: ") (command "_.pline") (setvar 'CMDECHO 1) ....
I'm just a little curious about the reason for turning off command echoing, spelling out a prompt to start the Polyline, and turning command echoing back on to finish it. You could leave it on, and the Polyline command will provide its own starting prompt. Then you wouldn't need to reset it, and that aspect of the error handler could be omitted.
I do it to remove the display of "_.pline" on the command line. Plus, one shouldn't assume CMDECHO will be set to 1. I've worked at a few firms that set it ot 0 in their startup.
Thank you both for the help...
I do have a follow up question. The lisp routine allows the user to pick as many points as needed to create the pline, I was wondering if that is also possible while using the cui?
I made the folllowing command ^C^C_layer;s;c-sswr-pipe-x;;-linetype;s;san12'';;_pline;
after the pline is created I would like to set the linetype back to bylayer. I know the \ is a single pause for user input, but not sure if mulitple user input is possible. I can accomplish this easily with layers or with another lisp routine,but I am just trying to broaden my knowledge in the cui.
Thanks again for all the help...
Short answer is no. However the above routine could be convereted to a subfunction and you call it accordingly from the CUI, if you wanted.
(defun _pipeOnLayer (layer linetype / *error* cmd ent obj) (defun *error* (msg) (and cmd (setvar 'CMDECHO cmd)) (and *AcadDoc* (vla-endundomark *AcadDoc*)) (if (and msg (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*QUIT*,"))) (princ (strcat "\nError: " msg)) ) ) (vla-startundomark (cond (*AcadDoc*) ((setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object)))) ) ) (setq ent (entlast) cmd (getvar 'CMDECHO) ) (setvar 'CMDECHO 0) (princ "\nSpecify start point: ") (command "_.pline") (setvar 'CMDECHO 1) (while (eq (logand 1 (getvar 'CMDACTIVE)) 1) (command PAUSE)) (if (not (equal ent (setq ent (entlast)))) (progn (setq obj (vlax-ename->vla-object ent)) (and layer (vl-catch-all-apply 'vla-put-layer (list obj layer))) (and linetype (vl-catch-all-apply 'vla-put-linetype (list obj linetype))) (foreach off '(1. -1.) (vlax-invoke obj 'Offset off)) (vla-delete obj) ) ) (*error* nil) (princ) ) (_pipeOnLayer "C-SSWR-PIPE-X" "SAN12")