Solidworks macro - mating planes
- From: yochris77 <yochris77@xxxxxxxxx>
- Date: 27 Apr 2007 23:15:18 -0700
I have no knowledge on how to create macros in Solidworks.
I have used the Macro recorder and came up with a macro which is
nearly what I want. I would like to be in any assembly, select 2
parts, assemblies or a part and an assembly and have it mate the Top
plane of one to the top plane of another, Front plane of other to
Front plane etc.
Is there a better way to do this??
This is what I have so far - it will not work if the parts/assemblies
are different names:
Dim swApp As Object
Dim Part As Object
Dim SelMgr As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Dim Feature As Object
Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Set SelMgr = Part.SelectionManager
boolstatus = Part.Extension.SelectByID2("Front@Dual Base Plate
Assy-1@QX10 Dual Base Assy", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("Front", "PLANE", 0, 0, 0,
True, 0, Nothing, 0)
Set Feature = Part.AddMate2(0, -1, False, 0, 0, 0, 1, 1,
1.570796326795, 0.5235987755983, 0.5235987755983, longstatus)
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID2("Top", "PLANE", 0, 0, 0, True,
1, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("Top@Dual Base Plate
Assy-1@QX10 Dual Base Assy", "PLANE", 0, 0, 0, True, 1, Nothing, 0)
Set Feature = Part.AddMate2(0, -1, False, 0.0107, 0, 0, 1, 1, 0,
0.5235987755983, 0.5235987755983, longstatus)
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID2("Right@Dual Base Plate
Assy-1@QX10 Dual Base Assy", "PLANE", 0, 0, 0, True, 1, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("Right", "PLANE", 0, 0, 0,
True, 1, Nothing, 0)
Set Feature = Part.AddMate2(0, -1, False, 0, 0, 0, 1, 1,
1.570796326795, 0.5235987755983, 0.5235987755983, longstatus)
Part.ClearSelection2 True
End Sub
Any help appreciated.
Chris
.
- Prev by Date: Re: Hole callout variables
- Next by Date: Re: SimMechanics Vs SolidWorks COSMOSMotion
- Previous by thread: Question on *** Metal Capabilities
- Next by thread: Unable to flatten bends in *** metal part
- Index(es):