AnsweredAssumed Answered

Mating Planes API

Question asked by Sam Pike on May 9, 2018
Latest reply on May 10, 2018 by Sam Pike

Hello, I for the life of me cannot figure this out. Hoping someone can help me out.

What I am trying to do is write an API to coincident mate the Front Plane (Of the Assembly) to a part plane Called "Array Vert."

Then I will do the same with the Right Plane (Of the Assembly) to the part called "Array Horz".

The part name always changes but always has these two planes, specially created for this part.

The part/assembly are part of a template, that is why the part name always changes.

I am not sure how to make the API look inside of the tree for the part plane (Array Vert. or the Array Horz.) and select the plane before making the coincident mate.

 

Here is what I have so far. Any help would be appreciated. The trial name is something I quick made up for this.

 

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("Front Plane", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("Array Vert@Trial-1@Assem3", "PLANE", 0, 0, 0, True, 0, Nothing, 0)

' Mate
Dim swMate As Mate2
Set swMate = Part.AddMate5(0, 0, False, 0.329922578613554, 0.0254, 0.0254, 0.0254, 0.0254, 0, 0.5235987755983, 0.5235987755983, False, False, 0, longstatus)
Part.ClearSelection2 True
Part.EditRebuild3

boolstatus = Part.Extension.SelectByID2("Array Horz@Trial-1@Assem3", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("Right Plane", "PLANE", 0, 0, 0, True, 0, Nothing, 0)

' Mate
Set swMate = Part.AddMate5(0, 0, False, 0.110371086679135, 0.0254, 0.0254, 0.0254, 0.0254, 0, 0.5235987755983, 0.5235987755983, False, False, 0, longstatus)
Part.ClearSelection2 True
Part.EditRebuild3

End Sub

Outcomes