Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to create a set of folders + rename and repath files

6 REPLIES 6
Reply
Message 1 of 7
landscapeplanners
952 Views, 6 Replies

How to create a set of folders + rename and repath files

Hi all

I was wondering how to create a set of folders based on my template folder structure, rename the drawing files to include the project number and repath them - ideally with a script as I can understand them!

For example:

_I have a master template folder structure which is pre-populated with empty template drawing files. The drawing files are contained in folders called 'Work' and 'Sheet'.

_'Work' folder containing drawing files named XXXXX_TEXT.dwg, XXXXX_HATCH.dwg, etc

_'Sheet' folder with drawing files named XXXXX_L001.dwg, XXXXX_L002.dwg, etc

_The drawing files in the 'Work' folder are xref'd into the drawing files in the 'Sheet' folder as overlay with relative paths

I want to:

1. deploy a copy of the master template folder structure to a specific location on the network
2. rename the root folder from 'Template_MasterFolderStructure' to '12345_ProjectName' or whatever the new project number and name is
3. rename the files in both 'Work' and 'Sheet' folders to replace XXXXX with the project number ie 12345
4. repath the xrefs accordingly

I'm not sure if this is even possible with a script. I appreciate any pointers.

Thank you

Paul

6 REPLIES 6
Message 2 of 7
Anonymous
in reply to: landscapeplanners

Hi,


There are lots of ways of doing this.

 

One approach is to write a program in a language such as VB.NET or C#.Net to perform the whole task from inside the AutoCAD environment.

 

Another is to use the operating system (CMD file) to do part of the task and an AutoCAD script file for the rest.

 

 

Your CMD file would copy the source folder with XCOPY, then rename the files as required.

 

How to do the renaming can be found at lots of places on the web.  One is:

http://www.computing.net/answers/dos/rename-multiple-file/16725.html

which has CMD code to rename all the files in a folder.

 

Then your CMD file would start up AutoCAD and open the various files changing the Xref paths as required.

 

 

 

 

Message 3 of 7
landscapeplanners
in reply to: Anonymous

Hi Laurie

Thanks for the quick response.

 

I'll have to do a bit of reading and get my head around the options you provided - but another piece of info I probably should have provided is that this is not a one off scenario. I will need to do this for every new project.

 

So my ideal solution will be a little gui that pops up and asks for the NEW PROJECT NUMBER and NETWORK LOCATION and applies this info to create, rename and repath

 

Thanks again. I'm researching VB.NET and C++ now

 

Paul

Message 4 of 7

OK I've learnt something already! Not much I know but exciting for me....wrote a little routine using the xcopy command to create a new directory and copy files and folders from an existing directory into the new one...

 

What I'm wondering now is how to customise this so I can use it many times to create a new directory without having to edit the syntax of the routine each time....is this where VBA comes in?

Message 5 of 7

OK so I've got the first part of the puzzle done. I have a script that can copy the template folder structure:

 

Start
CMD /c

xcopy "C:\Users\Paul Stafford\Documents\AutoCAD\XXXXX" "C:\Users\Paul Stafford\Documents\AutoCAD\ZZZZZ" /i /s

 

But because I want to use this many times I would have to edit the syntax to change the destination each time I deployed another new project.

 

What I want to do is have a GUI pop up requiring user input for 2 pieces of information:

 

1. Project Number

2. Destination

 

And be able to re-use the Project Number later to rename the files in the folder structure - but I'll worry about that later.

 

So how do I create a GUI? VBA?

 

Thanks

Paul

Message 6 of 7

You need to write a DCL file to define the look of your dialog box, then write a lisp file with commands to interface with the DCL file you wrote.

 

A google search for "autocad dcl tutorial" will give you plenty to look at.

Message 7 of 7

DosLIB is invaluable to me for just such applications.  I find it EXTREMELY useful & if you have any Autolisp background you can find functions in DosLIB that have all the features you are asking for.  You don't even need to use DCL to define your own GUI since it is likely possible to use the GUI features DosLIB provides.

 

Cheers,

Sean

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost