Exploiting the "Field Expression"

Exploiting the "Field Expression"

Anonymous
Not applicable
191 Views
2 Replies
Message 1 of 3

Exploiting the "Field Expression"

Anonymous
Not applicable
I wrote a routine that will allow you to select a closed Polyline or pick a point inside of a closed area, and then it will retrieve the area, convert it to Acres (if you want it to) and then insert a block with attributes and fill in the attribute that asks for the area with the area it got from the object you just selected.

(defun c:acres (/ pt ent a temp val val2)
(setq layerold (getvar "clayer"))
(setq ent nil)
(setq N nil)
(setq val (getstring "\nUnits in Acres or Square feet? (A/S): "))
(if (= val "") (setq val "a"))
(while (not ent)
(while (not N)
(setq ent (car...











































































0 Likes
192 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
This is one I wrote for work. It should help you to figure out what
you need.

CJ



(defun c:AreaReport (/ a theobj id layer pt1 textobj strObject)
(princ "\nArea Report ")
(setq a (entsel "\nSelect Polyline: "))
(while a
(if (= (cdr (assoc 0 (entget (car a)))) "LWPOLYLINE")
(progn
(setq theobj (vlax-ename->vla-object (car a)))
(setq id (vla-get-objectid theobj))
(setq layer (vla-get-layer theobj))
(setq pt1 (getpoint "\nSelect location of text: "))
(setq textobj
(vla-addtext
(vla-get-ModelSpace (vla-get-ActiveDocument (vlax-get-acad-object)))
(strcat "%<\\AcObjProp Object(%<\\_ObjId " (itoa id) ">%).Area \\f
\"%lu2%ct4%qf1%pr0 SF>%" )
(vlax-3d-point pt1)
(* (getvar "dimscale") 0.09375)
))
(vla-put-layer textobj layer)
(setq a (entsel "\nSelect Polyline: "))
)
(progn
(setq strObject (vla-get-ObjectName (vlax-ename->vla-object (car a))))
(princ (strcat "\nInvalid. < " (strcase (substr strObject 5)) " >
selected. Please select a Polyline." ))
(setq a (entsel "\nSelect Polyline: "))
)
)
)
(princ)
)
0 Likes
Message 3 of 3

Anonymous
Not applicable
That worked out great, Thank you
0 Likes