Jump to content

Recommended Posts

Posted

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)

image.thumb.png.732335ac33d6bc6665a51f74dd974e64.png

Posted

Do you want the  two angles for every segment or just the angle in the direction the polyline is constructed?

Posted (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 by marko_ribar
Posted
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

Posted
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

Posted
14 minutes ago, Anushka said:

 

the two angles for each segment

 

And the angular units and accuracy?

  • Like 1
Posted
36 minutes ago, dlanorh said:

 

And the angular units and accuracy?

 

angular units: Degrees
Accuracy: 4 decimal places

Posted

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.

  • Thanks 1
Posted
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 !!!

Posted

Just a suggestion work in radians much easier with Autocad lisp.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...