Purge styles?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello
Im trying to simulate the purge styles button in amongst other things but am always left with outstanding styles in the list when i go back to the manage>purge button.
1. Is the stylesmanager.styles collection a collection of all of the other styles? Or do i need to loop through each of the styles manager collections deleting them individually?
In the first instance i had this code:
Sub PurgeStyles()
Dim oDoc As Inventor.DrawingDocument
Set oDoc = ThisApplication.ActiveDocument
Dim oStyles As DrawingStylesManager
Set oStyles = oDoc.StylesManager
Dim ostyle As Style
For Each ostyle In oStyles.Styles
If (ostyle.StyleLocation = kLocalStyleLocation) And (ostyle.InUse = False) Then
ostyle.Delete
End If
Next
End Sub
In the second i went to this extenet:
Sub PurgeStyles2()
Dim oDoc As Inventor.DrawingDocument
Set oDoc = ThisApplication.ActiveDocument
Dim oStyles As DrawingStylesManager
Set oStyles = oDoc.StylesManager
Dim oActive As DrawingStandardStyle
Dim oBalloon As BalloonStyle
Dim oCMark As CentermarkStyle
Dim oDimStyle As DimensionStyle
Dim oFCFS As FeatureControlFrameStyle
Dim oHTS As HoleTableStyle
Dim oLayer As Layer
Dim oLeader As LeaderStyle
Dim oODS As ObjectDefaultsStyle
Dim oSS As DrawingStandardStyle
Dim ostyle As Style
Dim oSTS As SurfaceTextureStyle
Dim oText As TextStyle
For Each oBalloon In oStyles.BalloonStyles
If (oBalloon.StyleLocation = kLocalStyleLocation) And (oBalloon.InUse = False) Then
oBalloon.Delete
End If
Next
For Each oCMark In oStyles.CentermarkStyles
If (oCMark.StyleLocation = kLocalStyleLocation) And (oCMark.InUse = False) Then
oCMark.Delete
End If
Next
For Each oDimStyle In oStyles.DimensionStyles
If (oDimStyle.StyleLocation = kLocalStyleLocation) And (oDimStyle.InUse = False) Then
oDimStyle.Delete
End If
Next
For Each oFCFS In oStyles.FeatureControlFrameStyles
If (oFCFS.StyleLocation = kLocalStyleLocation) And (oFCFS.InUse = False) Then
oFCFS.Delete
End If
Next
For Each oHTS In oStyles.HoleTableStyles
If (oHTS.StyleLocation = kLocalStyleLocation) And (oHTS.InUse = False) Then
oHTS.Delete
End If
Next
For Each oLayer In oStyles.Layers
If (oLayer.StyleLocation = kLocalStyleLocation) And (oLayer.InUse = False) Then
oLayer.Delete
End If
Next
For Each oLeader In oStyles.LeaderStyles
If (oLeader.StyleLocation = kLocalStyleLocation) And (oLeader.InUse = False) Then
End If
Next
For Each oODS In oStyles.ObjectDefaultsStyles
If (oODS.StyleLocation = kLocalStyleLocation) And (oODS.InUse = False) Then
oODS.Delete
End If
Next
For Each oSS In oStyles.StandardStyles
If (oSS.StyleLocation = kLocalStyleLocation) And (oSS.InUse = False) Then
oSS.Delete
End If
Next
For Each ostyle In oStyles.Styles
If (ostyle.StyleLocation = kLocalStyleLocation) And (ostyle.InUse = False) Then
ostyle.Delete
End If
Next
For Each oSTS In oStyles.SurfaceTextureStyles
If (oSTS.StyleLocation = kLocalStyleLocation) And (oSTS.InUse = False) Then
oSTS.Delete
End If
Next
For Each oText In oStyles.TextStyles
If (oText.StyleLocation = kLocalStyleLocation) And (oText.InUse = False) Then
oText.Delete
End If
Next
End Sub
Am i way off the mark or just missing some small point?
Thanks.
Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
---------------------------------------------------------------------------------------------------------------------------
Inventor 2010 Certified Professional
Currently using 2023 Pro