1 Reply Latest reply on May 8, 2014 3:00 PM by Chris Christy

# Explanation of code

Below is a macro that was recorded and edited by me. It is used to mate to two parts with a distance mate.Could someone explain to me what all the zeros are for?

Dim swApp As Object

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

Sub main()

Set swApp = _
Application.SldWorks

Set Part = swApp.ActiveDoc
Dist = InputBox(" Please enter distance in millimeters")
'Dim myMate As Object
Set myMate = Part.AddMate3(5, 1, False, Dist / 1000, 0, 0, 0, 0, 0, 0, 0, False, longstatus)
'Part.ClearSelection2 True
Part.EditRebuild3

End Sub

• ###### Re: Explanation of code

They are parameters for different types of mates, angle, limit, gear etc. Below is info on it from the API help.

ByVal Flip As System.Boolean, _

ByVal Distance As System.Double, _

ByVal DistanceAbsUpperLimit As System.Double, _

ByVal DistanceAbsLowerLimit As System.Double, _

ByVal GearRatioNumerator As System.Double, _

ByVal GearRatioDenominator As System.Double, _

ByVal Angle As System.Double, _

ByVal AngleAbsUpperLimit As System.Double, _

ByVal AngleAbsLowerLimit As System.Double, _

ByVal ForPositioningOnly As System.Boolean, _

ByRef ErrorStatus As System.Integer _

) As Mate2

#### Parameters

Type of mate as defined in swMateType_e

Type of alignment as defined in swMateAlign_e

Flip

True to flip the component, false otherwise

Distance

Distance value to use with distance or limit mates

DistanceAbsUpperLimit
Absolute maximum distance value (see Remarks
DistanceAbsLowerLimit

Absolute minimum distance value (see Remarks)

GearRatioNumerator

Gear ratio numerator value for gear mates

GearRatioDenominator

Gear ratio denominator value for gear mates

Angle

Angle value to use with angle mates

AngleAbsUpperLimit

Absolute maximum angle value

AngleAbsLowerLimit

Absolute maximum angle value

ForPositioningOnly

True positions the components according to the mating relationship but a mate relationship is not created and returned, false does not

ErrorStatus

Success or error as defined by swAddMateError_e