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 :
4. 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 :