AnsweredAssumed Answered

Editing A Mate In API Help

Question asked by Aj Jones on Sep 6, 2012
Latest reply on Sep 12, 2012 by Aj Jones

First of all I will warn you that I am new to VBA and working with the API.  I've been recording macros and editing them, but I can't seem to get my API to edit a distant mate that already exists. 

 

So you know, I did search a lot and try a lot of different things with these examples but I still can't get it to work:

http://help.solidworks.com/2012/English/api/sldworksapi/Edit_Mate_Example_VB.htm

https://forum.solidworks.com/message/276259

https://forum.solidworks.com/thread/30801

https://forum.solidworks.com/message/76714

http://help.solidworks.com/2012/English/api/sldworksapi/SolidWorks.Interop.sldworks~SolidWorks.Interop.sldworks.IAssemblyDoc~EditMate2.html

 

Below is my code that I currently have.  I read what all the numbers / TRUE & FALSE stands for in the EditMate2 and SelectByID2 commands, but I'm still not getting this to work.  I just want it to change the distant mate that already exists.  The distant mate is called "DEPTH", and I want to change it to 150 (or whatever I type in).  Thank you in advance

 

Dim swApp As Object

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

 

Sub main()

 

Set swApp = _
Application.SldWorks

 

Set Part = swApp.ActiveDoc
boolstatus = Part.Extension.SelectByID2("DEPTH", "MATE", 0, 0, 0, False, 0, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("", "FACE", -0.338201, -0.015875, -1.1684, True, 1, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("", "FACE", 0.354076, -1.58749999999999E-02, -4.4704, True, 1, Nothing, 0)
Part.EditMate2 5, 0, False, 150, 150, 150, 0, 0, 0, 0, 0, longstatus
Part.ClearSelection2 True
Part.EditRebuild3

 

End Sub

Outcomes