Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am trying to automatically arrange dimensions on a sheet using different spacing based on whether the dimension is a vertical or horizontal one. How do you determine if the dimension is vertical or horizontal? Please see the code below.
Sub AutoDimArrange()
Dim oDoc As DrawingDocument
Set oDoc = ThisApplication.ActiveDocument
' Set a reference to the active sheet
Dim oSheet As Sheet
Set oSheet = oDoc.ActiveSheet
Dim oDrawingDim As DrawingDimension
Dim oDrawingDimensions As DrawingDimensions
Set oDrawingDimensions = oSheet.DrawingDimensions
Dim oDimsToBeArrangedVertical As ObjectCollection
Dim oDimsToBeArrangedHorizontal As ObjectCollection
Set oDimsToBeArrangedVertical = ThisApplication.TransientObjects.CreateObjectCollection
Set oDimsToBeArrangedHorizontal = ThisApplication.TransientObjects.CreateObjectCollection
Dim oStyle As DimensionStyle
Set oStyle = oDoc.StylesManager.DimensionStyles.Item("MRK")
Dim oScale As Double
oScale = 2.54
For Each oDrawingDim In oDrawingDimensions
If TypeOf oDrawingDim Is LinearGeneralDimension Or TypeOf oDrawingDim Is AngularGeneralDimension Then
'If oDrawingDim.DimensionLine Then
' oDrawingDim.CenterText
' Call oDimsToBeArrangedVertical.Add(oDrawingDim)
'ElseIf oDrawingDim Then
oDrawingDim.CenterText
Call oDimsToBeArrangedHorizontal.Add(oDrawingDim)
'End If
End If
Next
'oStyle.Extension = 0.125 * oScale
'oStyle.OriginOffset = 0.063 * oScale
'oStyle.Gap = 0.031 * oScale
'oStyle.spacing = 0.25 * oScale
'oStyle.PartOffset = 0.125 * oScale
'Call oDrawingDimensions.Arrange(oDimsToBeArrangedVertical)
oStyle.Extension = 0.125 * oScale
oStyle.OriginOffset = 0.063 * oScale
oStyle.Gap = 0.031 * oScale
oStyle.spacing = 0.375 * oScale
oStyle.PartOffset = 0.125 * oScale
Call oDrawingDimensions.Arrange(oDimsToBeArrangedHorizontal)
End Sub
Solved! Go to Solution.