Is it possible to get the transform of the section box through the API?

Is it possible to get the transform of the section box through the API?

Anonymous
Not applicable
2,169 Views
4 Replies
Message 1 of 5

Is it possible to get the transform of the section box through the API?

Anonymous
Not applicable

I am wondering if there is any way of getting information about the section box in Navisworks. I have been able to get the normal and distance of enabled section planes but have not found any info about the section box.

0 Likes
2,170 Views
4 Replies
Replies (4)
Message 2 of 5

vilchishin
Explorer
Explorer

Hi Vanessa,

 

You can access section box information by de-serializing clipping planes JSON of active view:

 

  1. Get instance of Autodesk.Navisworks.Api.View which is your current active view (this can be got from Document.ActiveView);
  2. View.GetClippingPlanes() will return you a JSON string which contains OrientedBox property.

 

 

0 Likes
Message 3 of 5

alexisDVJML
Collaborator
Collaborator

You can get full details of the Section Box, aka mode, bounding box, oriented box or planes etc by accessing the LcOaClipPlaneSet object of the active viewpoint:

var cps =NavisworksApp.ActiveDocument?.CurrentViewpoint.ToViewpoint()?.InternalClipPlanes;

var m = cps.GetMode();
bool enabled = cps.IsEnabled();

BoundingBox3D box = new BoundingBox3D(); Rotation3D rotation = new Rotation3D();
cps.GetOrientedBox(box, rotation);
 // etc...

However, while you can change these values by calling various SetXXX methods, I have not found yet how to have these changes be reflected in Navisworks.


Which is sad since such API is much cleaner and efficient than having to parse/construct JSON strings.
Anyone has a way to have such changes really applied?

Main Scientist, Full Stack Developer & When Time Permits Director of IDIGO ► On your marks, Set, Go
0 Likes
Message 4 of 5

alexisDVJML
Collaborator
Collaborator

I actually find a way to have changes update Navisworks:

var cvp = NavisworksApp.ActiveDocument?.CurrentViewpoint;
var vp = cvp?.Value;
var cps = vp?.InternalClipPlanes;
if (cps == null) return;

// DO CHANGES HERE, for example here we change the box (making it half size) if in box mode
if (cps.GetMode() != LcOaClipPlaneSetMode.eMODE_BOX) return;
BoundingBox3D box = new BoundingBox3D();
Rotation3D rotation = new Rotation3D();

cps.GetOrientedBox(box, rotation);
Vector3D dims = box.Size;
box = box.ExpandBy(-dims.X * 0.25, -dims.Y * 0.25, -dims.Z * 0.25);
cps.SetOrientedBox(box, rotation);

// surprisingly we have to copy the viewpoint back into the document then everything is refreshed correctly:		NavisworksApp.ActiveDocument.CurrentViewpoint.CopyFrom(vp);

Sure should have better ways, but at least that's a good working start 🙂

Main Scientist, Full Stack Developer & When Time Permits Director of IDIGO ► On your marks, Set, Go
0 Likes
Message 5 of 5

alexisDVJML
Collaborator
Collaborator

An even simpler way to change current document AND view Sectioning state and have it refreshed:

var oav = Application.ActiveDocument.State.GetViewer();
var cps = oav.GetClipPlaneSet();
// Change CPS mode, planes etc here
...
//

// Ensure UI is updated
oav.RequestRedraw(LcOaViewerRedrawType.eREDRAW_UPDATE);

 

Main Scientist, Full Stack Developer & When Time Permits Director of IDIGO ► On your marks, Set, Go
0 Likes