Jump to content

Separate Mtext to individual text


CloudJack

Recommended Posts

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
Link to comment
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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

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