Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Writing dwg's to a zip file.

  1. #1
    Active Member
    Join Date
    2002-05
    Posts
    72
    Login to Give a bone
    0

    Question Writing dwg's to a zip file.

    I'm gathering information before I start writing a routine that will be like pack'n'go. Basically I will be archiving a number of drawing files, possible a few image files, and a ctb file. I can easily write each package to it's own directory, however writing them to a zip file would be far more elegant. Does anyone have any information on writing files to a zip file that would get me started?

    Thanks in advance,

    Kelly

  2. #2
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,096
    Login to Give a bone
    0

    Default Re: Writing dwg's to a zip file.

    This Tek-Tips Forum thread discusses how to add files to a compressed files.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  3. #3
    Active Member
    Join Date
    2002-05
    Posts
    72
    Login to Give a bone
    0

    Default Re: Writing dwg's to a zip file.

    That's exactly what I was looking for. Thank you very much!

  4. #4
    I could stop if I wanted to Comach's Avatar
    Join Date
    2005-03
    Location
    Scotland
    Posts
    286
    Login to Give a bone
    0

    Default Re: Writing dwg's to a zip file.

    Quote Originally Posted by kdayman View Post
    I'm gathering information before I start writing a routine that will be like pack'n'go. Basically I will be archiving a number of drawing files, possible a few image files, and a ctb file. I can easily write each package to it's own directory, however writing them to a zip file would be far more elegant. Does anyone have any information on writing files to a zip file that would get me started?

    Thanks in advance,

    Kelly
    Is there any reason why you would not wish to use 'eTransmit'?

    You can select any number of drawings/files to the package and save this to a zip file.

  5. #5
    Active Member
    Join Date
    2002-05
    Posts
    72
    Login to Give a bone
    0

    Default Re: Writing dwg's to a zip file.

    Quote Originally Posted by hughrjt View Post
    Is there any reason why you would not wish to use 'eTransmit'?

    You can select any number of drawings/files to the package and save this to a zip file.
    We have some clients that have very specific requests (these are saved in an SQL DB) and as part of our Quality Management ISO Certification we write what file files were sent when and by who to the DB. eTransmit just doesn't cut it.

    I have been able to write the contents of a directory to a zip file. Here is the basic method I'm using:

    Code:
    Public Sub testzip0()
        MakeZip ("C:\test.zip")
        AddDirToZip ("C:\test.zip"), ("C:\temp")
    End Sub
    
    Function MakeZip(Path)
        Set FSO = CreateObject("Scripting.FileSystemObject")
        Set ts = FSO.OpenTextFile(Path, 8, vbTrue)
        BlankZip = "PK" & Chr(5) & Chr(6)
        For X = 0 To 17
        BlankZip = BlankZip & Chr(0)
        Next
        ts.Write BlankZip
        Set objFolder = Nothing
        Set objShell = Nothing
        Set FSO = Nothing
        Set ts = Nothing
     End Function
    
    Function AddDirToZip(ZipFile, Dir)
        Set objApp = CreateObject("Shell.Application")
        objApp.NameSpace(ZipFile).CopyHere objApp.NameSpace(Dir).Items
    End Function
    However I would like to write individual files to the zip file, it not turning out to be as easy as I thought.

    Any ideas???

    Last edited by Opie; 2008-07-29 at 05:40 PM. Reason: [CODE] tags added, see Moderator Note

  6. #6
    I could stop if I wanted to Comach's Avatar
    Join Date
    2005-03
    Location
    Scotland
    Posts
    286
    Login to Give a bone
    0

    Default Re: Writing dwg's to a zip file.

    Quote Originally Posted by kdayman View Post
    We have some clients that have very specific requests (these are saved in an SQL DB) and as part of our Quality Management ISO Certification we write what file files were sent when and by who to the DB. eTransmit just doesn't cut it.
    I am not sure that I can help you further with this. I am bit surprised that you could not work with the etransmit as this does give you the option to add individual files and also to add additional Notes to the transmittal which could be used to record details of the sender.

    Anyway I wish you success with your endeavours.

  7. #7
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,397
    Login to Give a bone
    0

    Default Re: Writing dwg's to a zip file.

    Do you have any 3D party zip software installed other than windows compressed folders? They sometimes have command line versions that you can script.
    C:> ED WORKING....

  8. #8
    Active Member
    Join Date
    2002-05
    Posts
    72
    Login to Give a bone
    0

    Default Re: Writing dwg's to a zip file.

    Got it working, here is the code...

    Code:
    Public Function AddFileToZip(ZipName, FileToZip)
        Dim FSO As Object
        Dim oApp As Object
        If Dir(ZipName) = "" Then
            Open ZipName For Output As #1
            Print #1, Chr$(80) & Chr$(75) & Chr$(5) & Chr$(6) & String(18, 0)
            Close #1
        End If
        Set oApp = CreateObject("Shell.Application")
        oApp.NameSpace(ZipName).CopyHere (FileToZip)
         'Keep script waiting until Compressing is done
        On Error Resume Next
        Do Until oApp.NameSpace(ZipName).Items.Count = 1
            Application.Wait (Now + TimeValue("0:00:01"))
        Loop
        On Error GoTo 0
        On Error Resume Next
        Set FSO = CreateObject("scripting.filesystemobject")
        FSO.DeleteFolder Environ("Temp") & "\Temporary Directory*", True
        Set oApp = Nothing
        Set FSO = Nothing
    End Function
    Thank you very much to everyone who replied to this post.

    I have however hit my next bump in the road, but I'll start a new post.

    Kelly

  9. #9
    Active Member
    Join Date
    2002-05
    Posts
    72
    Login to Give a bone
    0

    Default Re: Writing dwg's to a zip file.

    I've run into a problem, it works great for local files (on C:\ drive) however when I try with either the file to be zipped or the zip file being on a network drive I get:

    Run-time error '91':

    Object variable or With block variable not set
    on the following line:
    Code:
        oApp.NameSpace(ZipName).CopyHere (FileToZip)
    Any ideas???

  10. #10
    Active Member
    Join Date
    2002-05
    Posts
    72
    Login to Give a bone
    0

    Default Re: Writing dwg's to a zip file.

    I just had a thought, my developement machine is not on the network, however I have network drives that point to local folder. For example to see a P:\ drive I use the following dos command

    Code:
    subst P: C:\LocalP
    Could this be the problem? (I'm working remotely so I cannot connect to the network to verify this)
    Last edited by kdayman; 2008-08-07 at 10:52 PM. Reason: Fixed typo.

Page 1 of 2 12 LastLast

Similar Threads

  1. Writing a DXF file
    By meyekj in forum AutoLISP
    Replies: 5
    Last Post: 2008-06-13, 05:34 AM
  2. Problem writing to a file
    By ppirtle in forum Revit - API
    Replies: 3
    Last Post: 2008-02-15, 09:23 PM
  3. STC failure with error writing to backup file
    By Wes Macaulay in forum Revit - Worksharing/Worksets/Revit Server
    Replies: 6
    Last Post: 2007-10-03, 12:40 AM
  4. Writing to a text file
    By ewuensch in forum AutoLISP
    Replies: 4
    Last Post: 2007-02-22, 01:05 PM
  5. Replies: 1
    Last Post: 2005-08-13, 04:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •