Message 1 of 8
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I need your help about how to add mate constrain by using API.
I'd like to connect a conduit (left) and UNV (right)
My Code is below,
Sub AddMateTest01()
' Add Mate constrain sammple
' Cylindrical Face of Conduit and Work Axis od Clamp
Dim oDoc As Inventor.AssemblyDocument
Set oDoc = ThisApplication.ActiveDocument
'select couduit
Dim oConduitFace As Inventor.FaceProxy
Set oConduitFace = ThisApplication.CommandManager.Pick(kPartFaceCylindricalFilter, "select couduit")
Dim oUNV_Comp As Inventor.ComponentOccurrence
Set oUNV_Comp = ThisApplication.CommandManager.Pick(kAssemblyOccurrenceFilter, "select UNIV")
'select UNV
Dim oWx As Inventor.WorkAxis
Set oWx = oUNV_Comp.Definition.WorkAxes.Item("Wx_Unv")
'Create Proxy
Dim oWxProxy As Inventor.WorkAxisProxy
Call oUNV_Comp.CreateGeometryProxy(oWx, oWxProxy)
'Add Mate
Dim oMate As Inventor.MateConstraint
Set oMate = oDoc.ComponentDefinition.Constraints.AddMateConstraint(oConduitFace, oWxProxy, 0)
End Sub
Sub AddMateTest02()
' Add Mate constrain sammple
' Cylindrical Face of Conduit and Work Axis od Clamp
Dim oDoc As Inventor.AssemblyDocument
Set oDoc = ThisApplication.ActiveDocument
'select couduit
Dim oConduitFace As Inventor.FaceProxy
Set oConduitFace = ThisApplication.CommandManager.Pick(kPartFaceCylindricalFilter, "select couduit")
Dim oUNV_Comp As Inventor.ComponentOccurrence
Set oUNV_Comp = ThisApplication.CommandManager.Pick(kAssemblyOccurrenceFilter, "select UNIV")
'Get Wx of Conduit
Dim oWxConduit As Inventor.WorkAxis
Set oWxConduit = oConduitFace.ContainingOccurrence.Definition.WorkAxes.Item(3)
Dim oWxConduitProxy As Inventor.WorkAxisProxy
oConduitFace.ContainingOccurrence.CreateGeometryProxy oWxConduit, oWxConduitProxy
'select UNV
Dim oWx As Inventor.WorkAxis
Set oWx = oUNV_Comp.Definition.WorkAxes.Item("Wx_Unv")
'Create Proxy
Dim oWxProxy As Inventor.WorkAxisProxy
oUNV_Comp.CreateGeometryProxy oWx, oWxProxy
'Add Mate
Dim oMate As Inventor.MateConstraint
Set oMate = oDoc.ComponentDefinition.Constraints.AddMateConstraint(oWxConduitProxy, oWxProxy, 0)
End Sub
1st program AddMateTest01 will stop by Error at line 27.
2nd progra will OK.
The difference is whether using Face proxy or work axis proxy for constraint.
But I want use Face proxy for mate constrain.
Can you tell me how I can add constrain correctly?
I attached the Sample project and movie.
Regards,
-YO
Octave.Lab
https://note.com/yo420186
Octave.Lab
https://note.com/yo420186
Solved! Go to Solution.