KernelCAD Documentation

DInsight Home
Skip Navigation Links. Skip Navigation LinksHome Page > KernelCAD Components > Interfaces > Sections > ISection2
ISection2 Interface

ISection2 Interface


ISection2 interface has two methods, which control visibility of the local frame of the object (ShowLocalFrame property)

See also: Interface List

HRESULT GetFrameVisibleFlag(VARIANT_BOOL *pbVisible)


pbVisible - [out, retval] reference to a Boolean variable, which will receive the current value of the frame visibility flag.

HRESULT SetFrameVisible(VARIANT_BOOL bVisible)


bVisible - [in] new value for the frame visibility flag.

HRESULT Show(VARIANT_BOOL show, VARIANT_BOOL includeChildren, VARIANT_BOOL childrenOnly)


show - [in] new value for the objects visibility property.

includeChildren - [in] True if all children and descendents of the object are to be included in the operation

childrenOnly - [in] If true the object implementing this interface will not be included in the operation. (useful only if includeChildren is true)


The method allows changing visibility property for an object and its descendants in a single call.

HRESULT SetColor(float fRed, float fGreen, float fBlue


fRed, fGreen, fBlue - [in] Components of the color.


The method a quick shorcut for changing color of the object

HRESULT Detach()


Detaches the object from its parent. The object will remain alive and can be used for background calculations, can be added to any model, etc. as long as the application holds at least one reference to it

HRESULT RemoveAll()


Deletes all children and their descendants

HRESULT RemoveChild(IItem *item))


Removes the item child, which can actually be a section, and all its descendants

HRESULT Relocate(IFrame* newLocationOrientation)


Changes location and orientation of the object without moving children or parent.

The method only copies coordinates from newLocationOrientation without any changes and does not store or use it otherwise. So newLocationOrientation is a read-only (constant) parameter. As the result of that the local frame of the section will geometrically coinside with newLocationOrientation.

newLocationOrientation normally can be created with IDIObjGenerator.Create((int)EObjectType.eObjTypeFrame)

This method is equivalent to detaching this object from its parent and children from this object, copying newLocationOrientation to the local frame and reattaching the object to the parent and children to this object

Example: The code below expects a model with a cylinder as the first top level object and a cone as its child


Dim iMod As IModel = AxKernCADnet1.GetModel
Dim iSectCylinder As ISection = iMod.GetSection(0)
Dim iSectCone As ISection = iSectCylinder.GetChild(0)
Dim iSect2Cone As ISection2 = iSectCone Dim iGenerator As IDIObjGenerator = iMod

' Create a standalone frame. A frame defines location and orientation. By default it coinsides with the global axes
Dim iFrm As IFrame = iGenerator.Create(EObjectType.eObjTypeFrame)
'Query other IFrame* iterfaces here like IFrame3 = iFrm to get more functionality like rotation around local axes
iFrm.Rotate(10, 0, 0, 0, 0, 1, 0)
iFrm.SetOrigin(0.3, 0, 0)




IModel iMod = axKernCADnet1.GetModel();
ISection iSectCylinder = iMod.GetSection(0);
ISection iSectCone = iSectCylinder.GetChild(0);
ISection2 iSect2Cone = (ISection2)iSectCone;

IDIObjGenerator iGenerator = (IDIObjGenerator)iMod;
IFrame iFrm = (IFrame)iGenerator.Create(EObjectType.eObjTypeFrame);
//iFrm created coinsiding with global axes
iFrm.Rotate(10, 0, 0, 0, 0, 1, 0);
iFrm.SetOrigin(0.3, 0, 0);



HRESULT SaveAs(char* filePath, IDictionary_KC* options, VARIANT_BOOL* success)


filePath- [in] full path. Can have any of the supported extensions

options- [in] Additional options. Can be null

success- [out,retval] The result code.


The method allows saving individual objects.

In case filePath has a VRML extension (.wrl or .vrml):

If options is not null and contains string named "TextureImagePath" and its value is a valid file path, it is considered as location of the image for texture of the object (if the object has it). If this path is not specified the image will be saved next to the vrml file.

If the TextureImagePath is provided, it is considered relative to location of the vrml file. Path with ellipses like "..\Image\MyTextureImage.png"  is acceptable