View Full Version : Script for Pasting Tables and Removing Overrides
mdemint
2008-06-19, 06:02 PM
I am trying to write a script that will:
1) Paste Special > AutoCAD Entity
2) Remove All Property Overrides
3) Scale 70% of original size.
When I use this script, I will have a table copied to the clipboard from Excel. I'm kinda new to writing scripts. Anyways, any help would be greatly appreciated!
-Mark
I am trying to write a script that will:
1) Paste Special > AutoCAD Entity
2) Remove All Property Overrides
3) Scale 70% of original size.
When I use this script, I will have a table copied to the clipboard from Excel. I'm kinda new to writing scripts. Anyways, any help would be greatly appreciated!
-Mark
You may need to elaborate, I'm not sure I (we) understand what you're doing.
To where are you pasting (Paste Special), in AutoCAD?
What AutoCAD entity? (blocks with attributes, regular geometry etc?)
What properties are you trying to get? (attribute info, other properties?)
Scale what at 70%, the table? the ACAD entity?
Maybe you could walk us through it, maybe post an example?
mdemint
2008-06-20, 09:43 PM
I apologize for being vague.
1) Into AutoCAD Civil 3D Land Desktop Companion 2008
2) In Microsoft Excel, select a group of cells and select Edit > Copy. Then go into AutoCAD with that selection of cells in the clipboard and select Edit > Paste Special > AutoCAD Entities. This will bring it in as a Table Object (If you do a normal Paste, it will come in as an OLE object; this is not desirable for me). Pasting it in at 0,0 will suffice; I can change it later if I want it to be pasted in off to the side.
3) When you Right-Click on the Table Object in AutoCAD 2008+ there is an option to Remove All Property Overrides. This feature will remove any formatting that you had with the selected grouping of cells in Microsoft Excel prior to the copy/paste (i.e. borders, shading, font, etc).
4) I wish to use the Quick Select > Previous command in AutoCAD to select the Table Object that [we] pasted into AutoCAD. After selecting said table I want to run the SCALE command and enter a value of 0.7.
I hope this helps explain a little better. Let me know if you have any questions or if this is even possible.
FYI - the command bar does not list the command for Remove All Property Overrides after it is selected... so I really have no idea what the command for this would be.
irneb
2008-06-23, 05:42 PM
As for point 2, PastePec has no command line equivalent. Maybe using a keystroke generator - I'm not sure if there is something out there. It would be something like a grwrite function.
For point 3, obtain a pointer to the last entity created. Eg. (setq en (entlast)). Then use the vla methods to clear overrides:(setq eo (vlax-ename->vla-object en))
(vla-ClearTableStyleOverrides eo 0) ;To clear all overrides
;; 1 for only table overrides
;; 2 for all cell overrides
For point 4 you could then use the reference you obtained previously as a selection for the scale command:(command "_scale" en "" "0,0" 0.7)
As for point 2, PastePec has no command line equivalent.
._pastespec gets you to the dialog but not sure how you could select "AutoCAD entities"?
If you enter through it, "" you get "Microsoft Office Word Document" ?
mdemint
2008-06-23, 08:21 PM
._pastespec gets you to the dialog but not sure how you could select "AutoCAD entities"?
If you enter through it, "" you get "Microsoft Office Word Document" ?
I'm not sure if this would work, but can you have the script type "A" then <ENTER> after using the _pastespec command?
Typing "A" will select "Autocad Entity" instead of "Microsoft Office Excel 2003 Worksheet." Again, I'm not sure if this is possible since I don't know LISP very well.
irneb
2008-06-24, 07:09 AM
Yes, but the problem is you can't send that "A" and "\R" from LISP directly. Seeing as it's not a part of the command line - you need something else to virtually send the keystroke through windows as if the user typed the keys. I don't know how you can do this through AutoLisp.
Either that, or you write an entire new LISP program looking into the clipboard and creating the table from that. I just think that's an enormous overkill.
mdemint
2008-06-26, 07:09 PM
Okay...I guess it's not a huge deal... but it would have saved some time for me. Thanks for the help.
irneb
2008-06-28, 11:35 AM
I'm not "extremely" sure that this is the scenario you're trying:
Select & copy portion from an Excel file
Run the script to paste as table into several AutoCAD DWGs
The scrip should then tweak the table after pasting
Save drawing and repeat from step 2.If this is the case, then could I suggest performing one paste special into one of your drawings, modifying according to preference. Then Copy from there and run a script for the other drawings using PASTEORIG to place the same table, at the same position, with the same modifications, in all the drawings?
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.