DGKC Control Documentation


Skip Navigation Links.
Start page
Quick Start
Search Page
Installation
What is new
Licensing
Collapse ModelsModels
Models
Persistence
Model Properties
Collapse EntitiesEntities
Collapse GeometryGeometry
Geometry
Collapse BRepBRep
BRep Overview
BRep Geometry
Shapes
Curves
Surfaces
Faces
Wires
Edges
Compounds
Collapse MeshMesh
Mesh Geometry
Mesh
BRep to Mesh Conversion
Curve Geometry
Line Strips
Point Sets
Overlays
Collapse AttributesAttributes
Local Frame
Appearance
Texture
Properties of an Entity
Collapse Model ItemsModel Items
Items
3D Text
Smart Labels
View Points
Collapse MeasurementsMeasurements
Measurements
Persistent Measurements
Grid
Collapse Operations and AlgorithmsOperations and Algorithms
Boolean Operations
Euclidean Shortest Path
Collapse MovementMovement
Movements
Kinematic Entities
Collision Detection
Collapse Import/ExportImport/Export
Import/Export Overview
Data Flow Sample
STL Tree
Collapse DG Kernel ControlDG Kernel Control
DG Kernel Control
Collapse Properies, Methods, EventsProperies, Methods, Events
Properies
Methods
Events
Collapse Interactive FunctionalityInteractive Functionality
View
Context Menu
Measurements
Direct User Access
Modes of DGKC
Current Entities
Overlay
Collapse Selection OverviewSelection Overview
Selection
Selection Event
Collapse Auxiliary ViewsAuxiliary Views
Model Explorer
Birds Eye View
Full Screen window
Collapse Programmatic FunctionalityProgrammatic Functionality
Programming
Queries
Collapse Core TypesCore Types
Enums
PointDg
VectDg
Line2DDg
PairIntDg
T2DDg
LineDg
PlaneDg
RangeDg
RectangleDg
BoxDg
RegistryDg
Object Construction
Generator
Component Context
Initialisation Context
Collapse API ReferenceAPI Reference
Interface List
Vector Space
Collapse General GeometryGeneral Geometry
IPointArray_DG
IPointMatrix_DG
IPointCloud_DG
Collapse CurvesCurves
ICurve_DG
ILine_DG
ICircle_DG
IEllipse_DG
IBSplineCurve_DG
IBSplineCurveInterpolator_DG
ICurveFreeForm_DG
IArcSpline3DCurve_DG
Collapse 2D2D
ICurve2d_DG
IBSplineCurve2d_DG
ICircle2d_DG
ILine2d_DG
IArc_DG
Collapse SurfacesSurfaces
IUVSurface_DG
IPartialSplineProps_DG
IBSplineSurface_DG
IBezierSurface_DG
IPartialBezierProps_DG
IRectangularTrimmedSurface_DG
ISurfaceOfRevolution_DG
Collapse Oriented ObjectsOriented Objects
IObjectOriented_DG
IPlane_DG
ISphere_DG
ICylinder_DG
ICone_DG
ITorus_DG
IBox_DG
IPolygon3D_DG
IGeometricObject_DG
Collapse GeneralGeneral
IElement_DG
IStrip_DG
Collapse ModelModel
IModel_DG
Collapse EntitiesEntities
IEntity_DG
IEntityArray_DG
IStdShape_DG
IStdShapeRef_DG
IDraw_DG
IEntity2d_DG
IModel2d_DG
Collapse GeometryGeometry
IGeometry_DG
IPointSetGeometry_DG
ISegmentStripGeometry_DG
ICurveGeometry_DG
ISurfacePoint_DG
ISurfacePointArray_DG
ILabel_DG
ILabelGeometry_DG
ISticky_DG
Collapse BSpline BRep GeometryBSpline BRep Geometry
Collapse Advanced AlgorithmsAdvanced Algorithms
IBRepChamfer_DG
IBRepDraftAngle_DG
IBRepFillet_DG
IFeaturePrism_DG
IBRepShape_DG
IBRepVertex_DG
IBRepEdge_DG
IBRepWire_DG
IBRepFace_DG
IBRepShell_DG
IBRepSolid_DG
IBRepCompositeSolid_DG
IBRepCompound_DG
IShapeArray_DG
IBRepBuilderEx_DG
IWireArrayToSurfaceBuilder_DG
IBRepGeometry_DG
IBRepBuilder_DG
Collapse Mesh GeometryMesh Geometry
IMesh_DG
IMeshGeometry_DG
IVertex_DG
IVertexSegment_DG
ISimplex_DG
IMeshPoint_DG
IMeshAlgor_DG
IDiffSurface_DG
Collapse AppearenceAppearence
IAppearance_DG
IMaterial_DG
ITexture_DG
ILineStyle_DG
Collapse MovementMovement
Collapse Collision DetectionCollision Detection
IMetrics_DG
IPathCollisionDetector_DG
IKinematicEntity_DG
IMove_DG
IKinematicSet_DG
ICutEffect_DG
ISpinEffect_DG
IConstraint_DG
Collapse ItemsItems
IModelItem_DG
IItemArray_DG
IDynamicScreenItem_DG
IDynamicScreenItemManager_DG
ISmartLabelManager_DG
Collapse Import / ExportImport / Export
IDataContext_DG
ISTLDataContext_DG
Collapse Operations and AgorithmsOperations and Agorithms
IBooleanEntity_DG
IEuclideanShortestPath_DG
Collapse User DataUser Data
IUserData_DG
Collapse ViewView
IView_DG
ISelection_DG
IScene_DG
ILighting_DG
ILightSource_DG
IViewPoint_DG
IViewPointArray_DG
IMeasurement_DG
IRectangleColor_DG
I2DEditor_DG
IVirtualView_DG
Collapse General ComputingGeneral Computing
IObjectGenerator_DG
IControlInitialisationContext_DG
IGlobalAPI_DG
Collections
IUnk
IObject_DG
IBitmap_DG
IBlob_DG
IContext_DG
IError_DG
IFont_DG
Collapse ViewsViews
View
Scene
Global Axes
Background
3D Background
Collapse Samples and TutorialsSamples and Tutorials
Sample List
Collapse GraphicsGraphics
Concepts
3D View
Viewing Volume
Eye Frame
Perspective View
Collapse Math ObjectsMath Objects
Mathematical Objects
Planes
Frames
Transforms
Oriented Objects
Boxes
Collapse CurvesCurves
Curve Technologies
Native Curves
Collapse 2D Elements2D Elements
Geometric Elements
Arcs
Line Strips
Collapse DeprecatedDeprecated
Collapse Deprecated GeometryDeprecated Geometry
Collapse 3DS3DS
Profiles
Surface Patches
Surfaces and Patch Strips
Input Validation
Collapse Lines and CurvesLines and Curves
3DS Curves
Surface Of Revolution
Collapse Deprecated API ReferenceDeprecated API Reference
Collapse ModelModel
Collapse SectionSection
IBoundary
Collapse 3DS3DS
IProfiles
Redistribution
Model Viewer
Support
Skip Navigation Links Go to ActiveX docs Search Documentation


