Macro - Determine CirPattern Axis Type

SW2013 SP5

I am using a subroutine to determine the center axis of the selected circular pattern.  I am running into an issue when trying to get the Axis Property from the circular pattern feature data.

  • Get the definition of the pattern (Set myCirPatternData = myFeat.GetDefinition)
  • Access the selections for the pattern (If myCirPatternData.AccessSelections(swModel, Nothing) Then)
  • Test the Axis type (myCirPatternData.GetAxisType)

Here's where I have the issue.  If the pattern axis is either an RefAxis or an Edge it works well.  If the axis is a Face the "GetAxisType" returns a 0 (zero) - which is supposed to be an RefAxis.  The "GetAxisType" method seems to be the only way to determine what makes up the pattern axis.  There has to be another way...

Function CylinderPatternAxisOrigin(myFeat As SldWorks.Feature) As Double()

  Dim myCirPatternData As SldWorks.CircularPatternFeatureData

  Dim swEdge As SldWorks.Edge

  Dim vFace As Variant

  Dim swFace(1) As SldWorks.Face2

  Dim swSurf(1) As SldWorks.Surface

  Dim swCylSurf As SldWorks.Surface

  Dim swFlatSurf As SldWorks.Surface

  Dim swRefAxis As SldWorks.RefAxis

  Dim swAxisFeature As SldWorks.Feature

  Dim swTestFeature As SldWorks.Feature

  Dim swAxisObject As Object

  Dim vAxisParam As Variant

  Dim nPt(2) As Double

  Dim vCylinder As Variant

  Dim strTest As String

  ' PatternFeatureArray

  Set myCirPatternData = myFeat.GetDefinition

  If myCirPatternData.AccessSelections(swModel, Nothing) Then

    ' If the axis is a refAxis

    If myCirPatternData.GetAxisType = 0 Then

      If myCirPatternData.Axis.GetTypeName() = "RefAxis" Then

        Set swAxisFeature = myCirPatternData.Axis

        Set swRefAxis = swAxisFeature.GetSpecificFeature2

        vAxisParam = swRefAxis.GetRefAxisParams

        nPt(0) = vAxisParam(0): nPt(1) = vAxisParam(1): nPt(2) = vAxisParam(2)

      End If

    ElseIf myCirPatternData.GetAxisType = 1 Then

      Set swEdge = myCirPatternData.Axis

      vFace = swEdge.GetTwoAdjacentFaces2

      Set swFace(0) = vFace(0): Set swFace(1) = vFace(1)

      Set swSurf(0) = swFace(0).GetSurface: Set swSurf(1) = swFace(1).GetSurface

      If swSurf(0).IsCylinder Then

        Set swCylSurf = swSurf(0): Set swFlatSurf = swSurf(1)

      Else

        Set swCylSurf = swSurf(1): Set swFlatSurf = swSurf(0)

      End If

      vCylinder = swCylSurf.CylinderParams

      nPt(0) = vCylinder(0): nPt(1) = vCylinder(1): nPt(2) = vCylinder(2)

    End If

  End If

  myCirPatternData.ReleaseSelectionAccess

  CylinderPatternAxisOrigin = nPt

End Function

SolidworksApi macros