Imate generation with iLogic

Imate generation with iLogic

josh.linares-stanley
Enthusiast Enthusiast
544 Views
2 Replies
Message 1 of 3

Imate generation with iLogic

josh.linares-stanley
Enthusiast
Enthusiast

Hi,

Any advice on a good way to copy imate composites, possibly with ilogic? I have a the following DINRAIL as an iLogic component that adjust's length/type etc but have I have had to create iMate's on the top face and edge many times over. We might have 100's of items on it which could exceed the number of iMates I have set-up. Would be nice if the iMate would regenerate itself once it is consumed by the part, ready for the next breaker/terminal that's placed on it.

joshlinaresstanley_0-1649061917119.png

 

0 Likes
545 Views
2 Replies
Replies (2)
Message 2 of 3

WCrihfield
Mentor
Mentor

Hi @josh.linares-stanley.  I rarely work with iMates, so I work with them even less by code, but I do know that there are a few iLogic snippets for working with them.  And I also know how to access or create them by Inventor API code, if that may help out a little.

The 4 iLogic snippets are basically for IsActive (suppression) type use, and for Add (create) type use.

Constraint.iMateDefIsActive("iMate:1")
Constraint.iMateDefIsActive("SubAssem:1", "iMate:1")
Constraints.AddByiMates("Mate1", "Part1:1", "iMate:1", "Part2:1", "iMate:1")
Constraints.AddByiMateAndEntity("Mate1", "Part1:1", "iMate:1", "Part2:1", "iMate:1", entityBiasPoint := Nothing, angleEntityReversed := False)

And the API route is of course a bit longer and more complex looking, depending on what you are trying to do with them.  This is just one rough example of some code that can be used in an iLogic rule to access them:

Dim oPDoc As PartDocument = ThisDoc.Document
oPDef = oPDoc.ComponentDefinition
Dim iMateDefs As iMateDefinitions = oPDef.iMateDefinitions
Dim oCompIMateDef As CompositeiMateDefinition = Nothing
Dim oMatchList As String() = {}
If iMateDefs.Count > 0 Then
	For Each oIMateDef As iMateDefinition In iMateDefs
		If Not TypeOf oIMateDef Is CompositeiMateDefinition Then Continue For
		If oIMateDef.Name = "MyCompositeiMateDef" Then
			oCompIMateDef = oIMateDef
			oMatchList = oCompIMateDef.MatchList
			'can now alter the list if wanted/needed
			'can also set new MatchList, or set altered MatchList
			'oCompIMateDef.MatchList = oMatchList
			'oCompIMateDef.SequenceIndex
			'oCompIMateDef.Suppressed = False
		End If
	Next
End If
If IsNothing(oCompIMateDef) Then
	Dim iMatesColl As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
	'iMatesColl.Add(MyiMateDef1)
	oCompIMateDef = iMateDefs.AddCompositeiMateDefinition(iMatesColl, "MyCompositeiMateDef", oMatchList)
End If

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.

If you want and have time, I would appreciate your Vote(s) for My IDEAS :bulb: or you can Explore My CONTRIBUTIONS

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 3

josh.linares-stanley
Enthusiast
Enthusiast

Hi, Thanks for the response. I too have never really used iMates but it is producing some really good results for what I'm trying to achieve. Could be a really nice feature with a bit more development. 

 

Would you be able to clarify what that script does and where it should go? I've edited "myCompositeiMateDef" and placed in both assembly/part but get a error. 

 

Thanks

0 Likes