kurlytoenail Posted December 8, 2015 Posted December 8, 2015 Hi there. First post. I'm working on a huge plant upgrade project and very soon we will start to generate 3000+ drawings. I have created a drawing template and this is composed of multiple blocks with various attributes attached to each. Each drawing will share the same blocks, however, the attribute values are vastly different. I have messed around with the attout & attin commands and these work very well when dealing with one drawing at a time. I'm looking to speed things up a bit by automating the data import (from xls) using a batch & script combo that pulls the data from the spreadsheet located on my c:\ First of all, is this possible (hopefully I have explained clearly)? Secondly, I have minimal experience working with script files. I've used basic commands in the past to do multi edits for text attributes and so on. What command can I use in the script file to extract data from the xls file? I have a code for the bat file that can be used to process a specified folder but I'm really struggling with the scr side of things. Any help would be massively appreciated. Please advise if any further info is required... P.s. I've scanned the internet and found many similar-type problems but none quite the same. Most of the tutorials are based on inputting the same data into multiple drawings. Quote
kurlytoenail Posted December 8, 2015 Author Posted December 8, 2015 Additionally, would it be better to implement using VBA? Quote
BIGAL Posted December 9, 2015 Posted December 9, 2015 If you write down what you are doing every step then that is a script eg Open dwg1 (load "Excel1)(load "do Excel2") close Y. Using vba or lisp you can directly read a excel file getting an individual cell value. Can you provide some more info what your excel would contain a few lines, a image of your title block or dwg and what you are trying to change which way. Quote
dbroada Posted December 9, 2015 Posted December 9, 2015 I was quite proficient at scripts and often used them in preference to VBA/LISP BUT they do not offer any error trapping. If for any reason the fed value is not what was expected (an empty cell, a comma in the wrong place etc.) the whole script can go out of sync. For that reason I would not use a script for 3000+ drawings. Quote
YZ Posted December 10, 2015 Posted December 10, 2015 It is conceivable that you could format a large spreadsheet dataset to copy and paste into a script file, and then run that script manually. Or you could use a batch file to extract the script from the spreadsheet and then open AutoCAD and run the new script. The difficult thing (from an AutoCAD perspective) is the batch file to control Excel. As far as I know there is not a script command that can pull data out of an Excel file. (But that does not mean there isn't one). Generally a script can do whatever you can do manually in a command line. Find the command to get the data you want by typing, and you've found how to do it in a script file. Quote
kurlytoenail Posted December 10, 2015 Author Posted December 10, 2015 looptemplate1.dwg I've used a VBA tool in the past (via vbaide) but had no involvement in the development of the tool and the code was password protected. The generic files attached show some of the data I'm looking to insert into the cad drawings. It doesn't have to be blocks, maybe just insert text? or perhaps a macro field? Thanks so far guys. loop template data.xlsx Quote
YZ Posted December 15, 2015 Posted December 15, 2015 You could create another sheet on your spreadsheet called "script". Then write the script down the page in the first column, one command at a time. For the variables (attributes in the blocks) then reference across to the corresponding cell in the first row. Build it in a way that can have a select box where you choose from a dropdown which "Drg No" you want. Set it up so that drop down on the script tab populates all the rows in the table tab. Then copy and paste the rows of the script tab, one for each drop down item. Paste into a notepad or equivalent, save as looptemplate.scr or something into a support or known folder, then run a macro ^C^CScript;KnownFolder/LoopTemplate.scr one for each row. Once you have that working, then there are DEFINTELY ways you could harness Windows automation functionality, even perhaps in Excel itself to loop through that process on mass. 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.