Need to open many dwg’s and run routine

Discussion in 'AutoCAD' started by mnelson, Apr 19, 2004.

  1. mnelson

    mnelson Guest

    I have the need to make a LSIP routine (Autocad 2002) that will open many dwg’s, perform its task and then close and open the next one. I’ve made routines before, but not the type to hit all dwg’s in a folder. Can anyone point me to some code that will do this or a website with some good info to get me started. You help is appreciated!

    Thanks
     
    mnelson, Apr 19, 2004
    #1
  2. mnelson

    Paul Turvill Guest

    You'll need to create a script file. For an example of a LISP routine that
    creates a script, and then operates on all drawings in a folder, see
    RESAVE.LSP at
    http://www.turvill.com/t2/free_stuff
    ___

    dwg's, perform its task and then close and open the next one.
     
    Paul Turvill, Apr 19, 2004
    #2
  3. mnelson

    Rudy Tovar Guest

    Adjust as you wish.

    (defun c:fsave (/ flist cn ofile)

    (setq flist (vl-directory-files "c:/details" "*.dwg"))

    (setq cn 0)

    (setq ofile (open "c:/flist.scr" "w")
    )
    (while (nth cn flist)
    (progn
    (write-line "open" ofile)
    (write-line (strcat (chr 34)"c:/details/"(nth cn flist)(chr 34))
    ofile)
    (write-line "saveas" ofile)
    (write-line "r14" ofile)
    (write-line "" ofile)
    (write-line "y" ofile)
    (write-line "close" ofile)
    (setq cn (1+ cn))
    )
    )
    (close ofile)
    (Princ)
    )
    --

    AUTODESK
    Authorized Developer
    www.Cadentity.com
    MASi


    dwg's, perform its task and then close and open the next one. I've made
    routines before, but not the type to hit all dwg's in a folder. Can anyone
    point me to some code that will do this or a website with some good info to
    get me started. You help is appreciated!
     
    Rudy Tovar, Apr 19, 2004
    #3
  4. mnelson

    mnelson Guest

    Excellent - This will certainly help me out a lot! It would also be nice to be able to open all DWG's in a folder and its sub folders too (now that I think about it). Any thoughts on that? Couldn't a full-blown LISP of some type handle this or is a script the best way to go?
     
    mnelson, Apr 19, 2004
    #4
  5. mnelson

    Rudy Tovar Guest

    Thats exactly what the utility does, but saves the drawings down to a
    different directory.

    Review the code, and adjust as you wish.

    --

    AUTODESK
    Authorized Developer
    www.Cadentity.com
    MASi

    to be able to open all DWG's in a folder and its sub folders too (now that I
    think about it). Any thoughts on that? Couldn't a full-blown LISP of some
    type handle this or is a script the best way to go?
     
    Rudy Tovar, Apr 19, 2004
    #5
  6. mnelson

    ECCAD Guest

    For multiple folders, check out EC-Batch
    at http://www.bobscadshop.com
    Also, demo available that does (5) files at a time.
    Bob Shaw
     
    ECCAD, Apr 19, 2004
    #6
  7. mnelson

    Gary J. Orr Guest

    Other posts indicate using a script file.. this will work, but you don't get
    to supply arguments in a script, so I recently built this exact type of lisp
    routine for AutoCAD 2004. It went something like this:

    1) create a lisp routine that does all of the tasks that you want done...
    2) create a lisp routine to call it...

    the second routine should include:
    1) a function that does the recursive loop (a search for recurse.lsp (I
    believe) will help there) into the subdirectories and builds a list of the
    qualifying drawings...
    2) a call to a new instance of AutoCAD r16 using the (vla-create-object
    "AutoCAD.Application.16"). Be sure to include the vla-put-visible in case of
    any required user interaction...
    3) create a loop to use the (vla-open...) utility to open each of the
    drawings in your list...
    4) use the (vla-send-command...) utility to send a load <your other lisp
    routine> command into each drawing, followed by (vla-send-command...) for
    any required command string(s)...
    5) use the (vla-get-isquiescent...) utility inside a while = "False" loop to
    hold further processing until the function is completed in the other
    drawing...
    6) check the read only status of the opened drawing and send save or saveas
    as required... then use the (vla-close...) utility, this can be done in one
    step if the drawing is not read only by setting the "True" option in
    vla-close...
    7) log the success/fail status if desired...
    8) open the next drawing...

    see, it's easy ;-). it only took about three days to figure it out, and look
    out for SDI mode.
    happy lisping (I forget where that came from).

    --
    Gary J. Orr
    CADD Administrator
    (218) 279-2421


    LHB, Inc
    21 West Superior Street, Suite 500
    Duluth, Mn 55802
    (218) 727-8446
    www.LHBcorp.com
    dwg's, perform its task and then close and open the next one. I've made
    routines before, but not the type to hit all dwg's in a folder. Can anyone
    point me to some code that will do this or a website with some good info to
    get me started. You help is appreciated!
     
    Gary J. Orr, Apr 20, 2004
    #7
  8. mnelson

    mnelson Guest

    Thanks again for the info everyone.
     
    mnelson, Apr 21, 2004
    #8
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.