Blog · Inventor · 29 Sep 2026 · 3 min read

Can AI add dimensions to Inventor drawings? A working API example

Yes: an AI agent can write and run the Inventor API code that places dimensions. Here is the code it starts from, with the same API calls we ran on a real drawing, and the four things that trip it up: units, intents, placement and checking the result.

Adding dimensions by hand is the slowest part of producing cutting drawings. In Autodesk Inventor it can be automated through the API, and an AI agent can write that code for you: an iLogic rule, or an external program that drives Inventor. This guide shows the basic pattern the agent works from, with an example we ran on a real drawing.

The objects involved

The example

This iLogic rule finds the longest horizontal line in the first view of the active sheet and adds a horizontal dimension above it.

Sub Main()
    Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument
    Dim oSheet As Sheet = oDoc.ActiveSheet
    Dim oView As DrawingView = oSheet.DrawingViews.Item(1)
    Dim oTG As TransientGeometry = ThisApplication.TransientGeometry

    ' find the longest horizontal line in the view
    Dim best As DrawingCurve = Nothing
    Dim bestLen As Double = 0
    For Each oCurve As DrawingCurve In oView.DrawingCurves
        If oCurve.CurveType = CurveTypeEnum.kLineSegmentCurve Then
            Dim p1 As Point2d = oCurve.StartPoint
            Dim p2 As Point2d = oCurve.EndPoint
            Dim dx As Double = Math.Abs(p1.X - p2.X)
            If Math.Abs(p1.Y - p2.Y) < 0.0001 And dx > bestLen Then
                bestLen = dx
                best = oCurve
            End If
        End If
    Next
    If best Is Nothing Then Exit Sub

    ' attach to both ends, text 1.5 cm above the line
    Dim i1 As GeometryIntent = oSheet.CreateGeometryIntent(best, PointIntentEnum.kStartPointIntent)
    Dim i2 As GeometryIntent = oSheet.CreateGeometryIntent(best, PointIntentEnum.kEndPointIntent)
    Dim pt As Point2d = oTG.CreatePoint2d((best.StartPoint.X + best.EndPoint.X) / 2, best.StartPoint.Y + 1.5)

    Dim oDim As LinearGeneralDimension = oSheet.DrawingDimensions.GeneralDimensions.AddLinear(pt, i1, i2, DimensionTypeEnum.kHorizontalDimensionType)
    MessageBox.Show("Dimension added: " & Math.Round(oDim.ModelValue * 10, 1) & " mm")
End Sub

Four things that trip people up

Units and scale. The API works in centimetres, whatever the drawing shows. The 1.5 above is 15 mm on the sheet. ModelValue is in centimetres too, which is why it is multiplied by 10, and it is the size of the part, not of the line on the sheet: in a view at 2:1, a line 40 mm long on paper returns 20 mm. An agent that compares sheet lengths with part sizes without the view scale will report errors that are not there.

Intents. Attaching the dimension to the curve itself, without a point intent, lets Inventor choose, and it does not always choose what you meant. Say which end you want.

Placement. The text point decides where the dimension sits. Put it outside the view outline, or it will be drawn across the part.

Straight text needs a dimension, not a note. A leader note with a number typed in looks like a dimension but does not update and cannot be checked. Use a real dimension.

Check what you placed

After a batch, open the drawings and read the dimensions back: count them per view, compare ModelValue with the size you expected, and look for dimensions that overlap. A rule that runs without errors has not necessarily dimensioned the right edge.

From one dimension to a full drawing

The same pattern, repeated for overall sizes, holes and bevels, is how a whole set of cutting drawings gets dimensioned. The hard part is not the API call. It is deciding which edges to dimension on parts you have never seen, and checking the result on every one of them.

Do and don't

Do

Don't

Next: holes and overall sizes, overlaps and the rules a shop accepts, dimension styles with scripts.

That is the work we do. If you want your drawings dimensioned this way, send us a file.