TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: qjchen on July 14, 2007, 10:04:47 AM

Title: How to use transparent command "'zoom" or "'pan" in command "Pline"
Post by: qjchen on July 14, 2007, 10:04:47 AM
How to use transparent command "'zoom" in "Pline"

I want to do this function, when I draw a pline upon some points, it automatically pan .

I search this in google group, and get this two.
http://groups.google.com/group/autodesk.autocad.customization/browse_thread/thread/447fa68e623abf63/06cac073465d34ac?lnk=gst&q=%27zoom+pline&rnum=3#06cac073465d34ac
http://groups.google.com/group/autodesk.autocad.customization/browse_thread/thread/2c7be821154011fb/afbf2a342aa554d9?lnk=gst&q=%27zoom+pline&rnum=8#afbf2a342aa554d9

This one
Code: [Select]
;;;http://groups.google.com/group/autodesk.autocad.customization/browse_thread/thread/2c7be821154011fb/cb9427d8ad609042?lnk=gst&q=pline+%27zoom&rnum=17#cb9427d8ad609042
;;;  Jason Wilder     

(defun c:pll( / 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 "")
)

The effect is what I need.

but it can't draw arc or set width of pline.

How can I use 'zoom or 'pan in "pline" or "spline" command directly.

That means, not just get point list and then finally use foreach to construct the pline.

Thank you very much.
Title: Re: How to use transparent command "'zoom" or "'pan" in command "Pline"
Post by: mjfarrell on July 14, 2007, 11:09:47 AM
I don't know that one needs to use any 'code' to perform transparent pans or zooms during the PLINE command. In normal use on simply depresses the Middle Mouse button to Pan, or rolls the wheal In/Out to zoom. Optionally one can tip 'p, or 'z during the PLINE command to call the transparent pan/zoom function one needs.
Title: Re: How to use transparent command "'zoom" or "'pan" in command "Pline"
Post by: rainier on July 15, 2007, 07:24:37 PM
yuanqiu, try this... 'pan or 'zoom

hope it helps..
Title: Re: How to use transparent command "'zoom" or "'pan" in command "Pline"
Post by: T.Willey on July 16, 2007, 11:42:19 AM
Can you just use the pline command within your code then?
Code: [Select]
(command "_.pline")
(while (> (getvar "cmdactive") 0)
 (command pause)
)
Make sure the 'cmdecho' variable is set to 1 so you can see the prompts for the pline command.
Title: Re: How to use transparent command "'zoom" or "'pan" in command "Pline"
Post by: Krushert on July 16, 2007, 12:26:37 PM
Now I am going to open my mouth and mostly likely a bunch of noise is going to come out.

Is there not a function that will center the screen editor about a user selected point. 
Could the screen follow the points that are entered by the user for the pline?

Title: Re: How to use transparent command "'zoom" or "'pan" in command "Pline"
Post by: CAB on July 16, 2007, 01:26:10 PM
Code: [Select]
(defun c:pll (/ p1 p2 plst)
  (defun grlst (lst / glst)
    (mapcar '(lambda (x)
               (setq glst
                      (cond
                        ((null glst) (list x))
                        ((> (length glst) 1) (append glst (list (last glst) x)))
                        (t (list (car glst) x))
                      )
               )
             )
            lst
    )
    glst
  )
  (setq p1 (getpoint "\nStart point: "))
  (command "_zoom" "_C" "_non" p1 "")
  (while (setq p2 (getpoint p1 "\nNext point: "))
    (command "-pan" "_non" p2 "_non" p1)
    (setq plst (if plst (cons p2 plst) (list p2 p1))
          p1   p2
    )
    (grvecs (cons 256 (grlst plst)))
  )
  (command ".pline")
  (foreach pt plst (command "_non" pt))
  (command "")
  (redraw)
  (princ)
)

<edit: added zoom>
Title: Re: How to use transparent command "'zoom" or "'pan" in command "Pline"
Post by: qjchen on July 17, 2007, 08:58:34 AM
Thank you all:)

Sometimes when I draw line along many points, I have to pan again and again, so I want to write this code that it automatic pan each time I draw a point.

To T.Willey
Thank you

CAB has ever write a code for me about a pline arrow, Yours two code is very similar.
Code: [Select]
(defun c:test ()
  (vl-load-com)        ;  no error checking
  (prompt "\nDraw your pline.")
  (command "PLINE")
  (while (> (getvar "CMDACTIVE") 0)
    (command pause)
  )
  (setq ent (entlast))
  (setq ArrowLength 5
ArrowWidth 2
  )
  (setq ArrowBasePt (vlax-curve-getPointAtDist ent ArrowLength))
  (command "_pedit" ent "_e" "_i" "_non" ArrowBasePt "_x" "_e" "_w" "0"
   ArrowWidth "_x" "" ""
  )
  (princ)
)

so I want to add just code inside it
Code: [Select]
(while (> (getvar "CMDACTIVE") 0)
    (command pause)
    (command "'pan" p1 p2)
  )

but sure the code cant run.

To CAB
Thank you, the code run well. but nows code cant draw arc pline or set width because it use "foreach" to construct nor the normal pline command, can the transparent command be run in "pline" command?
Title: Re: How to use transparent command "'zoom" or "'pan" in command "Pline"
Post by: CAB on July 17, 2007, 09:10:02 AM
It can be done, but I don't have the time or desire at the moment.
I think mjfarrell said it best.
I don't know that one needs to use any 'code' to perform transparent pans or zooms during the PLINE command. In normal use on simply depresses the Middle Mouse button to Pan, or rolls the wheal In/Out to zoom. Optionally one can tip 'p, or 'z during the PLINE command to call the transparent pan/zoom function one needs.
Title: Re: How to use transparent command "'zoom" or "'pan" in command "Pline"
Post by: Crank on July 20, 2007, 09:54:41 AM

so I want to add just code inside it
Code: [Select]
(while (> (getvar "CMDACTIVE") 0)
    (command pause)
    (command "'pan" p1 p2)
  )

but sure the code cant run.

Haven't tryed this, but can't you use 'zoom center?
Code: [Select]
(while (> (getvar "CMDACTIVE") 0)
    (command pause)
    (command "'zoom" "c" (getvar "LASTPOINT") "")
  )
Title: Re: How to use transparent command "'zoom" or "'pan" in command "Pline"
Post by: qjchen on July 22, 2007, 08:16:23 AM
Thank you, Crank, but it seems not work:)

just like this, is not working

Code: [Select]
(defun c:test ()
  (vl-load-com)        ;  no error checking
  (prompt "\nDraw your pline.")
  (command "PLINE")
  (while (> (getvar "CMDACTIVE") 0)
    (command pause)
    (command "'zoom" "c" (getvar "LASTPOINT") "")
  )
  (setq ent (entlast))
  (setq ArrowLength 5
ArrowWidth 2
  )
  (setq ArrowBasePt (vlax-curve-getPointAtDist ent ArrowLength))
  (command "_pedit" ent "_e" "_i" "_non" ArrowBasePt "_x" "_e" "_w" "0"
   ArrowWidth "_x" "" ""
  )
  (princ)
)