Showing results for 
Search instead for 
Did you mean: 

CheckInterference problem

Valued Contributor
Valued Contributor


We have written a code to check Interferences in an Assembly file. But unfortunately we are getting errors. Can somebody help us in giving us a sample code in VB or VB.NET?

Our code:


Dim occurrences As SolidEdgeAssembly.Occurrences


occurrences = objAsmDoc.Occurrences

Dim set1(objAsmDoc.Occurrences.Count) As SolidEdgeAssembly.Occurrence

Dim status As SolidEdgeAssembly.InterferenceStatusConstants

Dim numInterferences AsObject = 0

Dim interferenceOccurrence AsObject = Nothing

Dim iTempCount As Int32


For iTempCount = 1 To occurrences.Count

set1.SetValue(occurrences.Item(iTempCount), iTempCount - 1)


objAsmDoc.CheckInterference(set1.Length, set1, status, _

SolidEdgeConstants.InterferenceComparisonConstants.seInterferenceComparisonSet1vsItself, _

Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, _

Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value)


We are using .Net 2.0 and VB.NETAbove code always throws:

"The server threw an exception. (Exception from HRESULT (RPC_E_SERVERFAULT))"


Posted by: Siddhartha Mishra
Post date: 4/8/2008 4:30:02 AM


RE: CheckInterference problem

Valued Contributor
Valued Contributor


You're not going to like my answer but this is the solution.  Passing arrays from .NET to COM can be a real pain.  Often times when a method fails like this, you have to resort to using .NET reflection.Imports SolidEdgeConstantsImports System.ReflectionImports System.Runtime.InteropServicesModule Module1 Sub Main() Dim objApplication As SolidEdgeFramework.Application Dim objAssembly As SolidEdgeAssembly.AssemblyDocument Dim objOccurrences As SolidEdgeAssembly.Occurrences Dim objOccurrence As SolidEdgeAssembly.Occurrence Dim objArray As Array Dim index As Integer Dim status As SolidEdgeAssembly.InterferenceStatusConstants objApplication = Marshal.GetActiveObject("SolidEdge.Application") objAssembly = objApplication.ActiveDocument objOccurrences = objAssembly.Occurrences objArray = Array.CreateInstance(GetType(SolidEdgeAssembly.Occurrence), objOccurrences.Count) For Each objOccurrence In objOccurrences objArray.SetValue(objOccurrence, index) index = index + 1 Next Dim p As New ParameterModifier(3) p(1) = True p(2) = True Dim mods() As ParameterModifier = {p} Dim objArgs() As Object = {objArray.Length, objArray, status} GetType(SolidEdgeAssembly.AssemblyDocument).InvokeMember( _ "CheckInterference", _ BindingFlags.InvokeMethod, _ Nothing, _ objAssembly, _ objArgs, _ mods, _ Nothing, _ Nothing) 'objAssembly.CheckInterference(objArray.Length, objArray, status) Select Case objArgs(2) Case SolidEdgeAssembly.InterferenceStatusConstants.seInterferenceStatusConfirmedAndProbableInterference Console.WriteLine("seInterferenceStatusConfirmedAndProbableInterference") Case SolidEdgeAssembly.InterferenceStatusConstants.seInterferenceStatusConfirmedInterference Console.WriteLine("seInterferenceStatusConfirmedInterference") Case SolidEdgeAssembly.InterferenceStatusConstants.seInterferenceStatusIncompleteAnalysis Console.WriteLine("seInterferenceStatusIncompleteAnalysis") Case SolidEdgeAssembly.InterferenceStatusConstants.seInterferenceStatusNoInterference Console.WriteLine("seInterferenceStatusNoInterference") Case SolidEdgeAssembly.InterferenceStatusConstants.seInterferenceStatusProbableInterference Console.WriteLine("seInterferenceStatusProbableInterference") End Select End SubEnd Module


Posted by: Jason Newell
Post date: 4/16/2008 8:34:35 PM

RE: CheckInterference problem

Valued Contributor
Valued Contributor


Thanks so much for your help on this function... It's been a while I fight with it to get it works...

It's now working, but I can not get back InterferingPartsSet1 nor InterferingPartsOtherSet


Do you know why ?


thanks in advance ...






Posted by: Anthony PONCEOT
Post date: 4/28/2008 2:15:45 AM