Patch Visual Basic Tutorial

Patch Tutorial demonstrates incorporation of DG Kernel Control into a simple Windows Form application using Microsoft Visual Studio.  Source code for Patch sample is available in Samples\NET\VB\Patch\ folder of the installation directory.

See also: Sample List

This tutorial assumes basic familiarity with Visual Studio. It is based on Visual Studio 2019.

The Application

Patch application creates a new truncated cone and allows modification of its parameters.

Step 1. Creating the project

  • Open Visual Studio. Select File > New > Project in the menu. In the "Create a new project" make sure Visual Basic, Windows, Desktop are current on top. Select "Windows Forms App (.NET Framework) Visual Basic" project type. Click Next. Enter "Patch" for the project name. Select location and make sure .NET framework 4.5 is selected. Click Create.
  • In Solution Explorer select the Form1.vb created by default and rename it (using context menu on right-mouse click) to Patch.vb. Accept the suggestion to rename related elements when asked.

Step 2. Inserting the DG Kernel Control

  • Open Patch form in design mode and adjust size of the form to 890, 532 by pasting or typing the pair in Size property of the Properties Window (View > "Properties Window"). Change also Text property to "Patch".
  • Expand the Components tab of the Toolbox (View > Toolbox). If DGKC control is not there, right click on the tab and select 'Choose Items...'. If DGKC is not listed in the .NET Framework Components tab, click the Browse button  and select DGKernel_7_1\Bin\AnyCPU\DGKC.dll in the DGK installation folder
  • Select DGKC in the Toolbox and place the control on the left in the form. Save All. Close the from designer. A new member of type DGKC called Dgkc1 will be added to the Patch class.
  • Open the form. Select the control and change its size to 698, 482 using Properties Window.
  • Right-click on the control and select Properties. The form shows properties of the control. The properties can also be accessed via the Properties Window of Visual Studio. The main one, ModelPath, can point to an .mdg model file or a file in any other supported format. We will leave it empty as our entity will be created in the code.
  • Open the Object Browser (View > Object Browser menu option). Expand DGKC and its child node. This node displays all necessary information about types, interfaces and their methods available in the component.

