The code is great, I already changed the prefix and sufix of the field but I don't know how to change the properties (layer, color, TextStyle) of the resultant field inside this code and how to do it all inside a multileader or block, could you help me?
(defun c:test2 ( ) (LM:QuickField "Length" "%lu2%pr2%ps[C= ,m]" 3))
(defun LM:quickfield ( prop format mode / ent ins obj str )
(if (setq str (LM:quickfield:constructfieldstring prop format))
(cond
( (= 1 mode)
(if (setq ent (LM:quickfield:selectifhasprop "Textstring" nentsel))
(progn
(setq obj (vlax-ename->vla-object ent))
(vla-put-textstring obj "") ;; To clear any existing field
(vla-put-textstring obj str)
(if (= "ATTRIB" (cdr (assoc 0 (entget ent))))
(vl-cmdf "_.updatefield" ent "")
)
)
)
)
( (= 2 mode)
(if (setq ins (getpoint "\nSpecify point for text: "))
(vla-addtext
(vlax-get-property (LM:quickfield:acdoc)
(if (= 1 (getvar 'cvport))
'paperspace
'modelspace
)
)
str (vlax-3D-point (trans ins 1 0)) (getvar 'textsize)
)
)
)
( (= 3 mode)
(if (setq ins (getpoint "\nSpecify point for mtext: "))
(vla-addmtext
(vlax-get-property (LM:quickfield:acdoc)
(if (= 1 (getvar 'cvport))
'paperspace
'modelspace
)
)
(vlax-3D-point (trans ins 1 0)) 0.0 str
)
)
)
)
)
(princ)
)
(defun LM:quickfield:selectifhasprop ( prop func / ent )
(while
(progn
(setvar 'errno 0)
(setq ent (car (func (strcat "\nSelect object with " prop " property: "))))
(cond
( (= 7 (getvar 'errno))
(princ "\nMissed, try again.")
)
( (null ent)
nil
)
( (not (vlax-property-available-p (vlax-ename->vla-object ent) prop))
(princ (strcat "\nSelected object does not have " prop " property."))
)
)
)
)
ent
)
(defun LM:quickfield:acdoc nil
(eval (list 'defun 'LM:quickfield:acdoc 'nil (vla-get-activedocument (vlax-get-acad-object))))
(LM:quickfield:acdoc)
)
( (lambda nil (vl-load-com)
(eval
(list 'defun 'LM:quickfield:constructfieldstring '( prop format / ent )
(list 'if '(setq ent (LM:quickfield:selectifhasprop prop entsel))
(list 'strcat "%<\\AcObjProp Object(%<\\_ObjId "
(if (vlax-method-applicable-p (vla-get-utility (LM:quickfield:acdoc)) 'getobjectidstring)
(list 'vla-getobjectidstring (vla-get-utility (LM:quickfield:acdoc)) '(vlax-ename->vla-object ent) ':vlax-false)
'(itoa (vla-get-objectid (vlax-ename->vla-object ent)))
)
">%)." 'prop '(if (/= "" format) (strcat " \\f \"" format "\">%") ">%")
)
)
)
)
)
)
(princ)