Community
Navisworks API
Welcome to Autodesk’s Navisworks API Forums. Share your knowledge, ask questions, and explore popular Navisworks API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Accessing clash detection settings through .NET API

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
gabby_rosemergy
304 Views, 3 Replies

Accessing clash detection settings through .NET API

I'm trying to automate mass clash detection and while I've got most of it working, I'm struggling to access some of the settings available in the UI clash detective.

 

I've found that using ClashSelection.PrimitiveTypes I am only able to set one of either surfaces/triangles, lines, and points at a time. In the UI, any combination of these can be set simultaneously. Is this possible with the API, or would I have to rerun the clash tests for each and then merge the results?

 

I'd also like to be able to set rules for the clash tests using the rules already in the document. I've found the ClashTest.IgnoreRules property, which appears as though it can be used in the same way as in the UI, but I can't find any way to access the existing rules. A post on stack exchange from about three years ago said that this is not possible, but I'm not sure if this is something that has been updated since.

Would I have to set up in code any rules I want to use? If so, how? I can't find any way to create a new rule, only to copy an existing one. This seems redundant if it is not possible to access any existing rules to copy them.

 

I'm well aware that I could just be missing something obvious (or that these may not be possible), so thanks in advance for any help!

3 REPLIES 3
Message 2 of 4

Hi @gabby_rosemergy ,

 

Could you please try using the below code?

  Document doc = Autodesk.Navisworks.Api.Application.ActiveDocument;
            DocumentClash documentClash = doc.GetClash();
            DocumentClashTests oDCT = documentClash.TestsData;
            ClashTest t = oDCT.Tests[0] as ClashTest;
            ClashTest oCopyt = t.CreateCopy() as ClashTest;
            oCopyt.SelectionA.PrimitiveTypes = PrimitiveTypes.Triangles | PrimitiveTypes.Lines;
            oCopyt.SelectionB.PrimitiveTypes = PrimitiveTypes.Lines | PrimitiveTypes.Points;
            oDCT.TestsEditTestFromCopy(t, oCopyt);

Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

Message 3 of 4

Awesome, thank you so much! That's solved my problems with the primitive types (which was more important to me)! Is there any way to use rules or is that feature still not available?
Message 4 of 4

Hi @gabby_rosemergy ,

 

You cannot use the .NET API to add rules to a clash test.

 

The only way I know of to add rules it to use the COM API.

 

There is an example in the NW API SDK, under "com/examples/Plugin/PluginClashRuleExample"

 

NW API SDK Link : https://aps.autodesk.com/developer/overview/navisworks


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


 

Autodesk Design & Make Report