Identifying the user who has opened the drawing file

By Virupaksha Aithal
You can use API “Autodesk.AutoCAD.ApplicationServices. Application.GetWhoHasInfo” API to identify the user who has opened the specified drawing file. The WhoHasInfo object returned contains the same information that is displayed by the WHOHAS command.

[CommandMethod("WhoHasInfoTest")]
public static void WhoHasInfoTest()
{
    WhoHasInfo info = Application.GetWhoHasInfo("c:\dwg\test.dwg");
 
    Document doc = Application.DocumentManager.MdiActiveDocument;
    Editor ed = doc.Editor;
 
    if (info.IsFileLocked)
    {
        ed.WriteMessage(info.ComputerName + " " 
                                            + info.UserName + "n");
    }
    else
    {
        ed.WriteMessage("File is not locked for editn");
    }
 
}

Comments

7 responses to “Identifying the user who has opened the drawing file”

  1. Hi Virupaksha.
    It’s interesting information.
    Thank you.

  2. James Maeding Avatar
    James Maeding

    this is the info in the dwl file right?
    I’d prefer to have a non-adesk based routine, similar to ours that gets dwg version by reading first 6 chars of the dwg in ascii. still a good tip though.

  3. Andrey and Owen – Yes this was spam comment. I had to delete your comments to remove it.
    Owen – Not sure why you say we’re ‘letting’ this spammer post comments. I’m flagging each one as spam when it comes in, but the spammers keep creating new accounts. Not sure what else I can do other than flag them as spam. (Maybe its better to say TypePad are ‘letting’ them keep posting). Maybe you know a better way – do tell :-)

  4. Oh, yes. Thank you James!
    DWL and DWL2 are contains the equal information, but in different formats. DWL – usual text and DWL2 – XML text.
    I never tried to open such files before. :)

  5. This one is always the same name and same URL, which should be easy to block. I’m not familiar with the TypePad platform, but on WordPress I can block specific comments or commenters by adding keywords to a comment blacklist.

  6. What can I say – I mark as spam, they keep coming back, I mark as spam …
    :-(

  7. They are persistent buggers. Irritating, too. :-\

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading