Анна Ахмаметьева пишет:Пишу программу на VB.Net
Тогда можно использовать примеры на VBA в Инвенторе. Если компоненты не создаются программно, а используются готовые, то можно в них заранее создать нужные сопряжения - конструктивные пары (iMate) типа совмещения, заподлицо и т.п. И использовать их для наложения зависимостей при вставке. Вот пример для VBA (его несложно перевести на VB.NET). Используется деталь по адресу "C:\TempiMatePart.ipt", на одну грань которой наложена зависимость совмещения с именем "iMate:1"...
Public Sub iMateResultCreationSample()
' 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("C:\TempiMatePart.ipt", oMatrix)
' Place the second occurrence
Dim oOcc2 As ComponentOccurrence
Set oOcc2 = oAsmCompDef.Occurrences.Add("C:\TempiMatePart.ipt", oMatrix)
' Look through the iMateDefinitions defined for the first occurrence
' and find the one named "iMate:1". This loop demonstrates using the
' Count and Item properties of the iMateDefinitions object.
Dim i As Long
Dim oiMateDef1 As iMateDefinition
For i = 1 To oOcc1.iMateDefinitions.Count
If oOcc1.iMateDefinitions.Item(i).Name = "iMate:1" Then
Set oiMateDef1 = oOcc1.iMateDefinitions.Item(i)
Exit For
End If
Next
If oiMateDef1 Is Nothing Then
MsgBox "An iMate definition named ""iMate:1"" does not exist in " & oOcc1.Name
Exit Sub
End If
' Look through the iMateDefinitions defined for the second occurrence
' and find the one named "iMate:1". This loop demonstrates using the
' For Each method of iterating through a collection.
Dim oiMateDef2 As iMateDefinition
Dim bFoundDefinition As Boolean
For Each oiMateDef2 In oOcc2.iMateDefinitions
If oiMateDef2.Name = "iMate:1" Then
bFoundDefinition = True
Exit For
End If
Next
If Not bFoundDefinition Then
MsgBox "An iMate definition named ""iMate:1"" does not exist in " & oOcc2.Name
Exit Sub
End If
' Create an iMate result using the two definitions.
Dim oiMateResult As iMateResult
Set oiMateResult = oAsmCompDef.iMateResults.AddByTwoiMates(oiMateDef1, oiMateDef2)
End Sub