Here's an iLogic rule I threw together that might do what you want. It is designed to work with an 'active' drawing document (not a part or assembly sketch). Right now it is just set-up to get the first dimension on the active sheet, but you can modify how it get the specific dimension you want another way if you want.
I had to set both the target and the eye to keep it from 'skewing' the view of the drawing sheet, even though I'm specifying 'ApplyWithoutTransition'.
Here's the code:
If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
MsgBox("A Drawing Document must be active for this rule (" & iLogicVb.RuleName & ") to work. Exiting.",vbOKOnly+vbCritical, "WRONG DOCUMENT TYPE")
Exit Sub
End If
Dim oDDoc As DrawingDocument = ThisDrawing.Document
Dim oSheet As Inventor.Sheet = oDDoc.ActiveSheet
'specify which dimension any way you want
Dim oDim As DrawingDimension = oSheet.DrawingDimensions.Item(1)
Dim oLine As LineSegment2d = oDim.DimensionLine
Dim oBox As Box2d = oLine.Evaluator.RangeBox
'Dim oBox As Box2d = oDim.Text.RangeBox
Dim oWidth As Double = oBox.MaxPoint.X - oBox.MinPoint.X
Dim oHeight As Double = oBox.MaxPoint.Y - oBox.MinPoint.Y
Dim oCam As Camera = ThisApplication.ActiveView.Camera
Dim oTarget As Point = ThisApplication.TransientGeometry.CreatePoint(oDim.Text.Origin.X, oDim.Text.Origin.Y, 0)
Dim oEye As Point = ThisApplication.TransientGeometry.CreatePoint(oDim.Text.Origin.X, oDim.Text.Origin.Y, 1)
oCam.Target = oTarget
oCam.Eye = oEye
oCam.SetExtents(oWidth + .25, oHeight + .25)
oCam.ApplyWithoutTransition
If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.
If you have time, please... Vote For My IDEAS 💡or you can Explore My CONTRIBUTIONS
Inventor 2021 Help | Inventor Forum | Inventor Customization Forum | Inventor Ideas Forum
Wesley Crihfield

(Not an Autodesk Employee)