- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I got the following lisp to label 'Area' and 'Perimeter' of the selected closed polylines.
When running the lisp it asks "Select TEXT to match height". Somehow it's not working whereas I have to manually input the text height (... but it is ok).
Can someone modify the lisp to:
1. It should ask to "Select TEXT to match height OR enter text height"
2. The value selected or entered should be remembered till the file closes.
Please help..
(defun C:mynewarea (/ acsp adoc ar axss txht maxp minp obj p1 p2 pc1 pc2 per
ss txts txt1 txt2)
(vl-load-com)
(setq adoc (vla-get-activedocument
(vlax-get-acad-object)
)
)
(if (and
(= (getvar "tilemode") 0)
(= (getvar "cvport") 1)
)
(setq acsp (vla-get-paperspace adoc))
(setq acsp (vla-get-modelspace adoc))
)
(vla-startundomark (vla-get-activedocument
(vlax-get-acad-object)))
(setQ txht (getreal "\nSelect TEXT to match height: "))
(setQ tx1 (/ txht 3))
(setQ tx2 (/ txht 1))
(prompt "\n Select OBJECTS on screen to add area label")
(if (setq ss (ssget))
(progn
(setq axss (vla-get-activeselectionset adoc))
(vlax-for obj axss
(if
(and
(not
(vl-catch-all-error-p
(setq
ar (vl-catch-all-apply
(function (lambda()
(vlax-curve-getarea obj)))))))
(not
(vl-catch-all-error-p
(setq
per (vl-catch-all-apply
(function (lambda()
(vlax-curve-getdistatparam obj
(vlax-curve-getendparam obj)))))))))
(progn
(setq txt2 (strcat "Area= " (rtos ar 2 2)))
(setq txt3 (strcat "Perimeter= " (rtos per 2 2)))
(setq pc1 (getpoint "\nPick Insertion point."))
(setq pc2 (mapcar '- pc1 (list 0 (* tx2 1.5) 0)))
(setq pc3 (mapcar '- pc2 (list 0 (* tx2 1.5) 0)))
;(setq pc4 (mapcar '- pc3 (list 0 (* tx2 1.5) 0)))
(command "text" pc2 tx2 "" txt2)
(command "text" pc3 tx2 "" txt3)
)
)
)
)
)
(vla-endundomark (vla-get-activedocument
(vlax-get-acad-object)))
(princ)
)
(princ "\n Type mynewarea to label objects with area and perimeter text")
(princ)
Solved! Go to Solution.