This provides you with the fastest way to use CADability with Microsoft Visual Studio
Getting started
If you use the Microsoft Visual Studio it is very easy to integrate CADability into your application following these steps:
- Add a reference to CADability to your application. In the "solution explorer" right click on "References" and select "Add Reference". In the following dialog select the "Browse" tab and select the CADability.dll file. The default installation directory is C:\Program Files\SOFA\CADability. Press the OK button
- In the Tools menu of the Visual Studio select "Choose Toolbox Items ..." and use the "Browse" button to select CADability.dll. After that you will find "CADability.CADControl". Drag this control onto your form and place it according to your requests.
- Use the properties of the CADControl to control the appearance of the control in the runtime. Use the properties ShowControlCenter, ShowMenu and ShowToolBars to show or hide the corresponding user interface items.
- Run your program. You will see the selected user interface items placed around the display area of CADability. The display area will be empty and only show the coordinate plane.
- To open a file use the corresponding menu or toolbar button. You may also use the ShowFile method to display a file.
Additional tips
To see all of the loaded model or drawing on the display area use the
ZoomToModelExtent method.
cadControl1.ShowFile(filename, "dxf");
ModelView mv = cadControl1.Frame.ActiveView as ModelView;
mv.ZoomToModelExtent(cadControl1.ClientRectangle, 1.0);
To gain access to the Model
which is contained in the open project use:
Project pr = cadControl1.Frame.Project;
Model m = pr.GetActiveModel();
foreach (IGeoObject go in m)
{
// do something with go
}