Get Space Type form selected Pattern Feature

Hi,

I would like to let user select pattern feature and do something with it. But it is necessary to split code for SpaceType "Offset" and SpaceType "List". How do I get spaceType from selected Pattern Feature? I cabt find out how use GeometricUtilities.PatternSpacing.SpacingType to return value as String.

The code below shows how to get the space type for a few pattern types (the other types will be similar). Instead of extracting the spacing type as a string and doing a string comparison; I suggest comparing the spacing type to the enumeration value. This will lead to more robust code.

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF

Module Module1

Dim theSession As Session = Session.GetSession()
Dim theUfSession As UFSession = UFSession.GetUFSession()

Dim theUI As UI = UI.GetUI()
Dim lw As ListingWindow = theSession.ListingWindow

Sub Main()

Dim workPart As Part = theSession.Parts.Work
Dim myPatternFeat As Features.PatternFeature = Nothing
Dim found As Boolean = False

For Each temp As Features.Feature In workPart.Features
If TypeOf (temp) Is Features.PatternFeature Then
myPatternFeat = temp
found = True
Exit For
End If
Next

If Not found Then
Return
End If

Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "NXJ")

lw.Open()

Dim patternFeatureBuilder1 As Features.PatternFeatureBuilder
patternFeatureBuilder1 = workPart.Features.CreatePatternFeatureBuilder(myPatternFeat)
lw.WriteLine("pattern feature found: " & myPatternFeat.GetFeatureName)
lw.WriteLine("pattern method: " & patternFeatureBuilder1.PatternMethod.ToString)
lw.WriteLine("pattern definition: " & patternFeatureBuilder1.PatternService.PatternType.ToString)

Select Case patternFeatureBuilder1.PatternService.PatternType
Case Is = GeometricUtilities.PatternDefinition.PatternEnum.Linear
lw.WriteLine("pattern spacing: " & patternFeatureBuilder1.PatternService.RectangularDefinition.XSpacing.SpaceType.ToString)

Case Is = GeometricUtilities.PatternDefinition.PatternEnum.Circular
lw.WriteLine("pattern spacing: " & patternFeatureBuilder1.PatternService.CircularDefinition.AngularSpacing.SpaceType.ToString)

Case Is = GeometricUtilities.PatternDefinition.PatternEnum.Polygon
lw.WriteLine("pattern spacing: " & patternFeatureBuilder1.PatternService.PolygonDefinition.PolygonSpacing.SpaceType.ToString)

Case Is = GeometricUtilities.PatternDefinition.PatternEnum.Spiral
lw.WriteLine("pattern spacing: " & patternFeatureBuilder1.PatternService.SpiralDefinition.PitchAlongSpiral.SpaceType.ToString)

Case Is = GeometricUtilities.PatternDefinition.PatternEnum.AlongPath
lw.WriteLine("pattern spacing: " & patternFeatureBuilder1.PatternService.AlongPathDefinition.XOnPathSpacing.SpaceType.ToString)

Case Is = GeometricUtilities.PatternDefinition.PatternEnum.General

Case Is = GeometricUtilities.PatternDefinition.PatternEnum.Reference

Case Is = GeometricUtilities.PatternDefinition.PatternEnum.Mirror

Case Is = GeometricUtilities.PatternDefinition.PatternEnum.Helix

End Select

patternFeatureBuilder1.Destroy()

lw.Close()

End Sub

Public Function GetUnloadOption(ByVal dummy As String) As Integer

'Unloads the image immediately after execution within NX
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately

End Function

End Module