ADD PERPENDICULAR LENGTH IN CHAINAGE LISP

ADD PERPENDICULAR LENGTH IN CHAINAGE LISP

Mohammedshebintk
Explorer Explorer
564 Views
3 Replies
Message 1 of 4

ADD PERPENDICULAR LENGTH IN CHAINAGE LISP

Mohammedshebintk
Explorer
Explorer

Could someone please help me to add  perpendicular length in the same leader line?

 

 

(defun c:Chin (/ s p c a d tp sch)
(setvar "cmdecho" 0)
(setq sch (getstring "\nSpecify start chainage : <0>")) ;"0" is set as the default value
(if (= sch "")(setq sch "0"))
(if
(and (setq s (car (entsel "\nPick a polyline :")))
(or (= (cdr (assoc 0 (entget s))) "LWPOLYLINE")
(alert "Invalid object! Please pick a polyline only.")
)
)
(while
(and
(setq
p (getpoint "\nSpecify point perpendicular to polyline :")
)
(setq c (vlax-curve-getclosestpointto s p))
(setq a (angle p c))
(not (grdraw p c 1 -1))
;; rubber line in red colour.
(setq d (angle '(0. 0. 0.)
(vlax-curve-getfirstderiv
s
(vlax-curve-getparamatpoint s c)
)
)
)
(or
(or (equal (rem (+ d (* pi 0.5)) (+ pi pi)) a 1e-4)
(equal (rem (+ d (* pi 1.5)) (+ pi pi)) a 1e-4)
)
(alert
"Picked point is not a perpendicular to picked polyline. <!>"
)
)
(setq tp (getpoint "\nSpecify Point for Text : "))
)
(command "_.QLEADER" p tp "" 1
(strcat "CH=" sch "+" (rtos (vlax-curve-getdistatpoint s c) 2 3))
(strcat "E=" (rtos (car p) 2 3))
(strcat "N=" (rtos (cadr p) 2 3))
""
)
(vlax-put-property (vlax-ename->vla-object (entlast)) 'height 0.6);;; Text Height 0.6
)
)
(setvar "cmdecho" 1)
(princ)
)
(vl-load-com)

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

pbejse
Mentor
Mentor
Accepted solution

@Mohammedshebintk wrote:

Could someone please help me to add  perpendicular length in the same leader line?

 

(defun c:Chin (/ s p c a d tp sch len)
  (setvar "cmdecho" 0)
  (setq sch (getstring "\nSpecify start chainage : <0>"))
					;"0" is set as the default value
  (if (= sch "")
    (setq sch "0")
  )
  (if
    (and (setq s (car (entsel "\nPick a polyline :")))
	 (or (= (cdr (assoc 0 (entget s))) "LWPOLYLINE")
	     (alert "Invalid object! Please pick a polyline only.")
	 )
    )
     (while
       (and
	 (setq
	   p (getpoint "\nSpecify point perpendicular to polyline :")
	 )
	 (setq c (vlax-curve-getclosestpointto s p))
	 (setq a (angle p c))
	 (not (grdraw p c 1 -1))
	 ;; rubber line in red colour.
	 (setq d (angle	'(0. 0. 0.)
			(vlax-curve-getfirstderiv
			  s
			  (vlax-curve-getparamatpoint s c)
			)
		 )
	 )
	 (setq len (distance c p))
	 (or
	   (or (equal (rem (+ d (* pi 0.5)) (+ pi pi)) a 1e-4)
	       (equal (rem (+ d (* pi 1.5)) (+ pi pi)) a 1e-4)
	   )
	   (alert
	     "Picked point is not a perpendicular to picked polyline. <!>"
	   )
	 )
	 (setq tp (getpoint "\nSpecify Point for Text : "))
       )
	(command "_.QLEADER"
		 p
		 tp
		 ""
		 1
		 (strcat "CH="
			 sch
			 "+"
			 (rtos (vlax-curve-getdistatpoint s c) 2 3)
		 )
		 (strcat "E=" (rtos (car p) 2 3))
		 (strcat "N=" (rtos (cadr p) 2 3))
		 (strcat "Length= " (rtos len 2 3))
		 ""
	)
	(vlax-put-property
	  (vlax-ename->vla-object (entlast))
	  'height
	  0.6
	)
;;; Text Height 0.6
     )
  )
  (setvar "cmdecho" 1)
  (princ)
)
(vl-load-com)

HTH

0 Likes
Message 3 of 4

Mohammedshebintk
Explorer
Explorer

Thank you very much, it has been a great help

0 Likes
Message 4 of 4

pbejse
Mentor
Mentor

@Mohammedshebintk wrote:

Thank you very much, it has been a great help


 

Anytime @Mohammedshebintk 

Glad I could help

 

 

0 Likes