In this tutorial, you will configure a C# or VB.NET project for a console application and use ImageGear .NET CAD capabilities. You will also learn how to open a DWG, DXF, or DGN file, rasterize it, and save it as a new image.
The following tutorial refers specifically to 64-bit installations; for 32-bit installations:
- Your project should already be set to compile to target Debug and x86, and you should have the directory:
$YOURLOCALPROJ\bin\x86\Debug\.
- Throughout these instructions, replace x64 with x86.
- The 32-bit ImageGear binaries are found in $INSTALLDIR\Bin\x86
Using the desired version of Visual Studio (2010 or later):
- Create a new "Console Application" project, using C# or VB.NET, and name the project: my_first_CAD_project
- If you installed ImageGear .NET 64-bit, using the Configuration Manager, create a new project platform (if you don't have one already) for x64. Make sure your project is set to compile targeting Debug and x64. Confirm you now have $YOURLOCALPROJ\bin\x64\Debug\, and if it's not there, create it.
- Add references and required resources into your projects in one of the following ways:
- Copy all files (and folders) inside $INSTALLDIR\Bin\x64 to your local output bin directory in your project (i.e., $YOURLOCALPROJ\bin\x64\Debug\ ).
- Add the following references to your project from $YOURLOCALPROJ\bin\x64\Debug\:
- ImageGear.Core.dll
- ImageGear.Evaluation.dll
- ImageGear.Formats.Common.dll
- ImageGear.Formats.Vector.dll
Your output target directory should be set to $YOURLOCALPROJ\bin\x64\Debug\ .
- At this point all necessary assembly references and resources have been added to the project. The following code snippet can be used to load a CAD file, and save it as an image. Make sure to replace C:\PATHTOCAD\ with your own CAD file name and path:
- Now, let's go over some of the important areas in the sample code with more detail. To initialize and support processing of DWG, DXF, and DGN files we need:
- There is one main data structure that is used in this sample code: The ImGearCADPage that holds the loaded CAD file.
- You can save the loaded CAD page to an image using:
This sample project was created as a simple introduction to using the CAD functionality in ImageGear. For systems designed for production environments, you need to configure your projects more efficiently by only adding the resources that you need. For more information, refer to Deploying Your Product.