Navisworks API : Find Intersect and Override Color & Transparency (v2)

Welcome to the fourth tutorial of Navisworks® API series, this post is an upgraded version of the previous post : Find Intersect and Override Color which was released a few months ago. This time we will implement a new feature to transparent the excluded ModelItems (ModelItems that are not selected nor intersected).

Lab-4 v2 Demo

So, first things first, setting up Navisworks® Add-Ins project in the visual studio, you can follow Creating Navisworks Add-Ins tutorial to set up the project. When you are ready,create a few variable, Document doc to store the current document instance and we have four ModelItemCollection variables to store the selected items, itemsToColor, itemsToTransparent and invertItems (inverted selection of the current selection) respectively. To make the inverted selection, first copy the selected items to invertItems with CopyFrom method and invert the selection items.(figure 1.0)

figure 1.0 – variables

Next to iterate the selected items and inverted items, get BoundingBox of the selected item by using BoundingBox method with an argument boolean value, to ignore hidden item, and store in box1. (figure 1.1)

figure 1.1 – Iteration and Intersection

Nested invertItems in selectedItems loop, get the BoundingBox of the inverted item store in box2. Check the intersection of box1 vs box2, if result is true/intersect, add to itemsToColor ModelItemCollection. Else, item to be included in itemsToTransparent ModelItemCollection. (figure 1.1)

figure 1.2 – Apply Color & Transparency

Finally, apply color to the intersect items and transparency to the exclude items (not in selection nor intersections). (figure 1.2)

Well, that’s the end of the tutorial, you can download the complete project source code from here. Cheers!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.