Possible? From Windows Explore, to open AutoCAD DWG file Read Only?

Discussion in 'AutoCAD' started by Dan, Sep 21, 2004.

  1. Dan

    Dan Guest

    Has anyone had experience modifying the righ-click menu to add "open as read
    only" option in the Windows Explore app?
     
    Dan, Sep 21, 2004
    #1
  2. Dan

    TomD Guest

    I've never tried such a thing, but possibly a VBScript that uses Windows
    Script Host to make it Read Only, then changes the file's property back
    after Acad has it open? (It could be assigned as an action for
    Explorer....I think)

    Just a thought.
     
    TomD, Sep 21, 2004
    #2
  3. Dan

    Dan Guest

    Looking into DDE right now....
    Researching...
    I'll post if I get an answer.
    Thanks,
    Dan
     
    Dan, Sep 21, 2004
    #3
  4. Dunno Dan??? Maybe because you have it open read only and are trying to
    compile it? I don't get that message when I compile - and thats the file
    I'm compiling

    -- Mike
    ___________________________
    Mike Tuersley
    CADalyst's CAD Clinic
    Rand IMAGINiT Technologies
    ___________________________
    the trick is to realize that there is no spoon...
     
    Mike Tuersley, Sep 22, 2004
    #4
  5. Dan

    Dan Guest

    I am using VB6, OPENREADONLY was just what I named the project. Are you
    using VB6, or Net? Can you compile it, and zip it up in an attachment?
     
    Dan, Sep 22, 2004
    #5
  6. Dan

    Dan Guest

    Update,
    The acad.exe process still starts, but does not finish opening a file read
    only.
    So I have yest to discover the problem.

    I tried to modify the lines:
    Set cadApp = GetObject("AutoCAD.Application")
    to
    Set cadApp = GetObject("AutoCAD.Application.16") 'researching the Help
    files-Still no luck

    So for now, I have written an old-school DOS batch file to open the file
    read-only and associated it with the extension into Explore, so I can
    right-click on a file, and select "Open As Read-Only" and then AutoCAD just
    prompts that the file is read-only, or in use, and I hit OK.

    Batch code:
    ATTRIB +R %1
    %1
    ATTRIB -R %1

    I would still like to make this a VB process, and eliminate the user from
    having to hit OK, thus by the drawing being opened via VB, and setting the
    option TRUE, but I still do not know why it isnt working yet. It looks
    good, but my experiance is limited.

    For what its work, I am using XPpro(SP1)/ACAD2k5
    Thanks again!
    Dan



    Untill then, the install progrm works great, and I created an old DOS batch
    file to open the drawing read
     
    Dan, Sep 23, 2004
    #6
  7. Dan

    Ed Jobe Guest

    I'm assuming you created the exe Mike gave you and it works but doesn't open
    the dwg. The exe takes a command line arg, which, when run by right clicking
    on a dwg in explorer, will be the path to the dwg. If you just try to run
    the exe, you are trying to run the Open command without suppying a file name
    and it will hang. This little app is designed to only be used by right
    clicking on a dwg.
     
    Ed Jobe, Sep 23, 2004
    #7
  8. Dan

    Dan Guest

    Correct, I understand that, and for some reason Ed, it will not open up the
    file. I cannot verify if the EXE is working properly other than ACAD does
    open up, partially, but I do not see the grphics screen, and the process is
    ran, but the file will not load. I have setp and compiled the .exe, and I am
    attempting to run from Explore through a right click. Thats Exactly how I
    setup the DOS Batch file until I get this working.

    Thanks,
    Dan
     
    Dan, Sep 23, 2004
    #8
  9. It is opening the file perfectly - you just can't see it =) I left out a
    line. After the End If and before the cadApp.Documents.Open..... add:

    cadApp.Visible = True

    As for changing the Acad.Application to a specfic number, that's up to you.
    As written, it'll open the last version of AutoCAD that was run *if* you
    are in a multi-install environment.

    As for compiling the installer, that you'll have to do because you're the
    only one who knows where the cad_file_opener EXE will be placed. FWIW the
    class mod compiles fine and I'm using the same setup as you -
    XPSP1/2005/VB6SP5. While I do use .NET mostly these days, this is not .NET
    code --- you can tell by how we access CAD. If it were .NET, Try..Catch
    loop would've been used.

    -- Mike
    ___________________________
    Mike Tuersley
    CADalyst's CAD Clinic
    Rand IMAGINiT Technologies
    ___________________________
    the trick is to realize that there is no spoon...
     
    Mike Tuersley, Sep 24, 2004
    #9
  10. Dan

    Dan Guest

    Great! That did the trick. Thank you very much Mike. I have learned so
    much from this group.
    The code is not compiled/installed/and working well. Others have mentioned
    this need, so I home many will be able to utilize the code you have kindly
    offered.
    Have a great week,
    Dan

    Final Code with addition:

    Option Explicit

    Sub Main()
    Dim msCommand As String
    msCommand = Command$()
    'Check to see if anything was there
    If msCommand <> "" Then
    Dim cadApp As Object
    On Error Resume Next
    Set cadApp = GetObject("AutoCAD.Application")
    If Err Then
    Err.Clear
    Set cadApp = CreateObject("AutoCAD.Application")
    Do
    Err.Clear
    Resume
    Loop While Err.Number = 429
    End If
    cadApp.Visible = True
    cadApp.Documents.Open msCommand, True
    cadApp = Nothing
    End If
    End Sub
     
    Dan, Sep 24, 2004
    #10
  11. Dan

    Dan Guest

    Update #2 Hope you have a sense of humor with me....I am learning, and was
    over eager.
    Just discovered ACAD was opening up in a new window each time, so I changed
    the following line:

    From:
    Set cadApp = GetObject("AutoCAD.Application")
    To:
    Set cadApp = GetObject(, "AutoCAD.Application")

    That made a difference for me.

    a HUGE thanks goes to Mike......AGAIN! Its people like him, that helps this
    industry grow, and become more efficient.

    Thanks, Dan

    Final Code with modifications (Take 2):

    Option Explicit

    Sub Main()
    Dim msCommand As String
    msCommand = Command$()
    'Check to see if anything was there
    If msCommand <> "" Then
    Dim cadApp As Object
    On Error Resume Next
    Set cadApp = GetObject(, "AutoCAD.Application")
    If Err Then
    Err.Clear
    Set cadApp = CreateObject("AutoCAD.Application")
    Do
    Err.Clear
    Resume
    Loop While Err.Number = 429
    End If
    cadApp.Visible = True
    cadApp.Documents.Open msCommand, True
    cadApp = Nothing
    End If
    End Sub
     
    Dan, Sep 24, 2004
    #11
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.