Hi, I am trying something simple:
1. Entmakex a line from 2 points
2. Entmakex a mtext in the middle, and populate it with Length FIELD from the line
Whats wrong with my field content?
(vl-load-com) (princ)
(defun C:test ( / p1 p2 a e c str id )
(if
(and
(setq p1 (getpoint "\nFirst point for the line: "))
(setq p2 (getpoint "\nSecond point for the line: " p1))
(setq a (angle p1 p2))
); and
(progn
(setq e (entmakex (list (cons 0 "LINE")(cons 10 p1)(cons 11 p2))))
(setq c (mapcar '(lambda (a b) (/ (+ a b) 2.0)) p1 p2))
(setq str
(strcat
"%<\\AcObjProp.16.2 Object(%<\\_ObjId "
(setq id (Get-ObjectIDx64 (vlax-ename->vla-object e)))
">%).Length \\f \"%lu2%ds44%zs8%th32\">%"
)
)
(entmakex
(list
(cons 0 "MTEXT") (cons 100 "AcDbEntity") (cons 100 "AcDbMText") (cons 10 c)
(cons 40 (getvar 'textsize)) (cons 50 a) (cons 1 str) (cons 71 5)
)
)
)
)
(princ)
)
(defun Get-ObjectIDx64 (obj / util)
(setq util (vla-get-Utility (vla-get-activedocument (vlax-get-acad-object))))
(if (> (vl-string-search "x64" (getvar "platform")) 0)
(vlax-invoke-method util "GetObjectIdString" obj :vlax-False)
(itoa (vla-get-Objectid obj))
)
)
I get this instead: