Getting Started
About
Create .NET managed applications with 2D/3D graphics that manages(Import/export) a big range of formats and geometrical shapes
How to Use
Add VectorDraw Nuget package to your .NET managed Application.
Can be used in Framework 4.x and above projects(6.x , 7.x , 8.x , 9.x ...).
In the nuget package manager browse for "vectordraw.drawing" select the "VectorDraw.Drawing.Framework.Net-4.x" or "VectorDraw.Drawing.Framework.Net-6.x" latest version and click install.
The VectorDraw.Drawing.Framework.Net-4.x package Supports Windows 10 and above x64/x86 Platform target.
The VectorDraw.Drawing.Framework.Net-6.x package Supports Windows 10 and above x64 Platform target.
The Assembly file names in this documantation are based on the 4.x version
The VectorDraw.Drawing.Framework.Net-6.x applies as well with the same namespaces and class names but all types are referenced to the VectorDraw.Core.6.dll assembly file.
Browse the following controls and components for the one that suits your needs and start using it in your application.
vdFramedControl
VectorDrawBaseControl
vdScrollableControl
vdPropertyGrid
vdCommandLine
vdDocumentComponent
vdConverter
vdRayComponent
vdIFCComponent
vdColorCombo
vdLayersCombo
vdLinetypeCombo
vdLineWeightCombo
See the following examples for quick start using
Notes About accessing the vdDocument object
Generally you need to handle the vdDocument object to manage the drawing and its entities,
The vdDocument object is the central hub for all drawing-related operations in VectorDraw Professional.
It also handles
- File I/O operations (like: Open , Save),
- External references (Xrefs),
- undo/redo history,
- Event handling.
- Methods to update the view after any change in the document like Redraw
- Manages collections of layout entities, layers, blocks, dimensions, text styles, line types, and other drawing elements
You can access the vdDocument object through the ActiveDocument property of the control you are using, for example:
- VectorDrawBaseControl.ActiveDocument
- vdScrollableControl.BaseControl.ActiveDocument
- vdFramedControl.BaseControl.ActiveDocument
- vdDocumentComponent.Document
Examples
Check some examples below that will help you start.
- Open Visual Studio 2022 and create a new Windows Forms App project (for .Net core 6x and up)
-or Windows Forms App(.NET Framework) for .Net Framework 4.x - In the nuget package manager browse for "vectordraw.drawing" select the "VectorDraw.Drawing.Framework.Net-6.x"
-or "VectorDraw.Drawing.Framework.Net-4.x", depend on your project type you selected and click install. - add the code snippets below to your project and run it to see the results.
Example 1
View and Edit Drawings inside a 'Windows Forms App':
using System;
using System.Windows.Forms;
namespace WindowsFormsApp1
{
internal static class Program
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
public partial class Form1 : Form
{
vdControls.vdFramedControl vd = new vdControls.vdFramedControl();
public Form1()
{
vd.Dock = DockStyle.Fill;
this.Controls.Add(vd);
this.WindowState = FormWindowState.Maximized;
}
}
}
Example 2
Create simple entities and save to a drawing inside a 'Windows Forms App':
using System;
using System.Windows.Forms;
using VectorDraw.Professional.ActionUtilities;
using VectorDraw.Professional.vdFigures;
using VectorDraw.Professional.vdObjects;
namespace WindowsFormsApp1
{
internal static class Program
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
public partial class Form1 : Form
{
vdControls.vdFramedControl vd = new vdControls.vdFramedControl();
public Form1()
{
vd.Dock = DockStyle.Fill;
this.Controls.Add(vd);
this.WindowState = FormWindowState.Maximized;
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
vdDocument doc = vd.BaseControl.ActiveDocument;
doc.New();//clear the document and initialize it to the defualt state with empty model entities
//create a new vdline
vdLine line1 = new vdLine(doc, new VectorDraw.Geometry.gPoint(0, 0, 0), new VectorDraw.Geometry.gPoint(2, 2, 0));
doc.Model.Entities.AddItem(line1);
vdCircle circle = new vdCircle(doc, new VectorDraw.Geometry.gPoint(1, 1, 0), 1.0);
doc.Model.Entities.AddItem(circle);
doc.ZoomExtents();
doc.Redraw(false);
//opens the Save dialog and prompts the user to select a file type to save the drawing
bool success = vdCommandAction.SaveAsEx(doc);
//alternate save it direct to a file type in local dist
//bool success = doc.SaveAs(System.IO.Path.GetDirectoryName(Application.ExecutablePath) + @"/vectordraw.pdf");
}
}
}
Example 3
Create blocks layers textstyles and add entities references them:
using System;
using System.Drawing;
using System.Windows.Forms;
using VectorDraw.Geometry;
using VectorDraw.Professional.Constants;
using VectorDraw.Professional.vdFigures;
using VectorDraw.Professional.vdObjects;
namespace WindowsFormsApp1
{
internal static class Program
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
public partial class Form1 : Form
{
vdControls.vdFramedControl vd = new vdControls.vdFramedControl();
public Form1()
{
vd.Dock = DockStyle.Fill;
this.Controls.Add(vd);
this.WindowState = FormWindowState.Maximized;
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
vdDocument document = vd.BaseControl.ActiveDocument;
//create some layers and set some of their properties
var layreblocks = document.Layers.Add("LayerBlocks");
layreblocks.PenColor = new vdColor(Color.FromArgb(255, 0, 0));
var layerrects = document.Layers.Add("LayerRects");
layerrects.PenColor = new vdColor(Color.FromArgb(0, 255, 0));
//create a text style
var textstyle = document.TextStyles.Add("MyTextStyle");
textstyle.FontFile = "Arial";
//create a block with some entities inside and set the entities color to byblock
var myblock = document.Blocks.Add("MyBlockName");
var circle = new vdCircle(document, new gPoint(), 2.5);
circle.PenColor = new vdColor(vdColor.ColorType.ByBlock);
var text = new vdText(document, "VectorDraw", new gPoint(0.0, 0.0, 0.0), 0.5, VdConstHorJust.VdTextHorCenter, VdConstVerJust.VdTextVerCen, textstyle);
text.PenColor = new vdColor(vdColor.ColorType.ByBlock);
myblock.Entities.AddItem(circle);
myblock.Entities.AddItem(text);
//set active layer to the layer of blocks so next entities will be on this layer
//altlernatively we could set the layer of the entities to the layer of blocks
document.ActiveLayer = layreblocks;
vdInsert ins1 = new vdInsert(document, myblock, new gPoint(-2.5, 0.0, 0.0), 0.0, 1.0, 1.0, 1.0);
vdInsert ins2 = new vdInsert(document, myblock, new gPoint(2.5, 0.0, 0.0), 0.0, 1.0, 1.0, 1.0);
//add the inserts to the model entities
document.Model.Entities.AddItem(ins1);
document.Model.Entities.AddItem(ins2);
//set active layer to the layer of rects and add a rect to the model entities
document.ActiveLayer = layerrects;
var rect = new vdRect(document, new gPoint(-5, -2.5), 10, 5, 0);
rect.LineWeight = VdConstLineWeight.LW_60;
document.Model.Entities.AddItem(rect);
//set the view size to be able to see all the entities we added
document.ZoomExtents();
//post a redraw to update the view
document.Redraw(false);
}
}
}
Example 4
Create 3d entities inside a 'Windows Form App':
using System;
using System.Windows.Forms;
using VectorDraw.Professional.vdFigures;
using VectorDraw.Professional.vdObjects;
namespace WindowsFormsApp1
{
internal static class Program
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
public partial class Form1 : Form
{
vdControls.vdFramedControl vd = new vdControls.vdFramedControl();
public Form1()
{
vd.Dock = DockStyle.Fill;
this.Controls.Add(vd);
this.WindowState = FormWindowState.Maximized;
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
vdDocument doc = vd.BaseControl.ActiveDocument;
doc.New();//clear the document and initialize it to the defualt state with empty model entities
//create a new cube
vdPolyface cube = new vdPolyface(doc);
cube.CreateBox(new VectorDraw.Geometry.gPoint(0, 0, 0), 4, 4, 4, 0);
//create a cylider represent the hole
vdPolyface cylider = new vdPolyface(doc);
cylider.CreateCone(new VectorDraw.Geometry.gPoint(2, 2, -1), 2, 2, 6, 16);
//subtruct the cylider from the cube to a new object entitiy
vdPolyface result = new vdPolyface(doc);
result.CombinePolyfacesEx(cube, cylider, BooleanOperation.Substraction);
//add the entitity to the document
doc.Model.Entities.AddItem(result);
//shading the result in NorthEast view
doc.RenderMode = VectorDraw.Render.vdRender.Mode.Shade;
doc.CommandAction.View3D("VINE");
doc.Redraw(false);
}
}
}
Example 5
Open IFC documents inside a 'Windows Form App':
using VectorDraw.Professional.vdObjects;
namespace WinFormsApp1
{
internal static class Program
{
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
}
public partial class Form1 : Form
{
vdControls.vdFramedControl vd = new();
vdIFC.vdIFCComponent iFC = new vdIFC.vdIFCComponent();
public Form1()
{
vd.Dock = DockStyle.Fill;
this.Controls.Add(vd);
this.WindowState = FormWindowState.Maximized;
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
vdDocument doc = vd.BaseControl.ActiveDocument;
//begin an open file dialog prompting the user to select an IFC file from local disk
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "IFC files (*.ifc)|*.ifc|All files (*.*)|*.*";
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
string filePath = openFileDialog.FileName;
bool success = doc.Open(filePath);
if (success)
{
doc.ZoomExtents();
//select the first entity in the model(which is an vdIFCDocument project) and redraw the document
vd.vdGrid.SelectedObject = doc.Model.Entities[0];
doc.Redraw(false);
}
}
}
}
}
Add License to your application's executables
Registered/Authorized users must also add VectorDraw Licence to their Applications.
The license is added to the application by vdLic.exe and using the serial both provided by VectorDraw.
If the license is not present then the package works in evaluation mode for 180 days.
Edit the build events of your Application and add the following command to the PostBuildEvent of your .csproj file : $(VDRAWDEV)vdlic.exe $(TargetPath)
Example of the .csproj file with the license command added to the PostBuildEvent and also to the Publish event for ClickOnce deployment:
<Target Name = "PostBuild" AfterTargets="PostBuildEvent">
<Exec Command = "$(VDRAWDEV)vdlic.exe" "$(TargetPath)" />
</Target >
<Target Name="AddPayloadsFolder" AfterTargets="Publish">
<Exec Command = "$(VDRAWDEV)vdlic.exe" "$(PublishDir)$(targetfilename)" />
</Target >
Localization
VectorDraw supports localization and can be used in different languages.
This can be done by using our tamplate example under ResourcesLocalization folder named vdFormsRes.
It contains all the resources for forms, menus ,command names, messages, icons, and object property names for display in vdPropertyGrid.
This project produce a dll that can be placed to your application folder.
You can build multi language dlls and load the suitable one based on the user language.
Disribution
See our online Distribution for more details about how to distribute your application with VectorDraw components.
Key Features
- View Edit Print Export 2D and 3D Drawings with various formats .vds , .vdml , .vdcl , .dwg , .dxf , .pdf , .dgn , .ifc , .dwf , .skp , .stl , .obj , .dae , .stp , .step , .las , .laz , .sat , .svg , .hpg, .emf , .wmf , .vdf , .vdi , .jpg , .bmp , .png , .gif , .tif , .ico
- High performance rendering and memory managment
- .dwg/.dxf like formatted object model
- Import/Export many CAD and raster formats; dwg dgn dxf pdf ifc skp obj dae stl dwf emf wmf hpg Images (bmp jpg png gif tif ico) native VectorDraw (vdml vdcl vds ) Only exported (svg hpgl) Only imported (las laz step stp)
- Predefined commands with user actions
- Rich user interaction: selection, osnaps, grips
- Touch screen supported
- Design and object customization
- OpenGL supported for 3D rendering
- Printing with large resolutions and paper sizes supported
- Geomertic utility function
- 3D boolean operations
- Easy distribution with side-by-side installation support for .NET applications
- WPF component also supported
- COM developer enviroments Support
- Linux 64-bit side-by-side with Mono installed
- Designed to be supported by web services
- Web canvas control for browsers that support the HTML5 canvas element; WebGL also supported for 3D rendering
Visit VectorDraw Quick Review for a Quick Review of VectorDraw components.