@Maxim-CADman77
Even though it's common practice to attach demensions to auxiliary geometry, keep in mind that this geometry is not part of the drawingview object either. We have to work with how the API is built and what's exposed to us.
@Maxim-CADman77 wrote:
I see. In fact attaching dimension to auxiliary geometry instead of model edge is a common practice.
Yet my task perobably can be simplified to solvable with couple assumptions/limitations ...
Let say:
1. I'm interested in analyzing only Linear dimensions (i believe there is no much sense in breaking other dimension types).
2. Healthy drawing should not contain any view overlaping or unattached dimensions
(parent view then can be determined indirectly as the one which range box "catches" both dimension attachement points, right?)
Something like this maybe?
Sub Main
Dim oView As DrawingView
Dim oDrawDim As GeneralDimension = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingDimensionFilter, "Select dimension")
Dim oSheet As Sheet = ThisDoc.Document.ActiveSheet
If oDrawDim.Type <> ObjectTypeEnum.kLinearGeneralDimensionObject
MsgBox("Not a linear dimension")
Exit Sub
End If
Dim oIntPos1 As Point2d = oDrawDim.IntentOne.PointOnSheet
Dim oIntPos2 As Point2d = oDrawDim.IntentTwo.PointOnSheet
For Each dW As DrawingView In oSheet.DrawingViews
If pointInView(oIntPos1, dW) Or pointInView(oIntPos2, dW) 'Change to "And" if you want to check if both is in view.
oView = dW
Exit For
End If
Next
If oView Is Nothing
MsgBox("Dimension type not supported")
Exit Sub
End If
MsgBox("Scale factor (double) = " & oView.Scale)
MsgBox("Scale string = " & oView.ScaleString)
End Sub
Function pointInView(ByRef pt As Point2d, ByRef oView As DrawingView) As Boolean
If pt.X >= oView.Left AndAlso pt.X <= (oView.Left + oView.Width)
If pt.Y <= oView.Top AndAlso pt.Y >= (oView.Top - oView.Height)
Return True
End If
End If
Return False
End Function
I think it should be enough to check that at least one of the intent points is within the boundary of the view.