AnsweredAssumed Answered

Mating Macro

Question asked by Alice Caspari on Jul 17, 2014
Latest reply on Jul 17, 2014 by Alice Caspari

I am trying to use a macro to mate two planes, but at the point the macro will run the component currently referred to as "Base Assmbly-1@POWERPACK" will be an unknown assembly that will have a "BAFRONTPLANE" and a "BATOPPLANE" in it. Any ideas?

 

Option Explicit

' ******************************************************************************
' Use to Mate Base Assembly Planes 07/17/14 by CASPARIA
' ******************************************************************************

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", 0, 0, 0, True, 1, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("BAFRONTPLANE@Base Assembly-1@POWER PACK", "PLANE", 0, 0, 0, True, 1, Nothing, 0)
Dim myMate As Object
Set myMate = Part.AddMate3(0, 0, False, 0, 0, 0, 0.001, 0.001, 0, 0.001, 0.001, False, longstatus)
Part.ClearSelection2 True
Part.EditRebuild3

boolstatus = Part.Extension.SelectByID2("Top", "PLANE", 0, 0, 0, True, 1, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("BATOPPLANE@Base Assembly-1@POWER PACK", "PLANE", 0, 0, 0, True, 1, Nothing, 0)
Set myMate = Part.AddMate3(0, 0, False, 0, 0, 0, 0.001, 0.001, 0, 0.001, 0.001, False, longstatus)
Part.ClearSelection2 True
Part.EditRebuild3

End Sub

Outcomes