AnsweredAssumed Answered

Can't change Fill Pattern setting to "Geometry Pattern"

Question asked by Mark Soldan on Nov 30, 2020
Latest reply on Dec 2, 2020 by Fifi Riri

I found a lot of parts (gears, splines, etc) at my job have patterns that take a LONG time to rebuild because they are not set to be "Geometry Patterns".  I made a macro that goes through every feature in a part and sets every pattern feature to "Geometry Pattern"  It works well for Mirror, Circular, Curve Driven, Linear, Sketch Driven, Table DrivenPatterns.  I cannot get it to work with Fill Patterns (APattern).  The code runs fine, no errors, but the "Geometry Pattern" setting won't change (from true to false, or vice versa).

 

Here's a subset of the code:

 

Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swFeat As SldWorks.Feature
Dim swFillPatternFeatureData As SldWorks.IFillPatternFeatureData
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swFeat = swModel.FirstFeature

While Not swFeat Is Nothing
Select Case swFeat.GetTypeName
Case "APattern"
Set swFillPatternFeatureData = swFeat.GetDefinition
swFillPatternFeatureData.GeometryPattern = True
swFeat.ModifyDefinition swFillPatternFeatureData, swModel, Nothing
End Select
Set swFeat = swFeat.GetNextFeature
Wend
End Sub

The other thing I have tried is changing data type "SldWorks.IFillPatternFeatureData" to "SldWorks.FillPatternFeatureData" [dropped the "I"]

Dim swFillPatternFeatureData As SldWorks.IFillPatternFeatureData

I know my code is good because it works well for every other pattern time.  There's clearly something fishy about fill patterns since both "FillPattern..." and "IFillPattern..." date types work.

 

Thank you for taking a look at this.

Outcomes