Script Batch?

Discussion in 'AutoCAD' started by Jason Wilder, Feb 16, 2004.

  1. Jason Wilder

    Jason Wilder Guest

    Ok, I had an idea and wanted to get feedback before I go wasting a bunch of
    time.

    I have been considering building a routine in LISP - one I've done a long
    time ago - that will prompt for a selection of files through a dialogue box,
    then build a script file customized to a specific function. (i.e. DWF files,
    PLT files, 11x17 plotting, etc.)

    I thought I'd put the effort into using VBA to make a form interface that
    the user could simply select the files, then choose buttons (or listbox,
    whatnot) for the various options that would then be used to construct the
    SCR file. After which, the SCR would be executed.

    Which would mean I'd use the Open/Write/Close for external file writing in
    VBA, wrather than LISP. Here is where I get into a little bit of a snag, as
    I haven't done this alot. So, here is where I turn to you all for pointers.
    Also, if someone is willing to share code snippets for the Open/Write/Close,
    that'd obviously help.

    Or if there are other ideas or ways that I can control this process strictly
    through VBA? I thought of that, but wasn't certain where VBA stays loaded
    and if I would be able to continue to read a file list in order to
    open/(plot)/close a list of files.

    Thanks for any advice.
     
    Jason Wilder, Feb 16, 2004
    #1
  2. Stick to straight vba! Just make sure you are using MDI so the vba app
    stays loaded. Then keeping the first file open [default Drawing1, walk
    thru your process opening a drawing, processing it, close it, go to next
    one...
    ___________________________
    Mike Tuersley
    CADalyst's AutoCAD Clinic
    Rand IMAGINiT Technologies
     
    Mike Tuersley, Feb 17, 2004
    #2
  3. I experienced problems batch processing in MDI mode using ThisDrawing.Close
    I was told to use the close method of the documents collection by someone who said they had also experienced problems.
    I did not do this though as I decided it would be simpler to enforce SDI mode.

    The following is what I have previously posted for a similar question. It processes all drawings in a directory and requires being in SDI mode.

    ************************************************************************

    The following uses a reference to the Microsoft Scripting Runtime.

    Option Explicit
    Option Compare Text
    'With GetFolder path only use an ending \ for root e.g. "C:\", "C:\Temp"

    Public Sub Batch()
    Dim objFSO As Scripting.FileSystemObject
    Dim objFolder As Scripting.Folder
    Dim objFile As Scripting.File
    Set objFSO = New Scripting.FileSystemObject
    Set objFolder = objFSO.GetFolder(Path) 'Modify path to folder of drawings to be updated
    For Each objFile In objFolder.Files
    If objFile.Name Like "*.dwg" = True Then
    ThisDrawing.Open objFile.Path

    ThisDrawing.Save
    End If
    Next objFile
    ThisDrawing.New Path 'Modify path to a drawing template
    End Sub

    Regards - Nathan Taylor
     
    Nathan Taylor, Feb 17, 2004
    #3
  4. Jason Wilder

    Jason Wilder Guest

    Ok, looks to be a viable solution, but where does the Scripting.* object
    come from? When I tried to execute the code, it says a project or library
    is missing?

    who said they had also experienced problems.
    processes all drawings in a directory and requires being in SDI mode.
     
    Jason Wilder, Feb 17, 2004
    #4
  5. Jason Wilder

    Jason Wilder Guest

    Well, that's an enthusiastic answer. :)

    Now to see if I can muddle my way through to the solution. That is what I
    had in mind, now to just see if I can accomplish with and maintain my
    sanity.
     
    Jason Wilder, Feb 17, 2004
    #5
  6. That's how he is accessing the files.
     
    Mike Tuersley, Feb 17, 2004
    #6
  7. Jason Wilder

    Jason Wilder Guest

    I understand that, I think I know what is missing, which script type library
    do I add to my references list?

    When I begin to step through the code, it errors on the first Dim line:

    Dim objFSO As Scripting.FileSystemObject

    At this line it gives me - Compile Error: Can't find project or library.
     
    Jason Wilder, Feb 17, 2004
    #7
  8. Jason Wilder

    Mark Propst Guest

    Microsoft Scripting Runtime


     
    Mark Propst, Feb 17, 2004
    #8
  9. Nathan Taylor, Feb 17, 2004
    #9
  10. Do you wish to process all drawings in a directory like my example does, select only certain drawings from a directory or selects drawings across multiple directories.

    If you need extra info regarding this I should be able to help.

    Regards - Nathan
     
    Nathan Taylor, Feb 17, 2004
    #10
  11. Jason Wilder

    Jason Wilder Guest

    Let me start playing with this a bit to understand what it does.

    It would be nice if I can provide both options, a user can either select a
    directory for processing, or select certain files from within a directory.

    I'm not going to entertain spanning multiple just yet, until I get a better
    handle on this.

    select only certain drawings from a directory or selects drawings across
    multiple directories.
     
    Jason Wilder, Feb 18, 2004
    #11
  12. Jason Wilder

    Jason Wilder Guest

    That was the ticket, thanks Mark.

     
    Jason Wilder, Feb 18, 2004
    #12
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.