Jump to content

Saving a drawing plus a subdirectory to a new drive


BIGAL

Recommended Posts

We have the situation that running large jobs over our network becomes painfully slow. (please all those IT people we can not change the network 1500 users)

 

To get around this we copy the job to our local drive the job creates a database of info as well as the DWG.

 

What we want is a saveas option

1 copy drawing back to server (can do with new menu command)

 

2 copies a subdirectory to the network as well (part of new menu command)

 

The first can be done through Autocad now but the second we must use explorer etc and rely on operator remembering to do.

 

I had a look at using external commands through shelling to the OS and hinted at in the Acad.pgp file but can not get it to quite work using a copy command and a script.

 

VBA may be better option any suggestions.

Link to comment
Share on other sites

Further to my prior request tried editing the menu file changed ^c^c_saveas to ^c^c_saveas explorer

 

ie run save autocad then pop up explorer window, saveas works but no explorer any ideas maybe just missing a slash or semicolon etc

Link to comment
Share on other sites

Another thought can someone provide the code to copy a file d:\myjobs\test to P:\jobno\design from within Autocad. Lisp or vba ok

 

The file name will change but this can be read from the Autocad drawing open.

Link to comment
Share on other sites

Thank you thats exactly what I was looking for.

 

The extra options are good check for existing etc

 

It also showed me do the simple thing first, check the VBA help entering "file copy" locates that command.

Link to comment
Share on other sites

  • 1 month later...

Thank you for the information recieved but now I have another problem I need to use a wild card ie copy multifiles in one go using the *.* option does not work .

 

Filecopy only seems to work with 1 file at a time I have now discovered that the software creates extra files depending on the type of job so you really dont know exactly how many to copy.

Here is a bit of the code which does work but not with *.*

 

civ3dfile = "*.*"

SourceFile = newdatadrive + "\Civil 3D Projects\" + JOBNO + "\" + JOBNO + "-data\Advroads\" + civ3dfile

 

 

DestinationFile = "P:\" + JOBNO + "\design\" + JOBNO + "-data\Advroads\" + civ3dfile

 

FileCopy SourceFile, DestinationFile

 

Any help would be appreciated

Link to comment
Share on other sites

Any one watching this found the answer You need a loop that looks at the directory and using Dir(filename) pulls each file name out and then copies it.

Link to comment
Share on other sites

  • 1 year later...

hope this helps

 

you just need a form to enter the "jobno" and directory letter (newdatadrive)

 

Private Sub commandbutton1_Click()
Dim newdatadrive As String
Dim jobno As String
Dim MyPath, MyName, checkfile
Dim SourceFile, DestinationFile As String
Dim civ3dfile As String
jobno = projectno.Value
newdatadrive = datadrive.Value + ":"
coggfilecopy1.Hide
'check to see if current drawing
currentdwgname = ThisDrawing.GetVariable("Dwgname") 'noofchar = Len(currentdwgname)
currentdwgname = Mid$(currentdwgname, 1, 7) 'only need 1st 7 characters
'MsgBox "dwg name" & currentdwgname
If currentdwgname = jobno Then
MsgBox "You can not save the drawing if you have it open" & (Chr(13)) & "Please close and try again"
GoTo COGGEND
End If
checkfile = "P:\" + jobno + "\Design\" + jobno + "-data\"
'How to determine if a file exists in a folder:
If Dir(checkfile, vbDirectory) = "" Then
'makenewdir
MsgBox "Directory does not exist now making"
MkDir "P:\" + jobno + "\Design\" + jobno + "-data"
MkDir "P:\" + jobno + "\Design\" + jobno + "-data\Advroads\"
Else
MsgBox "Directory found now continue" & checkfile
End If
' Define source file name D:\Civil 3D Projects\jobno\jobno.dwg.
SourceFile = newdatadrive + "\Civil 3D Projects\" + jobno + "\" + jobno + ".dwg"
' Define target file name.
DestinationFile = "P:\" + jobno + "\design\" + jobno + ".dwg"
'copy file
MsgBox "file copied " & DestinationFile
FileCopy SourceFile, DestinationFile
' Display the names in C:\ that represent directories.
MyPath = newdatadrive + "\Civil 3D Projects\" + jobno + "\" + jobno + "-data\Advroads\"    ' Set the path.
'myname = Dir(Mypath, vbDirectory) '1st entry
MyName = Dir(MyPath)               '2nd entry 1st is .. not needed
Do While MyName <> ""    ' Start the loop.
SourceFile = newdatadrive + "\Civil 3D Projects\" + jobno + "\" + jobno + "-data\Advroads\" + MyName   ' Define source file name D:\Civil 3D Projects\2006100\2006100.dwg.
DestinationFile = "P:\" + jobno + "\design\" + jobno + "-data\Advroads\" + MyName    ' Define source file name D:\Civil 3D Projects\2006100\2006100.dwg.
FileCopy SourceFile, DestinationFile
MsgBox "file copied " & MyName
MyName = Dir    ' Get next entry.
Loop  'end of loop

GoTo COGGEND
notright:
MsgBox "enter a job no or data drive"
frmcoggfilecopy1.Show
COGGEND:
End Sub

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...