Jump to content

Recommended Posts

Posted
(defun c:bm ()

  
;code;;;;;;;;

  (setq s (car(entsel)))
  (if s
    (progn

      (setq ar (vlax-ename->vla-object s))
      (setq area (vla-get-Area ar))
      (setq p (getpoint "\nselect point"))

      (entmakex
	(list
	  (cons 0 "MTEXT")
	  (cons 100 "AcDbEntity")
	  (cons 100 "AcDbMText")
	  (cons 10 p)
	  (cons 40 0.3)
	  (cons 71 5)
	  (cons	1
		(strcat	"%<\\AcObjProp.16.2 Object(%<\\_ObjId "
			(itoa (vla-get-objectid ar))
			">%).Area \\f \"%lu2%pr2%ps\">%"
		)

	  )
	  (cons 7 "Standard")
	  (cons 73 1)
	)
      )
    )					; end progn
  )

;code;;;;;;;;


  
)

This part of the code displays the object area as: &lt;\AcObjProp.16.2 Object(%&lt;\_ObjId 2401165245680&gt;%).Area \f "%lu2%pr2%ps" in AutoCAD model space. If you double-click on the text, it will show the object area. (example 100.00)

Posted (edited)

If you wish to entmake a field, you need to also entmake the FIELD entity within the TEXT entry of the ACAD_FIELD dictionary found within the extension dictionary attached to the entity - this is theoretically possible, but a lot of work and wheel reinvention.

 

Instead, if you either create the MText object using vla-addmtext or convert the MTEXT entity into a VLA object and set the textstring property to a field expression, the CAD platform will automatically parse the field expression and configure the corresponding dictionaries for you.

Edited by Lee Mac
  • Like 1
  • Thanks 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...