Opening Drawings as Read-Only

Discussion in 'AutoCAD' started by mkaufhold, Nov 15, 2004.

  1. mkaufhold

    mkaufhold Guest

    Is there any easy way to open drawings as read-only with Lisp? I've attempted to go this route:

    (setq r (open fl3 "a"))
    (command "._open" fl3 "y")
    (close r)

    but it seems like my files don't always successfully close, and sometimes I end up with .dwg files at 0 kb. This is not my whole routine, but I'll post that if I need to. I was just wondering if maybe there was a better way to do this? I'm far from being an expert here, I'm self taught and still learning, so any help would be much appreciated. Thanks in advance!

    Marti
     
    mkaufhold, Nov 15, 2004
    #1
  2. mkaufhold

    Tom Smith Guest

    The open function in lisp has nothing to do with the Acad open command.

    The lisp function "opens a file for access by the AutoLISP I/O functions" as
    described in help. This is used for reading or writing text files. The
    available I/O functions are read-char, read-line, write-char, and
    write-line.

    You can open a drawing in lisp via (command "open" <drawingname>) but unless
    you have SDI set to 1, your lisp will terminate at the open command. If you
    want to do stuff in multiple files which involves opening and closing them,
    a script is probably what you need. If you'll describe what you're trying to
    do, someone can probably help.
     
    Tom Smith, Nov 15, 2004
    #2
  3. mkaufhold

    Tom Smith Guest

    Here's a routine which Jimmy Bergmark posted in September:

    (defun openRO (fna)
    (vla-activate (vla-open (vla-get-documents (vlax-get-acad-object)) fna
    :VLAX-TRUE))
    )

    Apparently you need the full pathname to the drawing file for this to work
     
    Tom Smith, Nov 15, 2004
    #3
  4. mkaufhold

    mkaufhold Guest

    What I am trying to do is create a routine that will read drawing names from a text file one by one, open each drawing and plot it. I think I have a pretty good handle on the rest of it, I'd just like all of the drawings to be opened read-only, as different people have different access to our network drives (some have write access and some will open all drawings as read-only anyway).

    No problem getting all the full path names, and my routine deals with SDI mode. Sorry to be such a beginner, but how would I use the code that you posted? Does that go within my routine or does it need to be separate? And do I use it as is or do I need to change any of it to work with what I have?

    Thanks so much for your help, I really appreciate it! =)

    Marti
     
    mkaufhold, Nov 15, 2004
    #4
  5. mkaufhold

    Tom Smith Guest

    That's called batch plotting. It's a very common task that nearly all
    offices need to perform, and there are many, many ways to do it without
    writing a program for the purpose.

    Acad has a built-in batch plot utility. You can also do it with the Publish
    command. Look them up in help.

    When you want to do things to multiple drawing, the natural way is to use a
    script, not a lisp function. Scripts are covered in help.

    If you have the 2000/2000i Migration Assistant, it included the ScriptPro
    utility which makes it easy to generate scripts for multiple drawings. I use
    an old shareware script generator which does about the same thing. There's
    no need for you to create a list of drawings in a text file, that's what the
    scripting utilities do for you.

    If there is a lisp function you want to run in multiple drawings, you should
    run it from a script. The script will be of the form

    open <drawing1>
    (load "mylisp")
    (c:mylisp)
    qsave
    open <drawing2>
    (load "mylisp")
    (c:mylisp)
    qsave
    ....
    etc.
     
    Tom Smith, Nov 15, 2004
    #5
  6. mkaufhold

    mkaufhold Guest

    Great. =)

    Thanks for the tips and all your time, Tom.
     
    mkaufhold, Nov 15, 2004
    #6
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.