how to: export all drawings in a folder to bitmap or other format

Discussion in 'AutoCAD' started by vindimy, Oct 20, 2005.

  1. vindimy

    vindimy Guest

    here's the code i wrote when i needed a routine that could export all
    of my drawings into .bmp files... hope someone finds it useful.

    Sub exportAllBlocks()
    On Error GoTo Err_Control

    Dim strFolder As String, strSubFolder As String, intI As Integer
    Dim fso As Scripting.FileSystemObject, folder As Scripting.folder,
    file As Scripting.file
    Dim objDrawing As AcadDocument, objBlock As AcadBlock, objEntity As
    AcadEntity, selSet1 As AcadSelectionSet

    strFolder = "P:\s100127_bar scanner-cad
    integration\Working\symbols\dmitriy_18-oct-05\"
    strSubFolder = "P:\\s100127_bar scanner-cad
    integration\\Working\\symbols\\dmitriy_18-oct-05\\img\\"

    Set fso = New Scripting.FileSystemObject
    Set folder = fso.GetFolder(strFolder)

    'ThisDrawing.Close

    For Each file In folder.Files
    Set objDrawing = Application.Documents.Open(strFolder &
    file.Name)
    objDrawing.Activate

    Application.ZoomExtents

    objDrawing.SendCommand "(command " & Chr(34) & "export" &
    Chr(34) & " " & Chr(34) & strSubFolder & file.Name & ".bmp" & Chr(34) &
    " " & Chr(34) & "all" & Chr(34) & " " & Chr(34) & "" & Chr(34) & ")" &
    vbCr

    Application.ZoomExtents
    objDrawing.Save
    objDrawing.Close
    Next file

    MsgBox "Done!", vbOKOnly, "Done"

    Err_Control:
    If Err.Number <> 0 Then
    MsgBox "Error: " & Err.Description, vbCritical, Err.Number
    End If
    Exit Sub
    End Sub
     
    vindimy, Oct 20, 2005
    #1
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.