KernelCAD Documentation

DInsight Home
Skip Navigation Links.
Start page
Quick Start
Installation
Overview of the software
What is new
Collapse KernelCAD ModelsKernelCAD Models
Collapse KernelCAD ComponentsKernelCAD Components
KernelCAD Control
KernelCAD .NET Control
Methods and Properties
Menu
Model Explorer
Birds Eye View
Programming
Direct User Access
Direct Operations
Interface Queries
Printing Support
Data Types
Modes of KernelCAD Control
DIObjectGenerator class
Properties
FlatObjectArray Poperty
Context
64 bit development
Dual Mode
Initialisation Context
Overlay Editor
Memory Management
Input validation
Collapse Advanced functionalityAdvanced functionality
Collapse InterfacesInterfaces
Alphabetical list
I3DGrid
I3DBugger
I3Dpt
IAxiBase
IAxis
IBoolSection
IBoolSectionEx
IBoundary
IColor
IConstraint
IData
IDiffSurface_KC
IDIFont
IDraw
IDrawUtil
IDraw2
IElem
IElement
IKCLine
ILightSource
ILocation
ILocationEx
IMaterial
IMetrics
IMetrics2
IModel
IModel2
IModelEx
IPatch
IKCPathCollisionDetector
IProfiles
IPropertyArray
IPropertyArray2
IStdShape
IStrip
ISurface
IText
ITexture
ITransform
IUnknown
Collapse Open Cascade TechnologyOpen Cascade Technology
Collapse DataData
Collapse MovementMovement
Collapse FramesFrames
Collapse Oriented ObjectsOriented Objects
Collapse SectionsSections
Collapse GeneralGeneral
Collapse Topological InterfacesTopological Interfaces
Collapse Viewing InterfacesViewing Interfaces
Collapse Lines And CurvesLines And Curves
Collapse Symmetry InterfacesSymmetry Interfaces
Collapse Clipping plane interfacesClipping plane interfaces
Collapse AlgorithmsAlgorithms
Collapse 2D Geometry2D Geometry
Collapse Programming Samples and TutorialsProgramming Samples and Tutorials
Collapse OverviewOverview
Collapse DeploymentDeployment
Collapse .NET Samples.NET Samples
Collapse C++ SamplesC++ Samples
Collapse Visual Basic SamplesVisual Basic Samples
Collapse Delphi SamplesDelphi Samples
Collapse 3D Debugger3D Debugger
Collapse DeploymentDeployment
Licensing
Model Viewer
Open C++ Source
Technical Support
Skip Navigation LinksHome Page > Programming Samples and Tutorials > Visual Basic Samples > Patch
VB Patch Sample

Patch Sample

Source code for Patch sample is available in Samples\VB folder of the installation directory. We suggest to copy  Patch  folder to location outside the installation directory if you are going to compile the project. Patch is an application, implemented in Visual Basic 6.0 which displays a DI model consisting of a single patch of surface using KernelCAD ActiveX control and allows to modify geometrical parameters of the model.

Note that VB 6.0 samples require Common Dialogs component enabled in the development environment (details).

See also:  C++ Patch TutorialC# Patch Tutorial    Visual Basic .NET Patch Tutorial,   All samples

Running Patch Sample

Patch application loads ArcPatch.glm model located in the models folder. The dialog displays parameters which can be modified to assign any valid shape to a model with single cross-sectional element (Elements).  Two edges of ArcPatch.glm are not of the same type. To be able to compare behaviour, the first edge (the right one) consists of arcs. The second edge consists of straight line elements. The first edit box "Cross-section position" specifies z coordinate for cross-sectional plane where all other parameter modifications will be applied. The next four edit boxes allow to modify coordinates of edge in the cross-section plane. Note that type of modifications is different depending if is the cross-section position is at the end ( z=0 or z=10 ) or anywhere in the middle of the axial range. 

Modifying the model

To enter new value of properties press "Apply" button. If entered values are valid the model will change in 3D.

Implementation

All the work is done inside PatchFrm.frm module. In Form_Load() Sub line

    Set iModUnkn = KernelCADCtrl.GetModel

retrieves iModUnkn  IModel interface (See Interface List ), from which all other interfaces are accessed.  Interface to the current section is kept into m_iSection member. It is obtained in the same procedure using call

Set m_iSection = m_iModel.GetSection(0)

This model is assumed to have a single section. 

The same Form_Load() Sub acquires IAxiBase interface using call

Set m_iAxiBase = m_iSection

Next, with the help of GetKnotValue method of IAxiBase interface we obtain range of z values for the section.

Last job in  Form_Load(() is to acquire IStrip pointer from m_iSection. IStrip interface m_iStrip is implemented by object which represents cross-section segment strip.

Update_Surface_Info() Sub updates current cross-section position  of the model by calling SetCrossPosition method of IAxiBase. The same function also retrieves IElement interfaces to both edge objects with 

        Set m_iElemEdge1 = m_iStrip.GetElement(0, False)

        Set m_iElemEdge2 = m_iStrip.GetElement(1, False)

Edge of the patch in cross-section is a point, so it should have two parameters. Values of those are obtained in Update_Page() with:

        m_dX1 = m_iElemEdge1.GetParam(0)

, ...

Line 

        Set m_iElemSegment = m_iStrip.GetElement(0, True)

 from Update_Surface_Info() retrieves IElement interface implemented by the surface patch itself. In cross-section it is an arc. It has single parameter - radius. We have already accessed objects of the arc ends with m_pIElemEdgek interfaces.

Geometry changes are done in ButtonApply_Click() Sub through calls to SetParam method of IElement interface. Call to UpdateSurface method of the control carries out recalculation of surface for the modified model.