Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: Open all drawings read only

  1. #1
    Member
    Join Date
    2009-05
    Posts
    32
    Login to Give a bone
    0

    Default Open all drawings read only

    Alright, so I have this program I am using to extract information from a batch of AutoCAD drawings all at once. Sometimes people have the drawings open, other times they don't. when I generate the script, it verifies all the drawings as either being open at the time or closed at the time of the script creation. The script runs through all the drawings as long as those drawings that were open/closed when the script was created remain as so. However, if someone opens a drawing/closes a drawing during the process and the script comes to that drawing during that change, it will halt. Failure.

    My question is, would there be a command line switch, autoLISP, or some other modification I could make so that ALL DRAWINGS would be opened read-only? This way, regardless if they are open or not, it opens it read-only. I don't need to save changes to the drawings but I want to be able to open every drawing via commandline (for the script) without having any dialog boxes (so it doesn't halt). Any ideas? Thanks.

  2. #2
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,804
    Login to Give a bone
    0

    Default Re: Open all drawings read only

    The open method supports read-only.

    Code:
    
    (vl-load-com)
    (if (zerop (getvar "SDI"))
      (vlax-invoke-method
        (vla-get-documents (vlax-get-acad-object))
        'Open
        "C:\\mydrawing.dwg"
        :vlax-true
      )
    )
    
    R.K. McSwain | CAD Panacea |

  3. #3
    Member
    Join Date
    2009-05
    Posts
    32
    Login to Give a bone
    0

    Default Re: Open all drawings read only

    So there is no way to set up an opening method without defining the specific drawing to be opened within the open command? No way to redfine the _OPEN command to open as read-only regardless if it is open or not?

  4. #4
    Member
    Join Date
    2009-05
    Posts
    32
    Login to Give a bone
    0

    Default Re: Open all drawings read only

    What about WRITESTAT? (if (= (getvar "WRITESTAT") 1) (command "_OPEN" "Y")?

  5. #5
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,804
    Login to Give a bone
    0

    Default Re: Open all drawings read only

    Quote Originally Posted by aturgeon View Post
    No way to redfine the _OPEN command to open as read-only regardless if it is open or not?
    Like this?

    Code:
    
    (vl-load-com)
    (command "._undefine" "open")
    (defun C:open ()
      (setq fn (getfiled "Select Drawing" "" "dwg" 0))
      (if (zerop (getvar "SDI"))
        (vlax-invoke-method
          (vla-get-documents (vlax-get-acad-object))
          'Open
          fn
          :vlax-true
        )
      )
    )
    
    R.K. McSwain | CAD Panacea |

  6. #6
    Member
    Join Date
    2009-05
    Posts
    32
    Login to Give a bone
    0

    Default Re: Open all drawings read only

    Almost. Is there a way to suppress the dialog?

  7. #7
    Member
    Join Date
    2009-05
    Posts
    32
    Login to Give a bone
    0

    Default Re: Open all drawings read only

    Could you just use (getstring "") somewhere in the lisp to make it take on the value of the next input?

  8. #8
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,804
    Login to Give a bone
    0

    Default Re: Open all drawings read only

    Quote Originally Posted by aturgeon View Post
    Almost. Is there a way to suppress the dialog?
    That is what the first bit of code did...
    I'm confused now...
    R.K. McSwain | CAD Panacea |

  9. #9
    Member
    Join Date
    2009-05
    Posts
    32
    Login to Give a bone
    0

    Default Re: Open all drawings read only

    well i liked redefining the open command to always open read-only, but then I wanted to have it prompt for the next line (the drawing path and filename) to open that drawing read only. I modified it a bit to say:

    Code:
    (vl-load-com)
    (if (zerop (getvar "SDI"))
      (vlax-invoke-method
        (vla-get-documents (vlax-get-acad-object))
        'Open
        (getstring "")
        :vlax-true
      )
    )
    That hangs up because the automatically generated list produces file names in quotes.

    then I tried

    Code:
    (vl-load-com)
    (command "._undefine" "open")
    (defun C:open ()
      (if (zerop (getvar "SDI"))
        (vlax-invoke-method
          (vla-get-documents (vlax-get-acad-object))
          'Open
          (getstring "")
          :vlax-true
        )
      )
    )
    which works kinda, but then it returns to the host drawing (Drawing1) to run the script instead of the drawing it opened read-only...

    I'm confused as well... this batch script generator (Hurricane) doesn't seem to like my methods of trying to open things read-only. I can load the lisp into AutoCAD to redefine the OPEN command, but then it doesnt accept the filename in quotes.

    Maybe it can't be done this way and I am best off just putting the program on a user that has read-only access to drawings and then running the program from there. That way the script will open all the drawings up read-only as well as use the batch script generator correctly unless you can think of a way to modify the lisp. Thanks for all your effort though.
    Last edited by Opie; 2009-07-23 at 10:02 PM. Reason: fixed [code] tags

  10. #10
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,804
    Login to Give a bone
    0

    Default Re: Open all drawings read only

    Not sure why you are inserting the (getstring) in there.
    Get your filenames first, then feed them to the original function.

    Also, you can turn off smilies to avoid the smiley in your code, and the CODE tags are [code] and [/code]
    R.K. McSwain | CAD Panacea |

Page 1 of 2 12 LastLast

Similar Threads

  1. Open Read-Only: The ability to open a worksharing enabled file in a read only mode.
    By revit.wishlist1942 in forum Revit Architecture - Wish List
    Replies: 5
    Last Post: 2012-09-05, 07:02 PM
  2. Replies: 3
    Last Post: 2012-06-17, 09:42 PM
  3. Replies: 2
    Last Post: 2011-04-28, 02:04 AM
  4. Drawings open in Read-only
    By james.matuska in forum AutoCAD General
    Replies: 5
    Last Post: 2009-12-11, 11:34 PM
  5. Partial open drawings in Read-only mode
    By cgsodd in forum AutoLISP
    Replies: 2
    Last Post: 2007-04-19, 02:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •