Jump to content
CloudJack

Separate Mtext to individual text

Recommended Posts

CloudJack

Currently, I have an Excel table. Numbers of column contains 0 or 1.

1213.jpg

I have to copy column by column into notepad and then copy the notepad contain to CAD.

After that, I have serval individual column of Mtext. Then I further explode them into text.

A numbers of individual text are pasted on CAD and this is what I want.

However, if I do copy multiple column into notepad, the result is a whole Mtext which is containing all columns. I explode the Mtext and I will obtain multiple line of text.

I am searching for a lisp to convert/separate Mtext to individual text.

123.jpg

For more advance, I want these 1 and 0 located in different destination point from excel to CAD by a lisp.

Share this post


Link to post
Share on other sites
Happy Hobbit

I found this somewhere, the user copies text from Excel or Word for example. The user invokes the PSTSP command & the text gets pasted as individual text items. I've changed it slightly to capitalise the text:

 

(defun c:PSTSP (/ _GetClipBoardText ent_last last_ent pt str)
(vl-load-com)
 (defun _GetClipBoardText (/ htmlfile result)
   (setq result
          (vlax-invoke
            (vlax-get
              (vlax-get
                (setq htmlfile (vlax-create-object "htmlfile"))
                'ParentWindow
              )
              'ClipBoardData
            )
            'GetData
            "Text"
          )
   )
   (vlax-release-object htmlfile)
   result
 )

 (if (not (setq ent_last (entlast)))
   (progn
     (entmake '(
                (0 . "POINT")
                (100 . "AcDbEntity")
                (100 . "AcDbPoint")
                (10 . (0.0 0.0 0.0))
               )
     )
     (setq ent_last (entlast)
           last_ent ent_last
     )
   )
 )
 (if (and (setq str (_GETCLIPBOARDTEXT))
          (setq pt (getpoint "\nSpecify text start point: "))
     )
   (progn
     (setq str (strcase str))
     (entmake (list
                '(0 . "MTEXT")
                '(100 . "AcDbEntity")
                '(100 . "AcDbMText")
                (cons 10 pt)
                (cons 1 str)
              )
     )
     
     (command "_.explode" "_L")
   )
 )
 (if last_ent
   (entdel last_ent)
 )
 (princ)
)

Share this post


Link to post
Share on other sites
CloudJack

Thank you!

However, I would like to do this:

124213.jpg

If I copy muliple column in Excel, the result is left one.

I want the right instead of left.

Each 1 and 0 should be seperated text.

Share this post


Link to post
Share on other sites
BIGAL

There are lots of examples of read excel file into Autocad via each individual cell as say a text value. Have a search here for "excel", you do not need a intermediate step via notepad etc.

 

There was something maybe last week will try to find.

Share this post


Link to post
Share on other sites
rlx

This tool may have what you want : http://www.cadtutor.net/forum/showthread.php?93900-VT-atrribute-amp-text-editor-RLX

 

 

Follow instructions (rename vt.lsp to vt.vlx and then use (load "vt.vlx") ...)

 

 

When you start the command press space or R-mouse to start quick menu and select function PasteSpec. Rest should be easy.

 

 

gr. Rlx

Share this post


Link to post
Share on other sites
CloudJack

Thank you BIGAL and rlx!!

I found Lee Mac: http://www.lee-mac.com/readcsv.html and I am successful to use this to make as individual text.

 

rlx, I tried your lisp. It is quite powerful lisp.

However, I want more code example to study how to write a lisp for a task.

 

By the way, thank you all a lot!

Share this post


Link to post
Share on other sites
rlx
Thank you BIGAL and rlx!!

I found Lee Mac: http://www.lee-mac.com/readcsv.html and I am successful to use this to make as individual text.

 

rlx, I tried your lisp. It is quite powerful lisp.

However, I want more code example to study how to write a lisp for a task.

 

By the way, thank you all a lot!

 

 

 

 

You're welcome , see also link below , last part of lsp has the excel code

 

 

http://www.cadtutor.net/forum/showthread.php?93959-VT-Attribute-amp-text-editor-lsp-amp-dcl

 

 

Gr. Rlx

Edited by rlx

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×