How to call a transparent command inside an autolisp routine?

  • Thread starter Thread starter bm01
  • Start date Start date
B

bm01

After drawing a pline from p1 to p2, I want to perform a pan function transparently from p2 to p1, then continue to draw a line to p3.

Does any one know how to call the 'p transparent command inside the following rountine? :

(defun c:asd( / p1 p2)
(setq p1 (getpoint "\nStart point: "))
(while (not p2)
(setq p2 (getpoint p1 "\nSecond point: "))
(if p2
(progn
(command "_pline" p1 p2 "'p" p2 p1 "" "") <== How to perform a pan function here?
(setq p1 p2 p2 nil)
)
)
)
)

Rosa Hsiao
 
;you can do something like this
;pan can be used like in the AutoCAD command pline
(defun c:asd( / p1)
(while (setq p1 (getpoint "\nStart point <RETURN> for stop: "))
(command "_pline")
(while (> (getvar "cmdactive") 0)(command "_Non" p1 "_Non" pause))
)
)
 
You seem to be intending to end the pline command after each segment, anyway
(if that's what your two pairs of double-quotes are about), in which case
you can do the pan NON-transparently (but with the hyphen in front so it
does it without on-screen picking):
.....
(progn
(command "_pline" p1 p2 "")
(command "-pan" p2 p1)
(setq p1 p2 p2 nil)
)
.....

I can imagine circumstances, if you start off close enough to an edge of the
screen area, under which you might not have room to draw the next segment in
the direction you want to go. Consider Zoom Center instead:
.....
(progn
(command "_pline" p1 p2 "")
(command "-zoom" "c" p2 "")
(setq p1 p2 p2 nil)
)
.....
which will put your latest point in the center of the screen.

(By the way, if you're ending the pline command for each segment, you may as
well use ordinary lines.)

If you don't want to end the pline with each segment, I tried typing in a
transparent hyphen-pan in mid-command, and hope the same would work inside a
(command) function. If so, this might do it, unless there's some
prohibition against starting a (command) function when in mid-command (i.e.
not at the Command: prompt):

.....
(if p2
(progn
(command "_pline" p1 p2 "'-pan" p2 p1)
(setq p1 p2 p2 nil)
)
.....

Typing '-pan works, but -'pan does not.

Kent Cooper, AIA


"bm01" wrote...
After drawing a pline from p1 to p2, I want to perform a pan function
transparently from p2 to p1, then continue to draw a line to p3.
Does any one know how to call the 'p transparent command inside the
following rountine? :

(defun c:asd( / p1 p2)
(setq p1 (getpoint "\nStart point: "))
(while (not p2)
(setq p2 (getpoint p1 "\nSecond point: "))
(if p2
(progn
(command "_pline" p1 p2 "'p" p2 p1 "" "") <== How to perform a pan
function here?
(setq p1 p2 p2 nil)
)
)
)
)
 
Oops....

Of course you can't do it quite this way, because after you pan, you just
want to give it another point, not call up the pline command again, since
you should already be in it. You'd have to start pline earlier, then have
this part of it simply take a new p2 and pan (or zoom c).

(By the way, in your original code, you probably want to prompt for the
"Next point: " rather than the "Second point: ".)

Kent Cooper, AIA


...
 
Seems it'd be simpler to use the Line command for display purposes, then
either store each line in a selection set (ssadd), or save a list of points
selected that would create the pline once the drafter is done executing the
command.

You don't actually have to be drawing an actual pline to have the final
product be a pline, just creatively program for display and final result. :)
 
Would something like this rearrangement work? (not tested)

(defun c:asd( / p1 p2)
(setq p1 (getpoint "\nStart point: "))
(command "_pline" p1)
(while (not p2)
(setq p2 (getpoint p1 "\nNext point: "))
(if p2
(progn
(command "'-pan" p2 p1)
(setq p1 p2 p2 nil)
)
)
)
)

Since, as I recall, (setq) returns the last value that it set, this might
feed in a "nil" to the Pline command where it's looking for a next point.
Whether that's going to end the command, I'm not sure -- I'll let you try it
out. If it does, this might get around it:

(defun c:asd( / p1 p2 temppt)
(setq p1 (getpoint "\nStart point: "))
(command "_pline" p1)
(while (not p2)
(setq p2 (getpoint p1 "\nNext point: "))
(if p2
(progn
(command "'-pan" p2 p1)
(setq p1 p2 p2 nil temppt p1)
(command "u")
)
)
)
)

That lets the (setq) line return an actual point (which could be anything --
0,0, or whatever, but I put in a point that already exists in the routine),
so maybe Pline will still be running. Then it undoes that last temporary
pline segment and (I hope) leaves the command awaiting a next point again.

I have no time right now to try it all out myself....

Kent Cooper, AIA


...
 
I don't think you can much of anything while the pline is active - you are
right, setq is returning a value that will muddy the command.

Here is a rendition that works, but you don't have the Close option you do
with pline. Just have to add in a method for accepting a 'c' and closing
the polyline if that's the desired result.

(defun c:asd( / p1 p2 pset lset)
(setq lset (ssadd))
(setq p1 (getpoint "\nStart point: "))
(setq pset (list p1))
(setq p2 (getpoint p1 "\nNext point: "))
(setq pset (cons p2 pset))
(command "_line" p1 p2 "")
(ssadd (entlast) lset)
(command "_pan" p2 p1)
(while (/= p2 NIL)
(setq p1 p2)
(setq p2 (getpoint p1 "\nNext Point: "))
(if p2 (setq pset (cons p2 pset)))
(command "_line" p1 p2 "")
(ssadd (entlast) lset)
(command "_pan" p2 p1)
);while
(command ".erase" lset "")
(command ".pline")
(foreach pt pset
(command pt)
)
(command "")
);defun
 
Jason,

I have tested your routine and it really works for me,except that I don't have the Close/Undo option as I usually do with pline + 'pan transparent command. But it does solve most of of my problem. Thanks for all your help.

Rosa


"Jason Wilder" <[email protected]> ¼¶¼g©ó¶l¥ó I don't think you can much of anything while the pline is active - you are
right, setq is returning a value that will muddy the command.

Here is a rendition that works, but you don't have the Close option you do
with pline. Just have to add in a method for accepting a 'c' and closing
the polyline if that's the desired result.

(defun c:asd( / p1 p2 pset lset)
(setq lset (ssadd))
(setq p1 (getpoint "\nStart point: "))
(setq pset (list p1))
(setq p2 (getpoint p1 "\nNext point: "))
(setq pset (cons p2 pset))
(command "_line" p1 p2 "")
(ssadd (entlast) lset)
(command "_pan" p2 p1)
(while (/= p2 NIL)
(setq p1 p2)
(setq p2 (getpoint p1 "\nNext Point: "))
(if p2 (setq pset (cons p2 pset)))
(command "_line" p1 p2 "")
(ssadd (entlast) lset)
(command "_pan" p2 p1)
);while
(command ".erase" lset "")
(command ".pline")
(foreach pt pset
(command pt)
)
(command "")
);defun
 
;; Modified for Close of Pline..
(defun c:asd( / p1 p2 pset lset Chk)
(setq lset (ssadd))
(setq p1 (getpoint "\nStart point: "))
(setq pset (list p1))
(setq p2 (getpoint p1 "\nNext point: "))
(setq pset (cons p2 pset))
(command "_line" p1 p2 "")
(ssadd (entlast) lset)
(command "_pan" p2 p1)
(while (/= p2 NIL)
(setq p1 p2)
(setq p2 (getpoint p1 "\nNext Point: "))
(if p2 (setq pset (cons p2 pset)))
(command "_line" p1 p2 "")
(ssadd (entlast) lset)
(command "_pan" p2 p1)
);while
(command ".erase" lset "")
(command ".pline")
(foreach pt pset
(command pt)
)
(setq Chk (getstring "\nClose Pline ? [Y/N] : <Y>"))
(if (or (= Chk "")(= Chk "Y")(= Chk "y"))
(command "_C")
(command "")
); end if
);defun

Bob
 
Back
Top