Guest Posted August 28, 2022 Posted August 28, 2022 Dear CADTutor, I'm developing this lisp routine to extract data from my dwg file and paste into excel file. Two questions: First question: is it possible to copy my string value output using lisp without having to copy manually everytime and pasting into excel? Second question: how do I paste one string and seperates in different cells in excel? I've used "\t" character but it outputs three spaces and pastes in one cell. Thanks. Quote
Steven P Posted August 28, 2022 Posted August 28, 2022 A quick answer This will copy ' --TEXTSTRING-- ' to the clipboard and you can then paste to a spreadsheet from there, this is perhaps the simplest solution though having to manually paste to excel add a little work (can also paste to wherever you want with this, a text editor, word processor, another drawing or wherever. CAD is off today, Sunday, but I think if you create your text string with a tab character in between 'cells' it might paste them into new cells - not something I have done though. Not sure about multiple lines. (vlax-invoke (vlax-get (vlax-get (vlax-create-object "htmlfile") 'ParentWindow) 'ClipBoardData) 'setData "TEXT" --TEXTSTRING-- ) You could also look at 'paste special' in excel, s there an option to paste CSV (comma separated values), and in that case you can create a temporary CSV file and paste that? Working with spreadsheets via AutoCAD.... a but tricky I understand but if you can save your text as a half way, like CSV it become a little easier but you need to do more work. 1 Quote
mhupp Posted August 28, 2022 Posted August 28, 2022 FYI if you don't release "htmlfile" it could so some funky things after multiple copies. ;;MP ;;http://www.theswamp.org/index.php?topic=21764.msg263322#msg263322 (defun _GetClipBoardText( / htmlfile result ) (vlax-invoke (vlax-get (vlax-get (setq htmlfile (vlax-create-object "htmlfile")) 'ParentWindow) 'ClipBoardData) 'GetData "Text")) (vlax-release-object htmlfile) ) 1 Quote
Steven P Posted August 28, 2022 Posted August 28, 2022 16 minutes ago, mhupp said: FYI if you don't release "htmlfile" it could so some funky things after multiple copies. Thanks, I'll change the code I copied that form in the morning Quote
BIGAL Posted August 29, 2022 Posted August 29, 2022 (edited) Still working on a expanded excel library functions so could do select text then select cell and it will PUT value direct not using clipboard. Stumbled on real nice get cell address. So if say make a list or selection set of text could do a multi PUT. For multi need extra question go right or down. Watch this space, very close. This is Acad / Bricscad asking excel to select a range and return the cell range. Big thanks to FIXO code unfortunately no longer with us did lots of excel stuff. So the get from is done Importing X and Y Coordinates for Custom made blocks from excel. - Autodesk Community - AutoCAD https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/importing-x-and-y-coordinates-for-custom-made-blocks-from-excel/td-p/11373585 Edited August 29, 2022 by BIGAL Quote
BIGAL Posted August 29, 2022 Posted August 29, 2022 (edited) Ok so back to this, Mudawarcad if you can provide a dwg and a matching xls then I will see what I can do. Need to know the rules like start at cell and go right and down etc for multi entry like rows and columns. Need to look at how your going to pick the text. Hmm Table to excel direct global function maybe do that first. Edited August 29, 2022 by BIGAL Quote
Guest Posted August 29, 2022 Posted August 29, 2022 Steven P and mhupp, answered my first question and the "\t" did work in these functions. Bigal, sounds very important but for the sake of little time, I'll check it out later. Thanks a lot everyone. Quote
Steven P Posted August 29, 2022 Posted August 29, 2022 (edited) . (Edited because I was saying the same as you) Edited August 29, 2022 by Steven P 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.