Create a duplicatec/copy of current file with VBA?

Create a duplicatec/copy of current file with VBA?

aaron.wrightCPM6Y
Contributor Contributor
852 Views
2 Replies
Message 1 of 3

Create a duplicatec/copy of current file with VBA?

aaron.wrightCPM6Y
Contributor
Contributor

I'm writing a macro that should parse text in an AutoCAD drawing, and replace with other values. I already have the script for this.

 

However, I don't really want the original drawing affected. I essentially want to copy the drawing, and apply the rest of the script this copy, before saving the new drawing down.

 

I couldn't find anything from searching the forum. Can anyone assist with this? I'm a bit unfamiliar with VBA, particularly in AutoCAD.

0 Likes
Accepted solutions (1)
853 Views
2 Replies
Replies (2)
Message 2 of 3

norman.yuan
Mentor
Mentor
Accepted solution

Well, if you just think/do things as an AutoCAD user does, it would be rather simple thing to do: save current drawing as different name; or in Window explorer create a copy of the dwg file and open it:

 

Let's assume you have the original drawing open as active drawing in AutoCAD. You can:

 

1. Call ThisDrawing.SaveAs() to save it to a whatever name as you wish, then you can do anything with this drawing. Of course the original drawing is not opened in AutoCAD any more (you can open it with code, if needed).

 

or,

 

2. You can use FileCopy() method to create a copy of the original file (yes, you can still copy a file that is open in AutoCAD), giving it a different file name; then open it in AutoCAD and do anything with it.

 

I'd think 1 is easier.

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 3 of 3

aaron.wrightCPM6Y
Contributor
Contributor

Thank you! Just as you responded I was writing ThisDrawing.SaveAs().into my code Didn't really occur to me initially.

0 Likes