Hello everybody,
I am trying in my add-in (SW 2019) to intercept interference events and to list interfering components of the assembly.
I am using the DAssemblyDocEvents_InterferenceNotifyEventHandler delegate to get the event.
Once the event has been raised I list the object name.
My issue is that not always the objects are correct and sometimes the event is raised for no reason.
I perform a lot of commands before I make this check so I have not been able to identify precisely a pattern that can cause such problem. I always call a DragOp before and I might have found that if i start the drag from an already colliding configuration the interference event fails more often.
However these are the methods I used to list the interferences once the event is raised.
object[] objList = pComponent as object[];
List<IComponent2> components = new List<IComponent2>();
for (int i = 0; i < objList.Length; ++i)
{
IComponent2 component = objList[i] as IComponent2;
if (!components.Contains(component))
components.Add(component);
Notify(component.Name);// MY API
}
I have also tried this solution:
var pIntMgr = swAssemblyDoc.InterferenceDetectionManager;
pIntMgr.TreatCoincidenceAsInterference = false;
pIntMgr.TreatSubAssembliesAsComponents = false;
pIntMgr.IncludeMultibodyPartInterferences = true;
pIntMgr.MakeInterferingPartsTransparent = false;
pIntMgr.CreateFastenersFolder = false;
pIntMgr.IgnoreHiddenBodies = true;
pIntMgr.ShowIgnoredInterferences = false;
pIntMgr.UseTransform = false;
var vInts = (object[])pIntMgr.GetInterferences();
IInterference interference = default(IInterference);
object[] vComps = null;
Component2 comp = default(Component2);
List components = new List();
if (vInts != null)
{
for (int i = 0; i < vInts.GetUpperBound(0); ++i)
{
interference = (IInterference)vInts[i];
vComps = (object[])interference.Components;
for (long j = 0; j <= vComps.GetUpperBound(0); j++)
{
comp = (Component2)vComps[j];
if (!components.Contains(comp))
components.Add(comp);
}
}
}
pIntMgr.Done();
It works but it is very heavy and checks all the interferences. I need a really fast computation, as I perform the checking in a loop. Also, pIntMgr.Done() makes makes changes on the SW GUI and I would like to avoid that.
I am trying to make the ToolsCheckInterference2 work, but I cannot find a way to get a result (in C#), although I have the VBA example.
Is this a known issue? Anybody has any idea on what can interfere with the event or any workaround for this problem?
Thanks in advance!
SolidworksApi/macros