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).
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,
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)
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)
selectedItems loop, get the
BoundingBox of the inverted item store in
box2. Check the intersection of box1 vs box2, if result is
intersect, add to
itemsToColor ModelItemCollection. Else, item to be included in
itemsToTransparent ModelItemCollection. (figure 1.1)
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!
Site Founder and Developer.