Non-DWG window in AutoCAD 2015

By Balaji Ramamoorthy

AutoCAD 2015 enables the creation of Non-DWG document window. The Non-DWG document window appears as a tab just as any other drawing window.

In this blog post, I have attached a C++ project to create a Non-DWG document window and demonstrate its usage.

To try it :

  1. Build the sample project using Visual Studio 2012 with Platform Toolset v110.

  2. Start AutoCAD 2015 and load the arx module.

  3. Run “ShowMyWnd” command. This command creates a Non-DWG document window that accepts user input for the dimensions of a chain link as shown here :

Non-DWG Window

 

 

 

 

 

 

 

 

  1. Create another drawing and run the “InsertLink” command. This command creates a chain link based on the values provided in the Non-DWG document window.

Now, here is a brief description of the steps to create a Non-DWG document window using C++ :

Step-1. Create a dialog class derived from CDialog. An MFC dialog can be created using the resource view of Visual Studio as usual.

Step-2. Create a custom document class derived from AcRxObject. This class will be used to hold the data that are specific to this document window. 

Step-3. Create a custom document window class derived from AcApDocWindow

  • Override the “onCreate” method to instantiate the dialog that is to be shown.

  • Override the “onLoad” method to associate the custom document created in step-2 with our document window class

  • Override the “onDestroy” method to perform cleanup such as deleting the dialog instance.

  • Override the “subRouteMessage” to perform resizing of the dialog when the document window size changes.

Step-4. Create a custom document window manager reactor derived from AcApDocWindowManagerReactor

  • Override the “documentWindowActivated” method to keep our custom document updated with the values provided in the dialog.

  • Override the “documentWindowCreated” method to get a pointer to our custom document window after its gets created

  • Override the “documentWindowDestroyed” method so we know when our custom document window is no longer valid.

In the attached sample, the steps to associate a custom document have been commented. AutoCAD 2015 at present becomes unstable if a custom document is associated with the custom document window. This behavior has been logged in our internal database for our engineering team to analyze. So the attached sample project now stores the document data in a helper class as static variables for the “InsertLink” command to access.

Here is the sample project :

Download NonDwgWindowSample


Comments

7 responses to “Non-DWG window in AutoCAD 2015”

  1. Mike Robertson Avatar
    Mike Robertson

    Is this functionality exposed via .NET also?

  2. Hi Mike,
    Yes, this is also exposed using AutoCAD .Net API using the “DocumentWindowCollection.AddDocumentWindow” method.
    Kean’s blog demonstrates it usage by loading an uri.
    http://through-the-interface.typepad.com/through_the_interface/2014/04/adding-a-web-page-as-a-document-tab-in-autocad-2015-using-net.html
    The other variant of the “AddDocumentWindow” can accept a “DocumentWindow”. A “WPFDocumentWindow” can be created and used as a document window.
    Regards,
    Balaji

  3. Hi Mike,
    I have created a blog post with a .Net sample
    http://adndevblog.typepad.com/autocad/2014/05/non-dwg-window-in-autocad-2015-using-net.html
    Regards,
    Balaji

  4. Very nice! Thanks for providing a C++ sample. I can think of several use cases.

  5. Hi Stephan,
    Thanks for the update.
    I am glad you are finding use cases for this feature.
    Regards,
    Balaji

  6. A special thanks for this informative post. I definitely learned new stuff here I wasn’t aware of !

  7. chris Avatar
    chris

    Thanks for the post Balaji.
    When I add a new non-DWG window to AutoCAD, I find that the window has to be closed first before exiting AutoCAD. Otherwise the application will hang. I don’t believe this has anything to do with your code but do you know why this is happening? I have noticed the same behaviour using the .NET API.

Leave a Reply to Stephan KaiserCancel reply

Discover more from Autodesk Developer Blog

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

Continue reading