Auto pan along selected polyline (with user defined speed in pan flow)

Auto pan along selected polyline (with user defined speed in pan flow)

Anonymous
Not applicable
1,165 Views
3 Replies
Message 1 of 4

Auto pan along selected polyline (with user defined speed in pan flow)

Anonymous
Not applicable

Dear Experts,

 

I need a lisp programme that should pan the autocad screen along the selected polyline with same zoom scale for quality checking of the 100KM of road plan. The lisp code also should ask the user for delay in pan for some time and then it should continue further for drawing quality check along the selected polyline.

 

Thank you in advance experts.

 

0 Likes
Accepted solutions (1)
1,166 Views
3 Replies
Replies (3)
Message 2 of 4

ВeekeeCZ
Consultant
Consultant
Accepted solution

Ok, here is the code. But for some reason, I cannot make the DELAY to work (acad 2019), so I made it to be stepped manually. In my opinion, it's even better this way, but anyone is welcome to fix that if that is required.

 

The idea is that you can hit ESC anytime and then continue from the spot where you left.

Or it can be reset by the Reset command.

 

(defun c:PanAlongCurveReset ()
  (setq *pac-ent* nil
	*pac-dst* nil
	*pac-dlt* nil
	*pac-dly* nil)
  (princ)
  )

(defun c:PanAlongCurve ( / *error* len done)
  
  (defun *error* (errmsg)
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break,end"))
      (princ (strcat "\nError: " errmsg)))
    (setvar 'cmdecho 1)
    (princ))
  
  
  (setvar 'cmdecho 0)
  
  (if (or *pac-ent*
	  (and (setq *pac-ent* (car (entsel "\nSelect polyline: ")))
	       (or (wcmatch (cdr (assoc 0 (entget *pac-ent*))) "LINE,*POLYLINE")
		   (setq *pac-ent* nil)
		   (prompt "\nError: Wrong selection"))
	       (setq *pac-dlt* (getdist "\nSet step distance: "))
	       ;(setq *pac-dly* (getint "\nSet delay in ms: "))
	       (setq *pac-dst* 0)
	       ))
    (progn
      (setq len (vlax-curve-getdistatparam *pac-ent* (vlax-curve-getendparam *pac-ent*)))
      (while (not done)
	(command "_.PAN" (trans (vlax-curve-getpointatdist *pac-ent* *pac-dst*) 0 1) (getvar 'VIEWCTR))
	(princ (strcat "\nCurrent stationing: " (rtos *pac-dst* 2 0)))
	(getkword "\nHit any key to continue...")
	;(command "_DELAY" *pac-dly*)
	(if (equal *pac-dst* len 1e-6)
	  (progn
	    (c:PanAlongCurveReset)
	    (setq done T))
	  (setq *pac-dst* (min (+ *pac-dst* *pac-dlt*)
			       len))))))
  (*error* "end")
  )

 


Message 3 of 4

Anonymous
Not applicable

Thank you So much..

0 Likes
Message 4 of 4

Anonymous
Not applicable

Great stuff, nice coding!

Thanks.

0 Likes