Open version specific files in script

Discussion in 'AutoCAD' started by jlspartz, Jan 3, 2005.

  1. jlspartz

    jlspartz Guest

    I want to make a script to run through hundreds of thousands of drawings but just open the files which are in 2000 format and are not read-only (open by a user). How would I put that in my scripting?
     
    jlspartz, Jan 3, 2005
    #1
  2. jlspartz

    mattis Guest

    Here's a routine that will check a drawing before it's opened to find out if it is r2000 or not. If it's not r2000, it will return nil, else it will return T.

    (defun vercheck (file / line dwgver ver2000)
    (setq line (read-line file))
    (setq dwgver (substr rl 1 6))
    (close file)
    (if (= dwgver "AC1015")
    (setq ver2000 T)
    (setq ver2000 nil)
    )
    ver2000
    )
    (vercheck "c:\\somedwg.dwg")

    The read-only thing is a little trickier than that. Here's something that I've done, though not recommended by the programming pros. I created a fake-out routine that would define a command called "yes". Yeah, kind of lame, I know, but waiting for answers on the dicussion groups could take some time and I had to come up with something. Anyway, here's the routine.

    (defun c:yes ()
    (princ)
    )

    My script would look like this:

    open
    c:\drawing1.dwg
    yes
    (somefunction)
    zoom
    extents
    quit
    yes
    open
    c:\drawing2.dwg
    yes
    (somefunction)
    zoom
    extents
    quit
    yes
    open
    c:\drawing3.dwg
    yes
    (somefunction)
    zoom
    extents
    quit
    yes

    If a 'yes' is needed for the read-only prompt, one will be provided, otherwise, 'yes' is inputted in the command line and nothing happens which will keep the script running. For the script to continue to the next drawing, make sure that SDI mode is set to 1.
     
    mattis, Jan 4, 2005
    #2
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.