mousho Posted April 5, 2021 Posted April 5, 2021 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 Quote
Tharwat Posted April 5, 2021 Posted April 5, 2021 This should give you the way to go with if your field structure is correct. https://www.cadtutor.net/forum/topic/72618-current-drawings-path-and-filename-in-autolisp/?tab=comments#comment-578985 2 Quote
mousho Posted April 5, 2021 Author Posted April 5, 2021 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 new block.dwg Quote
Tharwat Posted April 5, 2021 Posted April 5, 2021 Did you see the link that I posted earlier above? Did you modify your codes accordingly ? Quote
mousho Posted April 5, 2021 Author Posted April 5, 2021 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? Quote
Tharwat Posted April 5, 2021 Posted April 5, 2021 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. Quote
Tharwat Posted April 5, 2021 Posted April 5, 2021 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)) ) ) Quote
Recommended Posts
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.