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 > .NET Samples > C# Samples > Object Array
C# Object Array Sample

Object Array Sample

Source code for Object Array sample is available in Samples\NET\CS\ObjArray folder of the installation directory. It is recommended to copy the folder to location outside of the installation folder before loading or compilation. ObjArray is an .NET Windows Forms application, which demonstrates browsing object hierarchy in the model and dynamic creation of objects.

See also Visual Basic .NET Object Array sample  C++ Object Array sample   All C# .NET Samples,  All samples

Running the application  

Controls on the right allow navigation between objects in the currently loaded model. (see Structure of DInsight models). They represent a simplified version of Model Explorer of 3D Debugger.  Children group displays number of children in the current object and allows to make current one of them. The current object is highlighted in 3D with blue color and its name is displayed at the top of the dialog. On load "Children" group displays information about objects in the model, meaning that the whole model is considered as the top object in the hierarchy. 

"Delete" button deletes the child selected in the "Child" edit box.

"Switch to parent" button on the top of the dialog makes parent the current object.

"Position" edit boxes allow modification of location of the current object.

"New Child" group allows adding new objects to the model or new children to the current object. 

File submenu allows saving and loading models.

"Current Object" submenu contains operations with the model structure:

Operations

"Delete" command deletes the child selected in the "Child" edit box.

"Detach" command makes the current object independent top level object of the model. On this command nothing will change in the 3D view. To make sure that the command was carried out try to modify position of the current object using "Position" edit boxes. The object should move independently of its previous parent.

"Join" command makes the first top level object (different from the current) child of the current object. This command is invalid when a top object is being attached to its child. As the result the object will move together with its parent.

Implementation

The most important work specific to this sample is done using IArray interface. IArray is a topological interface, which means it changes structure of the model rather than changing its parameters. Actions performed by IArray depend on context. In this sample IArray adds or deletes child objects from/to the section or model it was queried from. It is done in ButtonAdd_Click() and ButtonDelete_Click() methods of ObjArrayForm class. 

New objects are added in ButtonAdd_Click()  handler.  Create3DS() method creates new  Sect3DGeneratorClass object, which is a generic constructor of 3D section objects. Sect3DGeneratorClass has a single interface I3DSectionGenerator, which is queried immediately from the object. Creation of the actual 3D Section  is done by using Create() method of I3DSectionGenerator. Create() returns an ISection interface, implemented by the new section, which is used later to add to the array of objects of the model or parent section. Prior to that, default parameters for the required section are collected into a DI3DSectInfo structure by Set3DSDefaults() function.

Method CreateSOR() of the form does the same job for Surface Of Revolution type of objects.

Suggested exercise

Add operation to change order of top level object in the model.