Message 1 of 3
LISP for creating field off a selected object, grabbing specific attribute
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Looking to create an autocad lisp that allows me to select an object and places a field parameter regarding that specific block's attribute titled CIRCUIT#. Original thought process was to select an object, grab its id, then place field parameter. It should autoselect field category as object, the object type should be the object that I selected, property should be Circuit#, and format should be (none).
For reference, here are two examples of the field expression for two objects.
%<\AcObjProp Object(%<\_ObjId 1770506033232>%).TextString>%
%<\AcObjProp Object(%<\_ObjId 1770506022224>%).TextString>%
I have an attempt above!
(defun c:PlaceField ()
(setq obj (car (nentselp "\nSelect an object: ")))
(if obj
(progn
(setq entityId (cdr (assoc 5 (entget obj)))) ; Get the handle of the selected object
(setq fieldText (strcat "%<\\AcObjProp Object(%<\\_ObjId " entityId ">%).Attribute(\"CIRCUIT#\")>%"))
(command "_.FIELD" "_Object" fieldText "_Type" "Object" "_Object" entityId "_Field")
)
(princ "\nNo object selected.")
)
)
; Examples of proper field expression
;<\AcObjProp Object(%<\_ObjId 1770506033232>%).TextString>%
;%<\AcObjProp Object(%<\_ObjId 1770506022224>%).TextString>%