Enable section box by using the api

Enable section box by using the api

Anonymous
Not applicable
2,602 Views
5 Replies
Message 1 of 6

Enable section box by using the api

Anonymous
Not applicable

Hi,

 

After exporting the clash results to viewpoints, the viewpoints contain some settings for a section box, but the section box isn't enabled by default. When I unhide all objects in the model, and I enable the section box, I see a nice section box around the clash and I can see all the objects around the clash. 

 

In case of thousand clashes this is a time consuming task. Therefore, I want to automate this using the api. Could someone push me in the right direction to achieve this in .net? Especially, I cant figure out how to enable the section box.

 

Thanks in advance!

0 Likes
2,603 Views
5 Replies
Replies (5)
Message 2 of 6

xiaodong_liang
Autodesk Support
Autodesk Support

Hi,

 

no API for sectioning box. Assume you have taken a look at the blog on how to create one sectioning plane, to have the effect of box, you can create the 6 planes one by one. 

http://adndevblog.typepad.com/aec/2012/08/create-sectioning-plane.html

Hope it helps.

0 Likes
Message 3 of 6

Anonymous
Not applicable

Hello,

Is it  possible know if after 4 years  there is some news ?
With news version of API it is possible ?

Thank you in advance

0 Likes
Message 4 of 6

tetsuya_miwa
Advocate
Advocate

Try SetClippingPlanes.

Private Sub Clip_VolumeBox(oBoxClip As BoundingBox3D)
        Dim clippingPlanesJson As String

        clippingPlanesJson = "{""Type"": ""ClipPlaneSet"",""Version"":1,""OrientedBox"":{""Type"":""OrientedBox3D"",""Version"":1,""Box"":[["
        clippingPlanesJson = clippingPlanesJson & oBoxClip.Min.X & ","
        clippingPlanesJson = clippingPlanesJson & oBoxClip.Min.Y & ","
        clippingPlanesJson = clippingPlanesJson & oBoxClip.Min.Z & "],["
        clippingPlanesJson = clippingPlanesJson & oBoxClip.Max.X & ","
        clippingPlanesJson = clippingPlanesJson & oBoxClip.Max.Y & ","
        clippingPlanesJson = clippingPlanesJson & oBoxClip.Max.Z & "]]"
        clippingPlanesJson = clippingPlanesJson & ",""Rotation"":[0,0,0]},""Enabled"":true}"

        Autodesk.Navisworks.Api.Application.ActiveDocument.ActiveView.SetClippingPlanes(clippingPlanesJson)

    End Sub
Message 5 of 6

Anonymous
Not applicable

It's a good idea.

Soon i try it, and I'll give you a feedback.

Thank you.

0 Likes
Message 6 of 6

bvgarbar
Contributor
Contributor

HI, @Anonymous !

 

If it's relevant...)
I've been looking for a solution to this question for several nights😅
On some pages of the forum, I found a direction where to move on. By the way, @tetsuya_miwa's answer gives one of the right directions. Thank you, @tetsuya_miwa!

 

So, I will try to describe what I managed to find.

There are two ways:
1. It's via .Net API
2. Bridge COM API

 

1. The first method allows you to create section planes using json. To do this, you first need to enable sections in the Navisworks test model. We can include individual section planes, or a box. Depending on this, the json data model will differ that you get using the GetClippingPlanes() method :

var doc = Application.ActiveDocument;
varactiveView = doc.ActiveView;
var clipps = activeView.GetClippingPlanes();

Next, I take the resulting json data model and make classes in my project that I will use for serialization.

var jsonPlaneData = JsonConvert.SerializeObject(planeData, Formatting.Indented);
activeView.SetClippingPlanes(jsonPlaneData);

2. The second method uses the Bridge COM API. The code that I was able to achieve (and based on research on the net) is as follows:

private void CreateSectionBox(Document doc, DocumentCurrentSelection selection)
{
var currentViewPoint = doc.CurrentViewpoint;
var viewPointValue = currentViewPoint?.Value;
var planes = viewPointValue?.InternalClipPlanes;
if (planes == null) return;

planes.SetMode(LcOaClipPlaneSetMode.eMODE_BOX);
if (planes.GetMode() != LcOaClipPlaneSetMode.eMODE_BOX) return;
BoundingBox3D box = selection.SelectedItems.BoundingBox();
//planes.FitToBox(box);
planes.SetBox(box);
planes.SetEnabled(true);
currentViewPoint.Value.ZoomBox(box);
}

Hope this information helps someone.

 

Best regards,

Bogdan