Message 1 of 2

Not applicable
06-23-2016
03:22 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have written a rule to see if a flat pattern is present and update the dim styles accordingly. It is supposed to change the dim style to 2 decimal places for all general dimensions and 3 decimal places for diameters/holes. My issue is: If there is only a diameter dimension present it will update just fine, but if there is a diameter dimension and a linear dimension it will error out. It seems to me when there are other general dimensions present it changes the class of the diameter dimension, but this is only speculation. Does anyone have any ideas here? My code is below and I have included some images of the error and what happens when it works correctly.
Sub Main() 'set drawing document Dim oDrawDoc As DrawingDocument = ThisDoc.Document Dim oView As DrawingView Dim oSheet As Sheet 'suppress all views that are not flat patterns For Each oSheet In oDrawDoc.Sheets For Each oView In oSheet.DrawingViews If Not oView.IsFlatPatternView = True Then oView.Suppressed = True End If Next Next 'sheet FormatHoles FormatGeneralDims 'unsuppress all views For Each oSheet In oDrawDoc.Sheets For Each oView In oSheet.DrawingViews If oView.Suppressed = True Then oView.Suppressed = False End If Next Next 'sheet End Sub Function FormatHoles 'set drawing document Dim oDrawDoc As DrawingDocument = ThisDoc.Document 'set the style manager Dim oStylesMgr As DrawingStylesManager = oDrawDoc.StylesManager 'declare variables Dim oDiaDim As DiameterGeneralDimension Dim oHoleDimStyle As DimensionStyle Dim oHoleDims As DrawingDimensions Dim oView As DrawingView Dim oSheet As Sheet For Each oSheet In oDrawDoc.Sheets For Each oView In oSheet.DrawingViews If oView.IsFlatPatternView = True Then oHoleDimStyle = oStylesMgr.DimensionStyles.Item("Decimal (3pls)") oHoleDims = oSheet.DrawingDimensions For Each oDiaDim In oHoleDims oDiaDim.Style = oHoleDimStyle Next End If Next 'view Next 'sheet End Function Function FormatGeneralDims 'set drawing document Dim oDrawDoc As DrawingDocument = ThisDoc.Document 'set the style manager Dim oStylesMgr As DrawingStylesManager = oDrawDoc.StylesManager Dim oDim As GeneralDimension Dim oDimStyle As DimensionStyle Dim oDims As DrawingDimensions Dim oView As DrawingView Dim oSheet As Sheet For Each oSheet In oDrawDoc.Sheets For Each oView In oSheet.DrawingViews If oView.IsFlatPatternView = True Then oDims = oSheet.DrawingDimensions oDimStyle = oStylesMgr.DimensionStyles.Item("Decimal (ANSI)") oHoleDimStyle = oStylesMgr.DimensionStyles.Item("Decimal (3pls)") For Each oDim In oDims If oDim.Style Is oHoleDimStyle Then 'Do Nothing Else oDim.Style = oDimStyle End If Next End If Next 'view Next 'sheet End Function
Solved! Go to Solution.