Currently, only COM exposed some small API for sectioning. InwClippingPlaneColl can add the custom clipping plane. But InwClippingPlaneColl.Add method is not supported. This is because the COM wrapper in having to follow the underlying C++ code.
You need to use InwClippingPlaneColl2.CreatePlane. It passes in a 1 based index. Default planes will be created as required, up to and including this index. Then you modify the plane that is in the collection directly.
private void createSectionPlane()
{
ComApi.InwOpState10 state;
state = ComBridge.State;
// create a geometry vector as the normal of section plane
ComApi.InwLUnitVec3f sectionPlaneNormal =
(ComApi.InwLUnitVec3f)state.ObjectFactory(
Autodesk.Navisworks.Api.Interop.ComApi.nwEObjectType.eObjectType_nwLUnitVec3f,
null,
null);
sectionPlaneNormal.SetValue(1, 1, 0);
// create a geometry plane
ComApi.InwLPlane3f sectionPlane =
(ComApi.InwLPlane3f)state.ObjectFactory
(Autodesk.Navisworks.Api.Interop.ComApi.nwEObjectType.eObjectType_nwLPlane3f,
null,
null);
//get collection of sectioning planes
ComApi.InwClippingPlaneColl2 clipColl =
(ComApi.InwClippingPlaneColl2)state.CurrentView.ClippingPlanes();
// get the count of current sectioning planes
int planeCount = clipColl.Count + 1;
// create a new sectioning plane
// it forces creation of planes up to this index.
clipColl.CreatePlane(planeCount);
// get the last sectioning plane which are what we created
ComApi.InwOaClipPlane cliPlane =
(ComApi.InwOaClipPlane)state.CurrentView.ClippingPlanes().Last();
//assign the geometry vector with the plane
sectionPlane.SetValue(sectionPlaneNormal, 1.0);
// ask the sectioning plane uses the new geometry plane
cliPlane.Plane = sectionPlane;
// enable this sectioning plane
cliPlane.Enabled = true;
}