Fenton Webb, from DevTech Americas, has been beavering away on a .NET port of the ObjectARX BlockView sample (found on the ObjectARX SDK under samples/graphics/BlockView). Thanks, Fents! :-)
Here is the C# source project for Visual Studio 2005. To build it you will almost certainly need to remap the acdbmgd.dll and acmgd.dll assembly references in the project.
One important note: if you load this project and try to view the BlockViewDialog in the Visual Studio Designer, the Visual Studio application will almost certainly crash. This is because the Designer is attempting to load into the dialog the GsPreviewCtrl component which depends on AutoCAD (and therefore cannot be instantiated outside of the AutoCAD process). At least that's what appears to be happening.
To temporarily allow the dialog to load - so you can make changes to the dialog's menu, etc. - you will need to edit the C# code in the BlockViewDialog.Designer.cs file. There are two edits that are needed - one that declares a variable for the control (lines 650-651) and one that instantiates it (lines 107-108):
Comment out line 650 and uncomment line 651, so...
650 private GsPreviewCtrl mPreviewCtrl;
651 //private System.Windows.Forms.Panel mPreviewCtrl;
650 //private GsPreviewCtrl mPreviewCtrl;
651 private System.Windows.Forms.Panel mPreviewCtrl;
And do the same for lines 107 and 108, so...
107 //this.mPreviewCtrl = new System.Windows.Forms.Panel();
108 this.mPreviewCtrl = new GsPreviewCtrl();
107 this.mPreviewCtrl = new System.Windows.Forms.Panel();
108 //this.mPreviewCtrl = new GsPreviewCtrl();
Then the dialog should load properly in the Visual Studio Designer, with no crash (although you'll need to change the code back to the way it was to build the application, of course).
As for what the application does, here's the original sample's ReadMe, updated to reflect the new application's behaviour:
Block View Sample Readme
- NETLOAD the BlockView.NET.dll module
- Run command BView at the AutoCAD command line.
- Default operation is to display the current drawing using the current view settings of the current drawing.
Opens an existing drawing into the Block View dialog (by clearing the GraphicsSystem.View).
File->Output Image to Disk
Allows you to output a JPG;BMP;TIFF;PNG files as a snaphot of the current view shown in the BlockView dialog.
View or edit the current GraphicsSystem.Device configuration settings.
Allows Zoom Extents/Zoom Window/Zoom In-Out functionality
Allows the toggling of various GraphicsSystem.View settings such as Linetype/Material and Sectioning
Allows you to switch the rendering mode.
Allows you to change the view style of the GraphicsSystem.View. It has the same options as the SHADEMODE command.
Allows you to remap the color palette. This is particularily useful if you want to show a GraphicsSystem.View as a paperspace layout, with a white background. In this case you will need to remap white entities to appear in a different color.
Tools->ReMap Colors->Standard Colors
Restores the Color Palette back to the original one.
Tools->Add an Entity->To This Database
Adds an entity to the Model Space and adds to the GraphicsSystem.View.
Tools->Add an Entity->Temporary
Adds an entity just to the GraphicsSystem.View.
Here's a quick snapshot of the BlockView dialog with a conceptual view of the standard 3D view sample:
Head on over to the ADN DevBlog for an updated version of this sample for AutoCAD 2015 onwards.