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!
Solved! Go to Solution.
Solved by naveen.kumar.t. Go to Solution.
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);
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
Can't find what you're looking for? Ask the community or share your knowledge.