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
Posted (edited)
;;;;;;;;;;;;;;;;;;;;;;;;;;;

(setq mtext
        (vla-AddMText
          mspace
          (vlax-3d-point pt)
          0.0  ; width (0 for default)
          (strcat "%<\\AcObjProp.16.2 Object(%<\\_ObjId "
                  (itoa (vla-get-ObjectID entity))
                  ">%).Area \\f \"%lu2%pr2%ps\">%")
        )
      )
      
      ;; Set properties
      (vla-put-Layer mtext "mtext")
      (vla-put-Height mtext 0.3)
      (vla-put-AttachmentPoint mtext 5) ; Middle-center
      (vla-put-InsertionPoint mtext (vlax-3d-point pt))
      (vla-put-StyleName mtext "Standard")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

I am replacing entmakex with vla-addmtext and have completed the task.   I want to apply various text properties, such as bold, underline, color, style, height, etc.............................thank...........................

Edited by maahee
Posted

Another simple way is to entmake the mtext with a plain content first, then apply entmod DXF1 with field expression for the mtext.

  • Dislike 1
Posted

... have you tested that...

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...