Author Topic: Combine codes for Field Area & Layer  (Read 1711 times)

0 Members and 1 Guest are viewing this topic.

vulchur

  • Guest
Combine codes for Field Area & Layer
« on: June 08, 2011, 01:32:08 PM »
I opened the existing lisp and found alot of coding that does not make sense to me.
When I monkey around with it, the lisp quits working.
As it is, it ultimately works for each command separately.
I didn't write the original.

Code: [Select]
Type FA, Pick a polyline, insert field with the area in s.f.
or
Type FAL, Pick a polyline, insert field with the layer name

I want to be able to type FAL, pick the polyline, insert 2 fields in one piece of m-text for the area and layer name of the object. Or at the bare minimum, two pieces of m-text with a field in each.

Please help me decipher this mess.
Thank you!!!
Code: [Select]
;;Setting a Field Object "area"

(defun c:FA ()
;;Turns off Fields Backgrounds
(COMMAND "FIELDDISPLAY" "0")

;;set layer
(if (not (tblsearch "LAYER" "m-ZONE"))
(Command "-layer" "n" "m-ZONE" "c" "3" "m-ZONE" "s" "m-ZONE" "")
(setvar "clayer" "m-ZONE"))
(prompt "\nPick Pline for Area Calculation ")
;;get a reference to model space
(setq *model-space*
(vla-get-ModelSpace
(vla-get-ActiveDocument (vlax-get-acad-object))
)
)
;;pass this function an entity and a point
(defun LinkedArea (ent pt / obj objID ip width str)
;;convert the entity to an object
(setq obj (vlax-ename->vla-object ent)
;;get the object ID
objID (vla-get-objectid obj)
;;convert the point
ip (vlax-3D-Point pt)
;;set the width for the MTEXT
width 0.0
;;set the string - this creates the field - from field expression
str (strcat
"%<\\AcObjProp.16.2 Object(%<\\_ObjId "(rtos objID 2 0)">%).Area \\f
\"%lu2%ct4%qf1 S.F.\">%"
)
)
;;Create the MTEXT entity containing the field.
(vla-addMText *model-space* ip width str)
)
;; Set A = the entity and set B = Point for text
(setq a (car (entsel)) b (getpoint "\n Select Point: "))
;;Call the function
(linkedarea a b)
(princ)
(EXIT))

;;Setting a Field Object "layer"
(defun c:FAL ()
;;Turns off Fields Backgrounds
(COMMAND "FIELDDISPLAY" "0")

;;set layer
(if (not (tblsearch "LAYER" "ZONE"))
(Command "-layer" "n" "ZONE" "c" "2" "ZONE" "s" "ZONE" "")
(setvar "clayer" "ZONE"))
(prompt "\nPick Pline to List the Layer ")
;;get a reference to model space
(setq *model-space*
(vla-get-ModelSpace
(vla-get-ActiveDocument (vlax-get-acad-object))
)
)
;;pass this function an entity and a point
(defun LinkedArea (ent pt / obj objID ip width str)
;;convert the entity to an object
(setq obj (vlax-ename->vla-object ent)
;;get the object ID
objID (vla-get-objectid obj)
;;convert the point
ip (vlax-3D-Point pt)
;;set the width for the MTEXT
width 0.0
;;set the string - this creates the field - from field expression
str (strcat
"%<\\AcObjProp.16.2 Object(%<\\_ObjId "(rtos objID 2 0)">%).layer \\f
\"%lu2%ct4%qf1 S.F.\">%"
)
)
;;Create the MTEXT entity containing the field.
(vla-addMText *model-space* ip width str)
)
;; Set A = the entity and set B = Point for text
(setq a (car (entsel)) b (getpoint "\n Select Point: "))
;;Call the function
(linkedarea a b)
(princ)
(EXIT))

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Combine codes for Field Area & Layer
« Reply #1 on: June 08, 2011, 02:37:35 PM »
You can use the code here to help you out.
[ http://www.theswamp.org/index.php?topic=20446.0 ]
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

vulchur

  • Guest
Re: Combine codes for Field Area & Layer
« Reply #2 on: June 08, 2011, 02:52:58 PM »
Thank you, I will dive into that and let you know what happens.