Jump to content
mousho

MTEXT FIELD

Recommended Posts

mousho

Hi to everyone

i use lisp to link mtext by field 

the problem is that it not show me the text 

only after i click the text it work

even "updatefield" not working beacause its not recognized it at field

i add the part of the lisp and the dwg

anyone can help me?

			(entmake 	(list 	
							(cons 0 "MTEXT") 
							(cons 100 "AcDbEntity")
							(cons 100 "AcDbMText")
							(cons 10 (nth 2 nks))	; First Insert point
							(cons 40 TxH)			; Text size
							(cons 50 0.0) 			; rotation
							(cons 1 (strcat "%<\\AcObjProp Object(%<\\_ObjId "
										(itoa (vla-get-ObjectID (vlax-ename->vla-object (entlast)))) 	">%).TextString>%"))
			))

 

new block.dwg

Share this post


Link to post
Share on other sites
mousho

hi tharwat

my field structure is right

the problem is that i need to "_mtedit" to see the field value and not the string

see pic above

Capture.PNG

new block.dwg

Share this post


Link to post
Share on other sites
Tharwat

Did you see the link that I posted earlier above?

Did you modify your codes accordingly ?

Share this post


Link to post
Share on other sites
mousho

hi thrwat

i did modify the code accordingly and it work for most of the code

the provlem is with that line

Quote

            (vla-put-textstring (vlax-ename->vla-object str)
                                        (strcat "%<\\AcObjProp Object(%<\\_ObjId "
                                        (itoa (vla-get-ObjectID (vlax-ename->vla-object (entlast))))     ">%).TextString>%"))

the entlast should be the earliear picking and not the last.

how can i select the last TEXT or the entlast before?

Share this post


Link to post
Share on other sites
Tharwat

As long as you selected the Text entity earlier so that means you already have it assigned to a variable, so use this variable instead of the function 'entlast' that you used into the field codes.

You can post your codes if you are not able to solve this minor issue.

Share this post


Link to post
Share on other sites
Tharwat

Here is an example to work with the selected Text object and not Mtext object.

(if (and (setq txt (car (entsel "\nSelect Text object :")))
         (or (= (cdr (assoc 0 (entget txt))) "TEXT")
             (alert "Invalid object. Try agian.")
             )
         (setq pnt (getpoint "\nSpecify insertion point for Field : "))
         (setq str (entmakex (list '(0 . "MTEXT") '(100 . "AcDbEntity") '(100 . "AcDbMText")
                                   (cons 40 12) ;; (cons 40 TxH) ; Text size
                                   (cons 50 0.0)
                                   (cons 10 pnt)
                                   '(1 . "")
                                   )
                             )
               )
         )
  (vla-put-textstring
    (vlax-ename->vla-object str)
    (strcat "%<\\AcObjProp Object(%<\\_ObjId "
            (_Get:Object:IdString (vlax-ename->vla-object txt)) ">%).TextString>%")
    )
  )
;;				;;
(defun _Get:Object:IdString (o / u)
  ;; _Gile
  (if (vlax-method-applicable-p (setq u (vla-get-Utility (vla-get-ActiveDocument (vlax-get-acad-object))
                )
        )
        'GetObjectIdString
      )
    (vla-GetObjectIdString u o :vlax-false)
    (itoa (vla-get-ObjectId o))
  )
)
							
						

 

Share this post


Link to post
Share on other sites

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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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