AnsweredAssumed Answered

Origins coincident mate through swMateCOORDINATE

Question asked by Leon Wurr on Jun 17, 2015
Latest reply on Jun 18, 2015 by Leon Wurr



     Has anyone here managed to add a mate via macro by using the type "swMateCOORDINATE" mate?


     My recorded code selects both the origins of the parts I'm trying to mate, but I keep getting error #4 (Incorrect selections for mate) when it tries to add the mate.

     Even if I comment out the lines of the code that select the origins, and select it manually and try to run it, I still get the same error.


     Any ideas of what may be going wrong?


Dim swApp As Object

Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long

Sub main()

Set swApp = _

Set Part = swApp.ActiveDoc
boolstatus = Part.Extension.SelectByID2("Point1@Origin@Peça1^Assy1-1@Assy1", "EXTSKETCHPOINT", 0, 0, 0, False, 0, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("Point1@Origin", "EXTSKETCHPOINT", 0, 0, 0, True, 0, Nothing, 0)
Dim myMate As Object
Set myMate = Part.AddMate5(20, 0, False, 0, 0, 0, 0, 0, 0, 0, 0, False, False, 0, longstatus)  'swMateCOORDINATE = 20
Part.ClearSelection2 True

If longstatus <> 1 Then swApp.SendMsgToUser "ERROR #" & longstatus

End Sub





2015 SOLIDWORKS API Help - AddMate5 Method (IAssemblyDoc)

2015 SOLIDWORKS API Help - swMateAlign_e Enumeration

2015 SOLIDWORKS API Help - swAddMateError_e Enumeration

2015 SOLIDWORKS API Help - swMateType_e Enumeration