Jump to content

Recommended Posts

Posted

Can somebody help me to find out a code to obtain an angle of a nested line object by selecting it.

Posted (edited)

An example:

(defun c:test ( / enx lst mat )
   (cond
       (   (not (setq lst (nentselp "\nSelect nested line: ")))
           (princ "\nNo object selected.")
       )
       (   (/= 4 (length lst))
           (princ "\nThe selected object is not nested.")
       )
       (   (/= "LINE" (cdr (assoc 0 (setq enx (entget (car lst))))))
           (princ "\nThe selected object is not a line.")
       )
       (   (setq mat (mapcar 'rcdr (rcdr (caddr lst))))
           (princ (angtos (apply 'angle (mapcar '(lambda ( x ) (mxv mat (cdr (assoc x enx)))) '(10 11)))))
       )
   )
   (princ)
)

;; Reverse cdr  -  Lee Mac
;; Returns all but the last item of a list

(defun rcdr ( l )
   (reverse (cdr (reverse l)))
)

;; Matrix x Vector  -  Vladimir Nesterovsky
;; Args: m - nxn matrix, v - vector in R^n

(defun mxv ( m v )
   (mapcar '(lambda ( r ) (apply '+ (mapcar '* r v))) m)
)

(princ)

Edited by Lee Mac
Posted

Thanks. I know you are the person writing this kind of codes.

nested.PNG

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