<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Create a Field Formula from Field Expressions in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/create-a-field-formula-from-field-expressions/m-p/13772764#M165975</link>
    <description>&lt;P&gt;i was tying something similar but this is the MTEXT output&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Julio_Soto_1-1755545121850.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1562284i6A658B85E1B3EAEF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Julio_Soto_1-1755545121850.png" alt="Julio_Soto_1-1755545121850.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;This is my test code, with the ObjectID hardcoded into the lisp for testing. also attached is the block i'm working with.&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(defun c:TestBoltLengthField (/ pt objId paramId str) 
  (setq pt (getpoint "\nPick insertion point for test field: "))

  (setq str (strcat 
              "%&amp;lt;\\AcExpr "
              "("
              "%&amp;lt;\\AcObjProp.16.2 Object (%&amp;lt;\\_ObjId 2429014325728).Parameter(1).UpdatedDistance \\f \"%lu6%zs12\"&amp;gt;%"
              " / "
              "%&amp;lt;\\AcObjProp.16.2 Object(%&amp;lt;\\_ObjId 2429014325728).InsUnitsFactor \\f \"%lu6%zs12\"&amp;gt;%"
              ")"
              "\\f \"%lu6%zs12\"&amp;gt;%"
            )
  )


  ;; Insert it as MText
  (entmakex 
    (list 
      '(0 . "MTEXT")
      '(100 . "AcDbEntity")
      '(100 . "AcDbMText")
      (cons 10 pt)
      (cons 40 0.2) ;; text height
      (cons 1 str) ;; the field string
      (cons 7 "Arial")
      (cons 71 1) ;; top-left attachment
      (cons 72 5) ;; L-to-R flow
      (cons 11 (list 1.0 0.0 0.0))
      (cons 210 (list 0.0 0.0 1.0))
    )
  )
  (princ)
)

