Hi,
I saw a good example of coding of mate modmachine site
Dim asmDoc As AssemblyDocument
asmDoc = inv_App.ActiveDocument
Dim asmDef As AssemblyComponentDefinition
asmDef = asmDoc.ComponentDefinition
Dim face1 As Face
face1 = inv_App.CommandManager.Pick( _
SelectionFilterEnum.kPartFacePlanarFilter, _
"1. Yüzeyi Seçin...")
Dim face2 As Face
face2 = inv_App.CommandManager.Pick( _
SelectionFilterEnum.kPartFacePlanarFilter, _
"2. Yüzeyi Seçin...")
Dim mate As MateConstraint
mate = asmDef.Constraints.AddMateConstraint(face1, face2, 0)
Perfect sample but I need to mate together lots of movement chain parts. I used I-Mate. I-mate make me faster but I need to mate all this parts with the VB.NET API code.
I want to give a name to mate-point of each part. Then I want to make mate with the name of the mate-points. Is this possible?
With above code I need to pick a face by user input every time. This is not so easy. My Code should be below:
Create Inner Chain,
Cretae Outer Chain,
Mate PointInnerX of the Inner chain with the point PointOuterXX of the outer chain. I do not want to pick a mate point everytime?!...
mate = asmDef.Constraints.AddMateConstraint(PointOneNameOfTheFirstPart, PointOneNameOfTheSeconPart, 0)
Is the below code like possible?...
Regards,
Mucip:)
Solved! Go to Solution.
Solved by adam.nagy. Go to Solution.
Hi Mucip,
You could still use iMates to later on hook up the parts with each other programmatically:
http://adndevblog.typepad.com/manufacturing/2013/03/hook-up-a-chain-using-imates.html
I hope this helps.
Cheers,
Hi,
Thanks...
I also find a way in these forums and tryed to increased functioanality little bit more...
The code inserting chain couples and mating them each others... You can increase the chain quantity.
Code is below:
Public Sub iMateResultCreationSample()
'Mucip Alınan yer aşağıda...
'http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/vba-imate-code-for-assy/m-p/2112512/hi...
'http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/Adding-contraints-with-VBA/m-p/760385/...
' Get the component definition of the currently open assembly.
' This will fail if an assembly document is not open.
Dim oAsmCompDef As AssemblyComponentDefinition
Set oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
' Create a new matrix object. It will be initialized to an identity matrix.
Dim oMatrix As Matrix
Set oMatrix = ThisApplication.TransientGeometry.CreateMatrix
' Place the first occurrence.
Dim oOcc1 As ComponentOccurrence
Set oOcc1 = oAsmCompDef.Occurrences.Add("R:\Resimler\Chain_B.ipt", oMatrix)
' Place the second occurrence, but adjust the matrix slightly so they're
' not right on top of each other.
oMatrix.Cell(1, 4) = 10
Dim oOcc2 As ComponentOccurrence
Dim oiMateDef1 As iMateDefinition
'Set oiMateDef1 = oOcc1.iMateDefinitions.Item(1)
Dim oiMateDef2 As iMateDefinition
Dim oiMateResult As iMateResult
Dim Sayac As Long
For Sayac = 2 To 10 ' You may increase the chain quantity with this number...
If ((Sayac Mod 2) = 0) Then
Set oOcc2 = oAsmCompDef.Occurrences.Add("R:\Resimler\Chain_P.ipt", oMatrix)
Set oiMateDef2 = oOcc2.iMateDefinitions.Item(1)
Set oiMateDef1 = oOcc1.iMateDefinitions.Item(1)
Set oiMateResult = oAsmCompDef.iMateResults.AddByTwoiMates(oiMateDef1, oiMateDef2)
Else
Set oOcc2 = oAsmCompDef.Occurrences.Add("R:\Resimler\Chain_B.ipt", oMatrix)
Set oiMateDef1 = oOcc1.iMateDefinitions.Item(2)
Set oiMateDef2 = oOcc2.iMateDefinitions.Item(2)
Set oiMateResult = oAsmCompDef.iMateResults.AddByTwoiMates(oiMateDef1, oiMateDef2)
End If
'Set oiMateResult = oAsmCompDef.iMateResults.AddByTwoiMates(oiMateDef1, oiMateDef2)
Set oOcc1 = oOcc2
Next
End Sub