Jump to content

Recommended Posts

Posted

Hello

Hello i have simple question.

How to calculate values shown in the attachment (polyline) using LISP?

Poly.jpg

Posted

You mean for second example :

 

100;90;300;45;424;-45;300;-90;100

Posted

A quick example:

(defun bearings ( ent / enx lst )
   (setq enx (entget ent)
         lst (mapcar 'cdr (vl-remove-if-not '(lambda ( x ) (= 10 (car x))) enx))
   )
   (if (= 1 (logand 1 (cdr (assoc 70 enx))))
       (setq lst (append lst (list (car lst))))
   )
   (if (cdr lst)
       (cons (distance (car lst) (cadr lst))
           (apply 'append
               (mapcar
                   (function
                       (lambda ( a b c )
                           (list (* 180.0 (/ (- (rem (+ pi pi (- (angle b a) (angle b c))) (+ pi pi)) pi) pi)) (distance b c))
                       )
                   )
                   lst (cdr  lst) (cddr lst)
               )
           )
       )
   )
)

 

To test:

(defun c:test ( / sel )
   (if (setq sel (ssget "_+.:E:S" '((0 . "LWPOLYLINE") (-4 . "<NOT") (-4 . "<>") (42 . 0.0) (-4 . "NOT>"))))
       (print (bearings (ssname sel 0)))
   )
   (princ)
)

  • 2 weeks later...
Posted

Wow, thank you for the quick reply Lee Mac. It works great

  • 4 weeks later...
Posted

Hello Lee

Could you change your code to give the result as below?

attachment.php?attachmentid=63771&cid=1&stc=1

POLYLINE2.jpg

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...