(princ "\nTest TEst")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 18 Aug 2025 19:26:58 GMT</pubDate>
    <dc:creator>Julio_Soto</dc:creator>
    <dc:date>2025-08-18T19:26:58Z</dc:date>
    <item>
      <title>Create a Field Formula from Field Expressions</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/create-a-field-formula-from-field-expressions/m-p/13772372#M165958</link>
      <description>&lt;P&gt;I have a lisp that I'm writing that takes a length parameter from a dynamic block and divides it by the unit factor (for dwg with different units)&lt;BR /&gt;&lt;BR /&gt;when I do this manually in AutoCAD the field looks like this&lt;BR /&gt;&lt;BR /&gt;%&amp;lt;\AcExpr (&lt;FONT color="#FF9900"&gt;%&amp;lt;\_FldPtr 1947961495696&amp;gt;%&lt;/FONT&gt; &lt;STRONG&gt;/&lt;/STRONG&gt;&lt;FONT color="#0000FF"&gt; %&amp;lt;\_FldPtr 1947961496080&amp;gt;%&lt;/FONT&gt;) \f "%lu2%zs12"&amp;gt;%&lt;BR /&gt;&lt;BR /&gt;but each FldPtr looks like this&lt;BR /&gt;%&amp;lt;\AcObjProp.16.2 Object(%&amp;lt;\_ObjId 1948028287920&amp;gt;%).Parameter(1).UpdatedDistance \f "%lu6%zs12"&amp;gt;%&lt;/P&gt;&lt;P&gt;and&lt;BR /&gt;%&amp;lt;\AcObjProp.16.2 Object(%&amp;lt;\_ObjId 1948028287920&amp;gt;%).InsUnitsFactor \f "%lu6%zs12"&amp;gt;%&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I can get those two fields with Lee-Mac's getobject Id and pramters, ect. but I don't know how to build the FldPtr expressions.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;is this possible with LISP?&lt;/P&gt;</description>
      <pubDate>Mon, 18 Aug 2025 15:42:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/create-a-field-formula-from-field-expressions/m-p/13772372#M165958</guid>
      <dc:creator>Julio_Soto</dc:creator>
      <dc:date>2025-08-18T15:42:57Z</dc:date>
    </item>
    <item>
      <title>Re: Create a Field Formula from Field Expressions</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/create-a-field-formula-from-field-expressions/m-p/13772509#M165962</link>
      <description>&lt;P&gt;did you create this field using the field formula option?&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;%&amp;lt;\_FldPtr 1947961496080&amp;gt;%&lt;/FONT&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Aug 2025 17:00:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/create-a-field-formula-from-field-expressions/m-p/13772509#M165962</guid>
      <dc:creator>paullimapa</dc:creator>
      <dc:date>2025-08-18T17:00:04Z</dc:date>
    </item>
    <item>
      <title>Re: Create a Field Formula from Field Expressions</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/create-a-field-formula-from-field-expressions/m-p/13772617#M165969</link>
      <description>&lt;P&gt;Yes.&amp;nbsp; I used the "Formula" option, then in the window where you enter formulas I create two more fields.&lt;BR /&gt;&lt;BR /&gt;I can create each field just fine with AutoLISP, but I dont' know how to create a FldPtr that AutoCAD uses, like this&lt;BR /&gt;&lt;SPAN&gt;%&amp;lt;\AcExpr (&lt;/SPAN&gt;&lt;FONT color="#FF9900"&gt;%&amp;lt;\_FldPtr 1947961495696&amp;gt;%&lt;/FONT&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;/&lt;/STRONG&gt;&lt;FONT color="#0000FF"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;%&amp;lt;\_FldPtr 1947961496080&amp;gt;%&lt;/FONT&gt;&lt;SPAN&gt;) \f "%lu2%zs12"&amp;gt;%&lt;BR /&gt;&lt;BR /&gt;each field was assigned some ID by autocad.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Those FldPtr are referencing the other two fields.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Aug 2025 17:47:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/create-a-field-formula-from-field-expressions/m-p/13772617#M165969</guid>
      <dc:creator>Julio_Soto</dc:creator>
      <dc:date>2025-08-18T17:47:09Z</dc:date>
    </item>
    <item>
      <title>Re: Create a Field Formula from Field Expressions</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/create-a-field-formula-from-field-expressions/m-p/13772678#M165971</link>
      <description>&lt;P&gt;In place of both:&amp;nbsp;&lt;FONT color="#FF9900"&gt;%&amp;lt;\_FldPtr 1947961495696&amp;gt;%&lt;/FONT&gt;&lt;SPAN&gt;&amp;nbsp;and %&amp;lt;\_FldPtr 1947961496080&amp;gt;%&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;use the actual &lt;STRONG&gt;%&amp;lt;\&lt;/STRONG&gt;A&lt;STRONG&gt;cObjProp&lt;/STRONG&gt; reference which would be something like this:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(strcat
"%&amp;lt;\\AcExpr&amp;nbsp;"
"("
%&amp;lt;\\AcObjProp.16.2 Object(%&amp;lt;\\_ObjId 1948028287920&amp;gt;%).Parameter(1).UpdatedDistance \\f \"%lu6%zs12\"&amp;gt;%"
"&amp;nbsp;/ "
"%&amp;lt;\\AcObjProp.16.2 Object(%&amp;lt;\\_ObjId 1948028287920&amp;gt;%).InsUnitsFactor \\f \"%lu6%zs12\"&amp;gt;%"
")"
"\\f \"%lu6%zs12\"&amp;gt;%"
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Aug 2025 18:18:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/create-a-field-formula-from-field-expressions/m-p/13772678#M165971</guid>
      <dc:creator>paullimapa</dc:creator>
      <dc:date>2025-08-18T18:18:00Z</dc:date>
    </item>
    <item>
      <title>Re: Create a Field Formula from Field Expressions</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/create-a-field-formula-from-field-expressions/m-p/13772764#M165975</link>
      <description>&lt;P&gt;i was tying something similar but this is the MTEXT output&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Julio_Soto_1-1755545121850.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1562284i6A658B85E1B3EAEF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Julio_Soto_1-1755545121850.png" alt="Julio_Soto_1-1755545121850.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;This is my test code, with the ObjectID hardcoded into the lisp for testing. also attached is the block i'm working with.&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(defun c:TestBoltLengthField (/ pt objId paramId str) 
  (setq pt (getpoint "\nPick insertion point for test field: "))

  (setq str (strcat 
              "%&amp;lt;\\AcExpr "
              "("
              "%&amp;lt;\\AcObjProp.16.2 Object (%&amp;lt;\\_ObjId 2429014325728).Parameter(1).UpdatedDistance \\f \"%lu6%zs12\"&amp;gt;%"
              " / "
              "%&amp;lt;\\AcObjProp.16.2 Object(%&amp;lt;\\_ObjId 2429014325728).InsUnitsFactor \\f \"%lu6%zs12\"&amp;gt;%"
              ")"
              "\\f \"%lu6%zs12\"&amp;gt;%"
            )
  )


  ;; Insert it as MText
  (entmakex 
    (list 
      '(0 . "MTEXT")
      '(100 . "AcDbEntity")
      '(100 . "AcDbMText")
      (cons 10 pt)
      (cons 40 0.2) ;; text height
      (cons 1 str) ;; the field string
      (cons 7 "Arial")
      (cons 71 1) ;; top-left attachment
      (cons 72 5) ;; L-to-R flow
      (cons 11 (list 1.0 0.0 0.0))
      (cons 210 (list 0.0 0.0 1.0))
    )
  )
  (princ)
)

