Hi everyone,
currently I'm connecting a polyline to a dynamic block (by ID), read the area of that line and write that to a field (It's a room tag /w automatic area field). The code I did not write myself but picked it up on the web (unfortunately can't remember where, so can't give credit).
Now I would like to as well write the perimeter of that polyline to another field and at the same time ideally check, if the polyline is closed.
It'd be great if anyone could help out, I still find it quite hard to understand LISP code.
Any hints are appreciated.
Best
C
[code] (defun C:linktoblock ( / pline tagblock attribute e d attobj plineobj) (setq pline (car (entsel "\nPolylinie waehlen: "))) (setq tagblock (car (entsel "\nRaumstempel waehlen: "))) (setq e (entnext tagblock)) (while (and (not attribute) (/= "SEQEND" (cdr (assoc 0 (setq d (entget e)))))) (if (eq "AREA" (cdr (assoc 2 d))) (setq attribute e) ) (setq e (entnext e)) ) (if attribute (progn (setq attobj (vlax-ename->vla-object attribute)) (setq plineobj (vlax-ename->vla-object pline)) (setq plineid (vla-get-objectid plineobj)) (vla-put-textstring attobj (strcat "%<\\AcObjProp.16.2 Object(%<\\_ObjId " (itoa plineid) ">%).Area \\f \"%lu2%pr2%ps[A= , m²]%ds44%zs8%th46\">%" ) ) (vlax-release-object attobj) (vlax-release-object plineobj) ) ) (princ) ) [/code]
Doing a search on the web will get you lots of info on this subject. To help you get started:
To read up on how to check if pline is closed:
The key is this function:
(vlax-curve-isClosed entityname)
To read up on getting the perimter:
http://www.autolisp.com/forum/threads/590-Perimeter-and-area-calculation
The key is this function:
(vla-get-Length (vlax-ename->vla-object entityname))
Area Object Link-Exchange App Store | Dwg Setup-Exchange App Store | Feet-Inch Calculator-Exchange App Store