Jump to content

lISP ANGLE MEASUREMENT IN AUTOCAD 3D


CongVenh

Recommended Posts

My last try:

(defun c:pp()
  (setq p1 (cdr (assoc 10 (setq el (entget (car (entsel "Select line   \n "))))))
	p2 (cdr (assoc 11 el))
	p3 (list (car p1) (cadr p1) (caddr p2))
	ang1 (atan (distance p1 p3) (distance p2 p3))
	ang2 (angle p3 p2)
	)
  (strcat  (convert ang1) "   |   " (convert ang2))
  )
(defun convert(a)
  (setq a (/ (* a 180.0) PI)
	d (fix a)
	m (fix (+ 0.5 (* 60.0 (- a d)))))
  (strcat (itoa d) "deg " (itoa m) "min")
  )

 

Link to comment
Share on other sites

14 hours ago, fuccaro said:

My last try:

(defun c:pp()
  (setq p1 (cdr (assoc 10 (setq el (entget (car (entsel "Select line   \n "))))))
	p2 (cdr (assoc 11 el))
	p3 (list (car p1) (cadr p1) (caddr p2))
	ang1 (atan (distance p1 p3) (distance p2 p3))
	ang2 (angle p3 p2)
	)
  (strcat  (convert ang1) "   |   " (convert ang2))
  )
(defun convert(a)
  (setq a (/ (* a 180.0) PI)
	d (fix a)
	m (fix (+ 0.5 (* 60.0 (- a d)))))
  (strcat (itoa d) "deg " (itoa m) "min")
  )

 

Thank you Fuccaro. The results were exactly what I wanted. Can you help me output that result to the screen instead of reading it from the command line?

Link to comment
Share on other sites

What do you mean by "output to the screen"? I could create two TEXT entities, but you will have to place them in the right position. You don't need any more to export the angles to Excel?

Link to comment
Share on other sites

(defun c:angles( / p1 p2 p3 ang1 ang2 sel a1 a2 textH)
  (setq p1 (cdr (assoc 10 (setq el (entget (car (setq sel (entsel "Select line   \n ")))))))
	p2 (cdr (assoc 11 el))
	p3 (list (car p1) (cadr p1) (caddr p2))
	ang1 (atan (distance p1 p3) (distance p2 p3))
	ang2 (angle p3 p2)
	)
  (strcat  (setq a1 (convert ang1)) "   |   " (setq a2 (convert ang2)))
  (setq textH 2)
  (entmake (mapcar 'cons '( 0 1 10 40 62) (list "text" a1 (cadr sel) textH 1)))
  (entmake (mapcar 'cons '( 0 1 10 40 62) (list "text" a2 (mapcar '+ (cadr sel) (list textH textH 0)) textH 4)))
  (export a1 a2)
  )
(defun convert(a / d m)
  (setq a (/ (* a 180.0) PI)
	d (fix a)
	m (fix (+ 0.5 (* 60.0 (- a d)))))
  (strcat (itoa d) "deg " (itoa m) "min")
  )
(defun export(a b / f file)
  (setq file (getfiled "Specify out file" (substr (setq name (getvar "dwgname")) 1 (- (strlen name) 4))   "csv" 1))
  (setq f (open file "w"))
  (write-line a f)
  (write-line b f)
  (close f)
  )

 

  • Like 1
Link to comment
Share on other sites

17 hours ago, fuccaro said:
(defun c:angles( / p1 p2 p3 ang1 ang2 sel a1 a2 textH)
  (setq p1 (cdr (assoc 10 (setq el (entget (car (setq sel (entsel "Select line   \n ")))))))
	p2 (cdr (assoc 11 el))
	p3 (list (car p1) (cadr p1) (caddr p2))
	ang1 (atan (distance p1 p3) (distance p2 p3))
	ang2 (angle p3 p2)
	)
  (strcat  (setq a1 (convert ang1)) "   |   " (setq a2 (convert ang2)))
  (setq textH 2)
  (entmake (mapcar 'cons '( 0 1 10 40 62) (list "text" a1 (cadr sel) textH 1)))
  (entmake (mapcar 'cons '( 0 1 10 40 62) (list "text" a2 (mapcar '+ (cadr sel) (list textH textH 0)) textH 4)))
  (export a1 a2)
  )
(defun convert(a / d m)
  (setq a (/ (* a 180.0) PI)
	d (fix a)
	m (fix (+ 0.5 (* 60.0 (- a d)))))
  (strcat (itoa d) "deg " (itoa m) "min")
  )
(defun export(a b / f file)
  (setq file (getfiled "Specify out file" (substr (setq name (getvar "dwgname")) 1 (- (strlen name) 4))   "csv" 1))
  (setq f (open file "w"))
  (write-line a f)
  (write-line b f)
  (close f)
  )

 

Thank you very much Fuccaro. Thanks to you, my work is easier

  • Like 1
Link to comment
Share on other sites

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