(princ "\nTest TEst")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Aug 2025 19:26:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/create-a-field-formula-from-field-expressions/m-p/13772764#M165975</guid>
      <dc:creator>Julio_Soto</dc:creator>
      <dc:date>2025-08-18T19:26:58Z</dc:date>
    </item>
    <item>
      <title>Re: Create a Field Formula from Field Expressions</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/create-a-field-formula-from-field-expressions/m-p/13772918#M165981</link>
      <description>&lt;P&gt;Don't think you can hardcode the ObjectID.&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I would use this function to get it and convert it from integer to string:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(itoa (vla-get-objectid obj))&lt;/LI-CODE&gt;&lt;P&gt;Then the complete string formatting will look like this:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(setq str (strcat 
              "%&amp;lt;\\AcExpr "
              "("
              "%&amp;lt;\\AcObjProp.16.2 Object(%&amp;lt;\\_ObjId " (itoa (vla-get-objectid obj)) "&amp;gt;%).Parameter(90).lookupString \\f \"%lu6%zs12\"&amp;gt;%"
              " / "
              "%&amp;lt;\\AcObjProp.16.2 Object(%&amp;lt;\\_ObjId " (itoa (vla-get-objectid obj)) "&amp;gt;%).InsUnitsFactor \\f \"%lu6%zs12\"&amp;gt;%"
              ")"
              " \\f \"%lu6%zs12\""
              "&amp;gt;%"
            )
)&lt;/LI-CODE&gt;&lt;P&gt;Now you can't add the string into the MText object when you create it so I would keep the string empty like this:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(entmakex 
    (list 
      '(0 . "MTEXT")
      '(100 . "AcDbEntity")
      '(100 . "AcDbMText")
      (cons 10 pt)
      (cons 40 0.2) ;; text height
;      (cons 1 str) ;; the field string
      (cons 1 "")
      (cons 7 "Arial")
      (cons 71 1) ;; top-left attachment
      (cons 72 5) ;; L-to-R flow
      (cons 11 (list 1.0 0.0 0.0))
      (cons 210 (list 0.0 0.0 1.0))
    )
)&lt;/LI-CODE&gt;&lt;P&gt;Then use this vla function to put the text in:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(vla-put-textstring (vlax-ename-&amp;gt;vla-object (entlast)) str)&lt;/LI-CODE&gt;&lt;P&gt;Now editing the &lt;STRONG&gt;MText&lt;/STRONG&gt; &lt;STRONG&gt;Field&lt;/STRONG&gt; object, it does show both &lt;STRONG&gt;numerator&lt;/STRONG&gt; and &lt;STRONG&gt;denominator&lt;/STRONG&gt;:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="paullimapa_0-1755554214517.png" style="width: 477px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1562320i2BE4CCFAAD6FA201/image-dimensions/477x441?v=v2" width="477" height="441" role="button" title="paullimapa_0-1755554214517.png" alt="paullimapa_0-1755554214517.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;But it still evaluates to &lt;STRONG&gt;###&lt;/STRONG&gt; because of the &lt;STRONG&gt;mm&lt;/STRONG&gt; unit string that comes with the &lt;STRONG&gt;65&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Aug 2025 21:57:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/create-a-field-formula-from-field-expressions/m-p/13772918#M165981</guid>
      <dc:creator>paullimapa</dc:creator>
      <dc:date>2025-08-18T21:57:59Z</dc:date>
    </item>
    <item>
      <title>Re: Create a Field Formula from Field Expressions</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/create-a-field-formula-from-field-expressions/m-p/13772930#M165982</link>
      <description>&lt;P&gt;so if you double click the field "65mm" you'll see the other to fields&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Julio_Soto_0-1755554703693.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1562325iC18244FFAD7B91A5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Julio_Soto_0-1755554703693.png" alt="Julio_Soto_0-1755554703693.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;the "mm" is just from "Additional formatting"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;aside fromthe 65mm you were able to get it to work?&lt;/P&gt;</description>
      <pubDate>Mon, 18 Aug 2025 22:05:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/create-a-field-formula-from-field-expressions/m-p/13772930#M165982</guid>
      <dc:creator>Julio_Soto</dc:creator>
      <dc:date>2025-08-18T22:05:42Z</dc:date>
    </item>
    <item>
      <title>Re: Create a Field Formula from Field Expressions</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/create-a-field-formula-from-field-expressions/m-p/13772933#M165983</link>
      <description>&lt;P&gt;yes, the fields do show up when I run the codes I provided you in my previous post&lt;/P&gt;</description>
      <pubDate>Mon, 18 Aug 2025 22:10:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/create-a-field-formula-from-field-expressions/m-p/13772933#M165983</guid>
      <dc:creator>paullimapa</dc:creator>
      <dc:date>2025-08-18T22:10:48Z</dc:date>
    </item>
    <item>
      <title>Re: Create a Field Formula from Field Expressions</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/create-a-field-formula-from-field-expressions/m-p/13772957#M165984</link>
      <description>&lt;P&gt;Thanks for the help dude, this is the code that is working right&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(defun c:TestBoltLengthField (/ pt blkObj objectID str mtextEnt)
  (setq pt (getpoint "\nPick insertion point for test field: "))
  (setq obj (vlax-ename-&amp;gt;vla-object (car (entsel "\nSelect block: "))))
  (setq objectID (getobjectid obj)) ;; Lee Mac helper

  ;; Build field string
(setq str (strcat 
              "%&amp;lt;\\AcExpr "
              "("
              "%&amp;lt;\\AcObjProp.16.2 Object(%&amp;lt;\\_ObjId " objectID "&amp;gt;%).Parameter(1).UpdatedDistance  \\f \"%lu6%zs12\"&amp;gt;%"
              " / "
              "%&amp;lt;\\AcObjProp.16.2 Object(%&amp;lt;\\_ObjId " objectID "&amp;gt;%).InsUnitsFactor \\f \"%lu6%zs12\"&amp;gt;%"
              ")"
              " \\f \"%lu2%zs12\""
              "&amp;gt;%"
            )
)

  ;; Insert dummy MTEXT
  (setq mtextEnt
    (entmakex
      (list
        '(0 . "MTEXT")
        '(100 . "AcDbEntity")
        '(100 . "AcDbMText")
        (cons 10 pt)
        (cons 40 0.2) ;; text height
        (cons 1 "-")  ;; placeholder
        (cons 7 "Arial")
        (cons 71 1)   ;; top-left attachment
        (cons 72 5)   ;; L-to-R flow
        (cons 11 (list 1.0 0.0 0.0))
        (cons 210 (list 0.0 0.0 1.0))
      )
    )
  )

  (vla-put-TextString (vlax-ename-&amp;gt;vla-object mtextEnt) str)

  (princ)
)



