Lisp modification

Lisp modification

BB8x
Advocate Advocate
492 Views
1 Reply
Message 1 of 2

Lisp modification

BB8x
Advocate
Advocate

Hello

 

I am using lisp to inserting arrows on the end of line. I need this one to be modified (or new one with same arrows). I would like to insert arrow on 3d poly and 2d poly but on point I click on the poly. Also it would be an issue with direction of arrow, so I think it should be an option in lisp to change direction for 180 deg

 

(defun c:as (/ a e p0 p1 p2)
  (cond	((null (tblobjname "block" "_ar"))
	 (entmake '((0 . "BLOCK")
		    (100 . "AcDbEntity")
		    (67 . 0)
		    (8 . "0")
		    (100 . "AcDbBlockReference")
		    (2 . "_ar")
		    (10 0 0 0)
		    (70 . 0)
		   )
	 )
	 (entmake '((0 . "LWPOLYLINE")
		    (100 . "AcDbEntity")
		    (67 . 0)
		    (8 . "0")
		    (100 . "AcDbPolyline")
		    (90 . 2)
		    (70 . 128)
		    (10 0 0 0)
		    (41 . 0.347296)
		    (10 -0.984807 0.0)
		    (40 . 0.347296)
		    (41 . 0.347296)
		   )
	 )
	 (entmake '((0 . "ENDBLK") (100 . "AcDbBlockEnd") (8 . "0")))
	)
  )
  (cond	((and (setq e (entsel "\Pick a line: "))
	      (= "LINE" (cdr (assoc 0 (entget (car e)))))
	      (progn (initget 6) (or (setq sc (getdist "\nEnter scale: <0.2> ")) (setq sc 0.2)))
	 )
	 (setq
	   p0 (vlax-curve-getclosestpointtoprojection (car e) (trans (cadr e) 1 (car e)) '(0. 0. 1.))
	 )
	 (setq e (entget (car e)))
	 (setq p1 (cdr (assoc 10 e)))
	 (setq p2 (cdr (assoc 11 e)))
	 (setq a (angle p1 p2))
	 (setq p1 (cond	((< (distance p1 p0) (distance p2 p0)) (list p1 (+ pi a)))
			((list p2 a))
		  )
	 )
	 (entmakex (list '(0 . "insert")
			 (cons 10 (car p1))
			 '(2 . "_ar")
			 (assoc 8 e)
			 (cons 50 (cadr p1))
			 (cons 41 sc)
			 (cons 42 sc)
			 (cons 43 sc)
		   )
	 )
	)
  )
  (princ)
)

 

0 Likes
493 Views
1 Reply
Reply (1)
Message 2 of 2

Sea-Haven
Mentor
Mentor

Maybe change some of the code, this gives a pt and an angle in radians for pick point, then yes need a flip option.

 

 

(defun alg-ang (obj pnt)
  (angle '(0. 0. 0.)
     (vlax-curve-getfirstderiv
       obj
       (vlax-curve-getparamatpoint
         obj
         pnt
       )
     )
  )
)

(setq e (entsel "\Pick a P/line: "))
(setq pt (cadr e))
(setq lobj (vlax-ename->vla-object (car e)))
(setq pt (vlax-curve-getclosestpointto lobj pt))

(setq ang (alg-ang lobj pt))

 

Not tested on 3dpoly

 

 

0 Likes