Rename clashes in Navisworks through Dynamo

Does anyone know how I can open a Navisworks in background and use its API? I want to rename clashes like here explained:
Solved: Change Clash Result Properties - Name, Status - Autodesk Community - Navisworks

Yes you can. The Dynaworks package does this, and if I recall it is open source so you can find a functional example online.

1 Like

An example with ComApi

rename_clashes

import clr
import sys
import System
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
from System.Collections.Generic import *

version = IN[0]
navis_path = r'C:\Program Files\Autodesk\Navisworks Manage {}'.format(version)
sys.path.append(navis_path)

clr.AddReference('Autodesk.Navisworks.Automation')
clr.AddReference('Autodesk.Navisworks.Controls')
clr.AddReference('Autodesk.Navisworks.Resolver')
clr.AddReference('Autodesk.Navisworks.ComApi')
clr.AddReference('Autodesk.Navisworks.Interop.ComApi')
clr.AddReference('Autodesk.Navisworks.Interop.ComApiAutomation')

import Autodesk.Navisworks.Api as API
import Autodesk.Navisworks.Api.ComApi as COMAPI
import Autodesk.Navisworks.Api.Interop.ComApi as ICOMAPI
import Autodesk.Navisworks.Api.Interop.ComApiAutomation as ICOMAPI_AUT
from Autodesk.Navisworks.Api import *
from Autodesk.Navisworks.Api.Automation import *
from Autodesk.Navisworks.Api.Controls import *

clr.AddReference('System.Windows.Forms')
import System.Windows.Forms
from System.Windows.Forms import MessageBox, MessageBoxButtons, MessageBoxIcon

		#
filepath = IN[1]
prefix =  IN[2]
app = ICOMAPI_AUT.DocumentClass()
app.OpenFile(filepath)
app.Visible = True
navis_doc = app.State()
MessageBox.Show("Waiting.....Are you Ready ?", "Wait", MessageBoxButtons.YesNo, MessageBoxIcon.Information)
for plugin in navis_doc.Plugins():
	if plugin.ObjectName == "nwOpClashElement":
		clashPlugin = plugin
		all_tests = clashPlugin.Tests()
		for test in all_tests:
			clash_results = test.results()
			for idx, clash_result in enumerate(clash_results):
				clash_result.name = prefix + clash_result.name
5 Likes

Merci @c.poupin as always! Great work!

1 Like