i wrote the concept below. Could u help me to rectify errors in this program...
'
Sub InsertConstraint()
Dim oDoc As AssemblyDocument
Set oDoc = ThisApplication.ActiveDocument
Dim oSelect As SelectTypeEnum
oSelect = Inventor.SelectionPriorityEnum.kEdgeSelectionPriority
'In this 10 sec i will select two round edges in an assembly
Application.Wait (Now + TimeValue("0:00:10"))
Dim oAsmCompDef As AssemblyComponentDefinition
Set oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
' Set a reference to the select set.
Dim oSelectSet As SelectSet
Set oSelectSet = ThisApplication.ActiveDocument.SelectSet
' Get the two edges from the select set.
Dim oEdge1 As Edge
Dim oEdge2 As Edge
Set oEdge1 = oSelectSet.Item(1)
Set oEdge2 = oSelectSet.Item(2)
' Create the insert constraint between the parts.
Dim oInsert As InsertConstraint
Set oInsert = oAsmCompDef.Constraints.AddInsertConstraint(oEdge1, oEdge2, True, 0)
oSelect = Inventor.SelectionPriorityEnum.kComponentSelectionPriority
End Sub
Try below code:
Sub InsertConstraintSample() Dim oDoc As AssemblyDocument Set oDoc = ThisApplication.ActiveDocument Dim oAsmCompDef As AssemblyComponentDefinition Set oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition ' Get the two edges from the select set. Dim oEdge1 As Edge Dim oEdge2 As Edge Set oEdge1 = ThisApplication.CommandManager.Pick(kPartEdgeCircularFilter, "Select a circular edge in a component") Set oEdge2 = ThisApplication.CommandManager.Pick(kPartEdgeCircularFilter, "Select a circular edge in another component") ' Create the insert constraint between the parts. Dim oInsert As InsertConstraint Set oInsert = oAsmCompDef.Constraints.AddInsertConstraint(oEdge1, oEdge2, True, 0) End Sub
Can't find what you're looking for? Ask the community or share your knowledge.