(defun GetObjectID (BlockVLA / acadobj acaddoc BlockEname BlockVLA) 
  (setq acadobj (vlax-get-acad-object)
        acaddoc (vla-get-activedocument acadobj)
  )
  ;; Lee Mac
  (if (eq "X64" (strcase (getenv "PROCESSOR_ARCHITECTURE"))) 
    (vlax-invoke-method (vla-get-Utility acaddoc) 'GetObjectIdString BlockVLA :vlax-false)
    (itoa (vla-get-Objectid BlockVLA))
  )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;in addition to some formatting issue, my main problem was putting my string in ENTMAKEX.&amp;nbsp; using vla-put-TextString was the trick. thanks again my friend!&lt;BR /&gt;&lt;BR /&gt;(also i used lee-mac getobjectID)&lt;/P&gt;</description>
      <pubDate>Mon, 18 Aug 2025 22:50:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/create-a-field-formula-from-field-expressions/m-p/13772957#M165984</guid>
      <dc:creator>Julio_Soto</dc:creator>
      <dc:date>2025-08-18T22:50:00Z</dc:date>
    </item>
    <item>
      <title>Re: Create a Field Formula from Field Expressions</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/create-a-field-formula-from-field-expressions/m-p/13772965#M165985</link>
      <description>&lt;P&gt;you are welcome...cheers!!!&lt;/P&gt;</description>
      <pubDate>Mon, 18 Aug 2025 22:58:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/create-a-field-formula-from-field-expressions/m-p/13772965#M165985</guid>
      <dc:creator>paullimapa</dc:creator>
      <dc:date>2025-08-18T22:58:58Z</dc:date>
    </item>
  </channel>
</rss>

