Anushka Posted April 26, 2020 Posted April 26, 2020 Hello, does anyone have a sub-function that returns me a list with the angle in relation to X and the distance between the verticies of a polyline ?? (7 27.7263) (187 27.7263 65 21.4872) (245 21.4872) Quote
dlanorh Posted April 26, 2020 Posted April 26, 2020 Do you want the two angles for every segment or just the angle in the direction the polyline is constructed? Quote
marko_ribar Posted April 26, 2020 Posted April 26, 2020 (edited) Out of curiosity, why do you need this info? What do you want to achieve - shouldn't be just 1 angle enough to determine complete polygonal polyline orientation - I assume you already have routine for dimension lengths and angles (inside) of polygonal polyline... Just look and search www... I posted one at augi.com long time ago... Edited April 26, 2020 by marko_ribar Quote
Anushka Posted April 26, 2020 Author Posted April 26, 2020 23 minutes ago, dlanorh said: Do you want the two angles for every segment or just the angle in the direction the polyline is constructed? the two angles for each segment Quote
Anushka Posted April 26, 2020 Author Posted April 26, 2020 15 minutes ago, marko_ribar said: Out of curiosity, why do you need this info? What do you want to achieve - shouldn't be just 1 angle enough to determine complete polygonal polyline orientation - I assume you already have routine for dimension lengths and angles (inside) of polygonal polyline... Just look and search www... I posted one at augi.com long time ago... I need these two values to do some calculations in my main program Quote
dlanorh Posted April 26, 2020 Posted April 26, 2020 14 minutes ago, Anushka said: the two angles for each segment And the angular units and accuracy? 1 Quote
Anushka Posted April 26, 2020 Author Posted April 26, 2020 36 minutes ago, dlanorh said: And the angular units and accuracy? angular units: Degrees Accuracy: 4 decimal places Quote
dlanorh Posted April 27, 2020 Posted April 27, 2020 Try this, tested and working but may need tweaking as angles are in decimal degrees. (defun rh:plad (ent / r2d ep sp sd sa ld la lst) (defun r2d (r) (if (>= (* 180.0 (/ r pi)) 360) (- (* 180.0 (/ r pi)) 360) (* 180.0 (/ r pi)))) (setq sp 0 ep (vlax-curve-getendparam ent)) (while (<= sp ep) (if (< sp ep) (setq sd (- (vlax-curve-getdistatparam ent (1+ sp)) (vlax-curve-getdistatparam ent sp)) sa (angle '(0.0 0.0 0.0) (vlax-curve-getfirstderiv ent sp)) );end_setq );end_if (cond ( (zerop sp) (setq lst (cons (list (r2d sa) sd) lst))) ( (= ep sp) (setq lst (cons (list (r2d (+ la pi)) ld) lst))) (t (setq lst (cons (list (r2d (+ la pi)) ld (r2d sa) sd) lst))) );end_cond (setq sp (1+ sp) ld sd la sa) );end_while (reverse lst) );end_defun Requires an lwpolyline entity. 1 Quote
Anushka Posted April 27, 2020 Author Posted April 27, 2020 1 hour ago, dlanorh said: Try this, tested and working but may need tweaking as angles are in decimal degrees. (defun rh:plad (ent / r2d ep sp sd sa ld la lst) (defun r2d (r) (if (>= (* 180.0 (/ r pi)) 360) (- (* 180.0 (/ r pi)) 360) (* 180.0 (/ r pi)))) (setq sp 0 ep (vlax-curve-getendparam ent)) (while (<= sp ep) (if (< sp ep) (setq sd (- (vlax-curve-getdistatparam ent (1+ sp)) (vlax-curve-getdistatparam ent sp)) sa (angle '(0.0 0.0 0.0) (vlax-curve-getfirstderiv ent sp)) );end_setq );end_if (cond ( (zerop sp) (setq lst (cons (list (r2d sa) sd) lst))) ( (= ep sp) (setq lst (cons (list (r2d (+ la pi)) ld) lst))) (t (setq lst (cons (list (r2d (+ la pi)) ld (r2d sa) sd) lst))) );end_cond (setq sp (1+ sp) ld sd la sa) );end_while (reverse lst) );end_defun Requires an lwpolyline entity. Thank you so much it works !!! Quote
BIGAL Posted April 28, 2020 Posted April 28, 2020 Just a suggestion work in radians much easier with Autocad lisp. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.