Export mtext to excel for printing stickers

Export mtext to excel for printing stickers

Andrew1307
Enthusiast Enthusiast
1,918 Views
7 Replies
Message 1 of 8

Export mtext to excel for printing stickers

Andrew1307
Enthusiast
Enthusiast

I've been searching for longer than I care to admit and am surprised this isn't a solved problem.

 

We have nests of parts in Autocad, each with a mtext block as a label. We want to extract this information to then be usable by some printing software. Autocad (extract every mtext block) to Excel (each block as it's own row) to Dymo Label software is how I envision it.

 

All the existing lisp or vba code I find extract the mtext contents which has extra formatting syntax along with it. Is there an easy way to export just plain text from mtext blocks? I found some sample vba code that steps through every mtext block here https://forums.autodesk.com/t5/autocad-forum/export-mtext-contents/td-p/6266304 But that still leaves me with how to work with the syntax filled mtext contents.

0 Likes
1,919 Views
7 Replies
Replies (7)
Message 2 of 8

JTBWorld
Advisor
Advisor

That can be done. If interested getting a custom command created for you contact us


Jimmy Bergmark
JTB World - Software development and consulting for CAD and license usage reports
https://jtbworld.com

0 Likes
Message 3 of 8

grobnik
Collaborator
Collaborator

Hi @Andrew1307 ,

if you can attach a simple dwg to your post could be easy to do some tests with VBA code.

I exported several time blocks attribute and/or text-mtext from dwg to excel, and I would like to understand more what you are requiring.

Bye

0 Likes
Message 4 of 8

grobnik
Collaborator
Collaborator

Hi @Andrew1307 ,

After some test, without your specific case of course, seems that the text or mtext additional formatting special chars are inside a " { } " consequently, after the second closed " } " should be start the text contents, so should be very simple trap the " } " and extract the text contents.

In any case you can use debug and /or immediate windows, when using VBA development tools, and examine the text contents.

Here below some test code.

 

Sub MultilineTxt()
For Each Object In ThisDrawing.ModelSpace
    If TypeOf Object Is AcadMText Then
        Debug.Print Object.TextString
        texttoextract = InStr(2, Object.TextString, "}", vbBinaryCompare)
        Debug.Print Mid(Object.TextString, texttoextract + 1, Len(Object.TextString) - texttoextract + 1)
     End If
Next
End Sub

 

Unfortunately the Excel connection part of code it's missing but if you need I'll give you soon.

The above code it's only an example, there are no variable declarations, errors trap, and effettively check of type of MTEXT in the drawing, perhaps you have to extract only a particular MTEXT content, or something like as, try and let me know.

 

Regards

0 Likes
Message 5 of 8

grobnik
Collaborator
Collaborator

Hi @Andrew1307 ,

as alternative if my procedure doesn't work in your case, you can have a look to this LISP procedure.

http://www.lee-mac.com/unformatstring.html

 

Bye

0 Likes
Message 6 of 8

grobnik
Collaborator
Collaborator

Hi @Andrew1307 ,

as alternative if my procedure doesn't work in your case, you can have a look to this LISP procedure.

http://www.lee-mac.com/unformatstring.html

 

Bye

0 Likes
Message 7 of 8

Andrew1307
Enthusiast
Enthusiast

Hi thank you for the responses. I will try your test code soon and report back.

0 Likes
Message 8 of 8

tiwari1211
Enthusiast
Enthusiast
Hallo grobnik

Can you please provide the excel connection part. I have a macro i already shared with you in another msg. I am now able to export all the MText from it but is it like this.. \A1;{\W1;8920-4.2/2.4602/N06022\P2x}
I want only the MTEXT content to be exported. Thank for your help.
0 Likes