Sub main()
' Open a drawing document and select two parallel linear curves in same drawing view first.
Dim oApp As Inventor.Application
set oApp = ThisApplication
Dim oDoc As Document
set oDoc = oApp.ActiveDocument
If Not (oDoc Is Nothing) Then
If Not (oDoc.DocumentType = kDrawingDocumentObject) Then
MsgBox "Please activate a drawing document for this sample.", vbCritical, "Inventor"
Exit Sub
End If
Else
MsgBox "Please open a drawing document for this sample.", vbCritical, "Inventor"
Exit Sub
End If
If Not (oDoc.SelectSet.Count = 2) Then
MsgBox "Please select two parallel linear drawing curves from same drawing view for this sample.", vbCritical, "Inventor"
Exit Sub
ElseIf (oDoc.SelectSet(1).Type <> kDrawingCurveSegmentObject Or oDoc.SelectSet(1).Type <> kDrawingCurveSegmentObject) Then
MsgBox "Please select two parallel linear drawing curves from same drawing view for this sample.", vbCritical, "Inventor"
Exit Sub
End If
Dim oCurve1 As DrawingCurve, oCurve2 As DrawingCurve
set oCurve1 = oDoc.SelectSet(1).Parent
set oCurve2 = oDoc.SelectSet(2).Parent
Dim oSheet As Sheet
set oSheet = oCurve1.Parent.Parent
' Create two GeometryIntent based on the selected drawing curve segments.
Dim oIntent1 As GeometryIntent, oIntent2 As GeometryIntent
set oIntent1 = oSheet.CreateGeometryIntent(oCurve1)
set oIntent2 = oSheet.CreateGeometryIntent(oCurve2)
Dim oTextPos As Point2d
set oTextPos = oApp.TransientGeometry.CreatePoint2d(12, 12)
' Create the linear foreshortened dimension
Dim oLinearForeshortenedDim As LinearGeneralDimension
'oLinearForeshortenedDim = oSheet.DrawingDimensions.GeneralDimensions.AddLinearForeshortened(oTextPos, oIntent1, oIntent2, True)
oLinearForeshortenedDim = oSheet.DrawingDimensions.GeneralDimensions.AddLinear(oTextPos, oIntent1, oIntent2)
End Sub