AddUsingiMates

AddUsingiMates

NachoShaw
Advisor Advisor
192 Views
0 Replies
Message 1 of 1

AddUsingiMates

NachoShaw
Advisor
Advisor

Hey

 

I am adding Components to my assembly then calling an iMates function to constrain them. I was looking at the AddUsingiMates function as its much faster but i cant see how i can declare the specific components to be mated. Is it feasible to do that? It looks like the AddUsingiMates will match the first set of iMates found...

 

Reason: i have different components with iMates and based on certain conditions, a typical component will need to be added. The typical component will be mated with the relevant components if the condition is met but only if the condition is met hence the declaring of the mating component.

 

My current code is set up so i can pass the AssemblyDefinition, First & Second occurrences along with an index of each iMate. It works fine, id just like to narrow down my code and speed up where possible..

 

Here is my iMates code

Friend Sub DoiMates(ByVal BaseComponent As ComponentOccurrence, ByVal BP1 As Integer, ByVal BP2 As Integer, ByVal BP3 As Integer,
                        ByVal SecondComponent As ComponentOccurrence, ByVal SP1 As Integer, ByVal SP2 As Integer, ByVal SP3 As Integer,
                        ByVal Assy As AssemblyComponentDefinition)

Dim Bcd As iMateDefinitionsEnumerator = BaseComponent.iMateDefinitions
Dim Scd As iMateDefinitionsEnumerator = SecondComponent.iMateDefinitions
Dim oiMateResults As iMateResult = Nothing
Try
   oiMateResults = Assy.iMateResults.AddByTwoiMates(Bcd.Item(BP1), Scd.Item(SP1))
Catch ex As Exception
End Try

Try
    oiMateResults = Assy.iMateResults.AddByTwoiMates(Bcd.Item(BP2), Scd.Item(SP2))
Catch ex As Exception
End Try

Try
   oiMateResults = Assy.iMateResults.AddByTwoiMates(Bcd.Item(BP3), Scd.Item(SP3))
Catch ex As Exception
End Try
End Sub

 

Called like this

IC.DoiMates(_BaseModel, 2, 3, 4, oCompOcc, 2, 3, 5, _aDef)

 

AddUsingiMates would be a single line of code, much more efficient but only if the 2 components were able to be declared..

 

Any suggestions? Even on improving my code? 🙂

 

 

Thanks

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


0 Likes
193 Views
0 Replies
Replies (0)