Step 3. Creating the Entity 

  • To create handler for the Load event of the form, in design mode, click on the form outside the control. Click Events icon on the top of Properties Window. Select Load row in the list and double-click the row on the right. A new Patch_Load() method will be added to the Patch class.
  • Add line:

    Imports DGKC

    at the top of the Patch.vb
  • Next we will get access to IModel_DG  interface implemented by the control. Add to Patch_Load() the next line (without the (A) annotation):

    Dim iModel As IModel_DG = Dgkc1.GetModel()           (A)

  • Add the following declarations to the Patch class:

    Dim m_iEntity As IEntity_DG
    Dim m_baseRadius As Double
    Dim m_topRadius As Double
    Dim m_height As Double

  • Initialise the parameters in New() Patch constructor or on start of  Patch_Load() as:

    m_baseRadius = 10
    m_topRadius = 5
    m_height = 10

  • Add the following three lines just below the line (A):

    Dim iStdShape As IStdShape_DG = iModel.Query(Of IStdShape_DG)()
    m_iEntity = iStdShape.Cylinder(m_baseRadius, m_topRadius, m_height)
    iModel.AddEntity(m_iEntity)

    The first line obtains an interface for creation of basic shapes. The second line creates a cylindrical object and stores its reference in m_iEntity. The third line adds the entity to the model to be displayed in the 3D view.

  • Add the following two lines at the end of Patch_Load():

    Dim iView As IView_DG = Dgkc1.GetView()
    iView.Reset(True, True)

    The first line accesses IView_DG, which is the root of the view-related functionality and the second line refits the view to include the new object.

Step 4. Implementing Modifications of the Object.

  • Add three edit boxes for the parameters and an Apply button to the form. Please make sure the text in edit boxes coincides with the initial values. The controls can be copied in design mode from the installed completed version of the sample
  • In handler of the Apply button, add: 

    m_baseRadius = Double.Parse(editBaseRad.Text)
    m_topRadius = Double.Parse(editTopRad.Text)
    m_height = Double.Parse(editHeight.Text)

    Dim iModel As IModel_DG = Dgkc1.GetModel()
    Dim iStdShapeRef As IStdShapeRef_DG = iModel.Query(Of IStdShapeRef_DG)()
    iStdShapeRef.Cylinder(m_baseRadius, m_topRadius, m_height, m_iEntity)

    Dgkc1.UpdateView()

    Notice the different version of interface used. IStdShapeRef_DG is designed for modification (and creation) rather than creation only. The last line redraws the window.

  • Run the application and test modifications of the entity.