- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
If we can show any 2 points of a line or polyline, Can Lisp show the distance by pointing?
Solved! Go to Solution.
If we can show any 2 points of a line or polyline, Can Lisp show the distance by pointing?
Solved! Go to Solution.
Thank you for your reply. On this we have an issue, it's showing point to point distance just a measurement. How can we update the distance reference to root of the pline.
For example, the above lisp is giving hypotenuse of a triangle, I wish to get its sum of length and width the triangle.
hope you learn something from it at least
(vl-load-com)
(defun c:StationingFrom ( / e b s p d ) (if (and (setq e (car (entsel "Select polyline: "))) (setq b (getpoint "\nStarting point: ")) (setq s (vlax-curve-getdistatpoint e (vlax-curve-getclosestpointto e (trans b 1 0)))) ) (while (setq p (getpoint b "\rNext point: ")) (setq d (- (vlax-curve-getdistatpoint e (vlax-curve-getclosestpointto e (trans p 1 0))) s)) (vl-cmdf "_.MLEADER" "_none" p "_none" (polar p (/ pi 4) 1.5) (strcat (rtos d 2 3) "mm")))) (princ) )
Thank you very much. It is amazing.
Yes, all of your codes are like reference books for me. Special thanks for that. 😃
How can we disable the routine, if the "Next point" selection is not on the polyline?
@smallƑish as you show at image , it are true linear measures
But now you ask for
@smallƑish wrote:Thank you for your reply. On this we have an issue, it's showing point to point distance just a measurement. How can we update the distance reference to root of the pline.
For example, the above lisp is giving hypotenuse of a triangle, I wish to get its sum of length and width the triangle.
Please upload your acad.dwg, with such measures or dimension.
With little modifiacation of code BeekeeCZ.
This?
(defun c:StationingFrom ( / e b s p d )
(if (and (setq e (car (entsel "Select polyline: ")))
(setq b (getpoint "\nStarting point: "))
(setq s (vlax-curve-getdistatpoint e (vlax-curve-getclosestpointto e (trans b 1 0))))
)
(while (setq p (getpoint b "\rNext point: "))
(cond
((osnap p "_near")
(setq d (- (vlax-curve-getdistatpoint e (vlax-curve-getclosestpointto e (trans p 1 0))) s))
(vl-cmdf "_.MLEADER"
"_none" (polar p (* pi 1.25) 1.5)
"_none" p
(rtos d 2 3))))))
(princ)
)
Just a suggestion also a slight variation is when entsel, you pick near an end this implies which end is the start, you reverse the pline if required, then pick next point required.
An example.
(defun c:wow ()
(setq ent (entsel "\nPick pline near start end "))
(setq pt3 (cadr ent))
(setq obj (vlax-ename->vla-object (car ent)))
(setq start (vlax-curve-getstartPoint obj))
(setq end (vlax-curve-getEndPoint obj))
(setq d1 (distance pt3 end))
(setq d2 (distance pt3 start))
(if (< d1 d2)
(command "pedit" (car ent) "R" "")
)
)
and another one
;***************************************************************************************************************************************
(defun draw_mleader (root_point shelf_point text)
(vl-cmdf "_.mleader" "_non" root_point shelf_point text)
)
;***************************************************************************************************************************************
(defun c:measure_mleader ()
(if (setq start_point (osnap (getpoint "Set start point to measure from: ") "_near,_int,_endp,_mid"))
(progn
(setq target_curve (car (nentselp start_point))
start_point_param (vlax-curve-getparamatpoint target_curve (trans start_point 1 0))
first_deriv (vlax-curve-getfirstderiv target_curve start_point_param)
ortho_angle (+ (* 0.5 pi) (angle '(0 0) first_deriv))
shelf_point (polar start_point ortho_angle 50)
)
(draw_mleader start_point shelf_point "Start point")
(vla-put-color (vlax-ename->vla-object (entlast)) 1)
(while (setq next_point (getpoint "\nSet point to measure to (RMB to stop command): "))
(if (setq next_point (osnap next_point "_near,_int,_endp,_mid"))
(progn
(setq next_point_param (vlax-curve-getparamatpoint target_curve (trans next_point 1 0))
first_deriv (vlax-curve-getfirstderiv target_curve next_point_param)
ortho_angle (+ (* 0.5 pi) (angle '(0 0) first_deriv))
shelf_point (polar next_point ortho_angle 50)
)
(draw_mleader next_point shelf_point (strcat (rtos (abs (- (vlax-curve-getdistatpoint target_curve (trans start_point 1 0))
(vlax-curve-getdistatpoint target_curve (trans next_point 1 0))
)
) 2 2
) "mm"
)
)
)
t
)
)
)
)
)
;***************************************************************************************************************************************