This code crash systematically SolidWorks:
Dim swApp As SldWorks.SldWorks
Sub main()
Set swApp = Application.SldWorks
Dim swRootModel As SldWorks.ModelDoc2: Set swRootModel = swApp.ActiveDoc
Dim i As Integer
Dim swFeat As SldWorks.Feature
Dim swMirrorFeat As SldWorks.MirrorPartFeatureData
If swRootModel Is Nothing Then Exit Sub
For i = 0 To swRootModel.GetFeatureCount - 1
Set swFeat = swRootModel.FeatureByPositionReverse(i)
If Not swFeat Is Nothing Then
'Debug.Print swFeat.Name & " [" & swFeat.GetTypeName & " / " & swFeat.GetTypeName2 & "]"
If swFeat.GetTypeName = "MirrorStock" Then
Debug.Print "[*] NAME: " & swFeat.Name
Set swMirrorFeat = swFeat.GetDefinition
If Not swMirrorFeat Is Nothing Then
Debug.Print " [*] AbsorbedSketches : " & swMirrorFeat.AbsorbedSketches
Debug.Print " [*] Axes : " & swMirrorFeat.Axes
Debug.Print " [*] CoordinateSystems : " & swMirrorFeat.CoordinateSystems
Debug.Print " [*] CosmeticThreads : " & swMirrorFeat.CosmeticThreads
Debug.Print " [*] CustomProperties : " & swMirrorFeat.CustomProperties
Debug.Print " [*] CutListProperties : " & swMirrorFeat.CutListProperties
Debug.Print " [*] DimXpertAnnotations : " & swMirrorFeat.DimXpertAnnotations
Debug.Print " [*] HoleWizardData : " & swMirrorFeat.HoleWizardData
Debug.Print " [*] ModelDimensions : " & swMirrorFeat.ModelDimensions
Debug.Print " [*] PathName : " & swMirrorFeat.PathName
Debug.Print " [*] Planes : " & swMirrorFeat.Planes
Debug.Print " [*] SheetMetalInformation: " & swMirrorFeat.SheetMetalInformation
Debug.Print " [*] SolidBodies : " & swMirrorFeat.SolidBodies
Debug.Print " [*] SurfaceBodies : " & swMirrorFeat.SurfaceBodies
Debug.Print " [*] UnabsorbedSketches : " & swMirrorFeat.UnabsorbedSketches
Debug.Print " [*] UnlockedProperties : " & swMirrorFeat.UnlockedProperties
'swMirrorFeat.AbsorbedSketches = False
'swMirrorFeat.Axes = False
'swMirrorFeat.CoordinateSystems = False
'swMirrorFeat.CosmeticThreads = False
'swMirrorFeat.CustomProperties = False
'swMirrorFeat.CutListProperties = False
'swMirrorFeat.DimXpertAnnotations = False
'swMirrorFeat.HoleWizardData = False
'swMirrorFeat.ModelDimensions = False
'swMirrorFeat.PathName
'swMirrorFeat.Planes = False
'swMirrorFeat.SheetMetalInformation = False
'swMirrorFeat.SolidBodies
'swMirrorFeat.SurfaceBodies = False
'swMirrorFeat.UnabsorbedSketches = False
'swMirrorFeat.UnlockedProperties
swMirrorFeat.AccessSelections swRootModel, Nothing
swFeat.ModifyDefinition swMirrorFeat, swRootModel, Nothing
swMirrorFeat.ReleaseSelectionAccess
'swFeat.Select2 False, 0
'Set swFeat = swRootModel.SelectionManager.GetSelectedObject6(1, -1)
'Set swMirrorFeat = swFeat.GetDefinition
'swMirrorFeat.AccessSelections swRootModel, Nothing
'swFeat.ModifyDefinition swMirrorFeat, swRootModel, Nothing
'swMirrorFeat.ReleaseSelectionAccess
Exit Sub
End If
End If
End If
Next i
End Sub
The problem is this line:
swFeat.ModifyDefinition swMirrorFeat, swRootModel, Nothing
There is a method to update Mirrored Part ?
Thanks.
SolidworksApi/macros