Insert Field into multiple mleaders/mtext objects

Insert Field into multiple mleaders/mtext objects

charles.langdaleUEXEH
Enthusiast Enthusiast
686 Views
4 Replies
Message 1 of 5

Insert Field into multiple mleaders/mtext objects

charles.langdaleUEXEH
Enthusiast
Enthusiast

Hi, 

 

I need to put a field into several instances of mleaders and mtext. I want to add the field after the word BOOK. My though was to do a find/replace but I'm not seeing a way to replace with a field. Is there a way to append a field for multiple text objects at the same time? 

 

Thanks for your help! 

0 Likes
Accepted solutions (1)
687 Views
4 Replies
Replies (4)
Message 2 of 5

AVCPlugins
Advisor
Advisor
Accepted solution

Create a new field in any text or attribute. Then look at and copy the field code from the field creation window (below). Then use this code as plain text for the find and replace command. AutoCAD recognizes that you have inserted not just text but a field code. You may also have to call _Regen.


Plugins for AutoCAD
A>V>C>
AppStore | Facebook | Twitter | YouTube | Blog
0 Likes
Message 3 of 5

paullimapa
Mentor
Mentor

Assume the entity (en) you found that has BOOK as text string then you save that like this:

(setq txtbook (vla-get-TextString (vlax-ename->vla-object en)))

Then assuming you want the Field object to be linked to another object's (obj) Text string value then it'll look like this format:

(setq txt(strcat txtbook "%<\\AcObjProp Object(%<\\_ObjId " (itoa(vla-get-ObjectID obj)) ">%).TextString \\f \"%tc1\">%"))

Now you would put this new combined txt string into the original entity (en) like this:

(vla-put-TextString (vlax-ename->vla-object en) txt)

lastly you could avoid a regen of the entire drawing screen by running the UpdateField command on just the entity (en):

(vl-cmdf"_.UpdateField" en "")

 

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 4 of 5

Sea-Haven
Mentor
Mentor

Dont forget every ID is individual so get an object and its ID when making the new string. As pointed out here.

(itoa(vla-get-ObjectID obj))

 

 

0 Likes
Message 5 of 5

charles.langdaleUEXEH
Enthusiast
Enthusiast

Brilliant, thank you 

0 Likes