Kean Walmsley

  • About the Author
    Kean on Google+

April 2014

Sun Mon Tue Wed Thu Fri Sat
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30      

« A handy tool for migrating ObjectARX code to work with AutoCAD 2007 and beyond | Main | Cleaning up after yourself: how and when to dispose of AutoCAD objects in .NET »

June 13, 2008

AutoCAD .NET version of the ObjectARX BlockView sample

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;

... becomes...

  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();

... becomes...

  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.

Function Descriptions



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.

File->AcGsDevice Config

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

View->Render Mode

Allows you to switch the rendering mode.

View->View Style

Allows you to change the view style of the GraphicsSystem.View. It has the same options as the SHADEMODE command.

Tools->ReMap Colors->Custom

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:



TrackBack URL for this entry:

Listed below are links to weblogs that reference AutoCAD .NET version of the ObjectARX BlockView sample:

blog comments powered by Disqus

10 Random Posts