Blog · Inventor · 1 Nov 2026 · Last updated 2 Nov 2026 · 5 min read · By Stefano B.

Change the Inventor drawing line color and weight of one component with iLogic

One iLogic rule moves every line of one component, in every view of the sheet, to a copy of its layer with your color and weight, one call per layer. Hidden lines stay dashed, and a second run changes nothing. In Inventor 2025.1 and later there is also a one-line way to change the color only.

Short answer: to change the Inventor drawing line color and weight of one part or sub-assembly, collect its line segments with DrawingView.DrawingCurves(occurrence), copy their layer with your color and weight, and move them all at once with Sheet.ChangeLayer. If you only need the color and you have Inventor 2025.1 or later, DrawingView.SetComponentLineColor does it with one call per view.

Assembly drawing of a tank agitator before the rule, in front, side and isometric view: a welded frame in square tube, a tank with lid and nozzle, and a vertical agitator on top with gearbox, motor, shaft and impeller. All lines are on the same layers and drawn in the same ink.
From this: the agitator drawn like the rest of the machine.
The same drawing after the rule: every line of the agitator sub-assembly in orange, moved to new layers, in all three views; the impeller inside the tank is still dashed, and the frame and the tank are unchanged.
To this: the agitator on its own layers, frame and tank untouched.

We ran the code on this page as iLogic rules in Inventor 2025.2. The example is a machine we modelled for it, a tank agitator: a welded frame in 60x60 tube, 800 x 800 and 1100 mm high, a 600 mm tank with a lid and a nozzle, and on top the agitator, a sub-assembly of gearbox, motor, shaft and impeller that reaches down into the tank. The sheet has 3 views: front with hidden lines (the impeller inside the tank), side, and isometric. The job: make the agitator stand out in every view, red and thicker, and leave the rest of the machine as it is. The images are redrawn from the DXF of that sheet after the rule: orange is the new layers (red in the drawing). The "before" image is the same DXF with every line drawn in ink. Line weight does not show in the images; the numbers below check it. For the times we also used a much bigger test sheet, further down.

The rule

Paste it as a rule in the drawing and change the first lines.

' Moves every line of one component (part or sub-assembly, at any level) to its own layer, in every view of the active sheet.
' Sheet.ChangeLayer moves a whole collection in one call, instead of editing the curves one by one.
' Each original layer (visible, hidden...) gets its own copy, so hidden lines stay dashed.
Dim sOccPath As String = "AGITATOR:1"   ' CHANGE: component as shown in the assembly browser; if it sits inside
                                        ' another sub-assembly, the whole path with "/", e.g. "MIXER:1/AGITATOR:1"
Dim iRed As Integer = 255            ' CHANGE: line color (red, green, blue 0-255)
Dim iGreen As Integer = 0
Dim iBlue As Integer = 0
Dim dWeightCm As Double = 0.07       ' CHANGE: line weight in cm (0.07 = 0.7 mm)
Dim sSuffix As String = " - " & sOccPath.Replace("/", " > ")   ' new layers: "<original layer> - <component path>"

Dim oDrawDoc As DrawingDocument = ThisDoc.Document
Dim oSheet As Sheet = oDrawDoc.ActiveSheet
Dim oColor As Inventor.Color = ThisApplication.TransientObjects.CreateColor(iRed, iGreen, iBlue)
Dim oGroups As New Dictionary(Of String, ObjectCollection)
Dim aPath() As String = sOccPath.Split("/"c)
Dim iCount As Integer = 0

For Each oView As DrawingView In oSheet.DrawingViews
    Dim oOcc As ComponentOccurrence = Nothing
    Dim oCurves As DrawingCurvesEnumerator = Nothing
    Try
        Dim oAsmDoc As AssemblyDocument = oView.ReferencedDocumentDescriptor.ReferencedDocument
        oOcc = oAsmDoc.ComponentDefinition.Occurrences.ItemByName(aPath(0))
        For i As Integer = 1 To aPath.Length - 1   ' walk down the path, one level at a time
            Dim oNext As ComponentOccurrence = Nothing
            For Each oSub As ComponentOccurrence In oOcc.SubOccurrences
                If oSub.Name = aPath(i) Then
                    oNext = oSub
                    Exit For
                End If
            Next
            If oNext Is Nothing Then Throw New Exception(aPath(i) & " not found")
            oOcc = oNext
        Next
        oCurves = oView.DrawingCurves(oOcc)
    Catch
        Continue For   ' view of another model, or the component is not in this view
    End Try
    For Each oCurve As DrawingCurve In oCurves
        For Each oSeg As DrawingCurveSegment In oCurve.Segments
            Dim sLayer As String = oSeg.Layer.Name
            If sLayer.EndsWith(sSuffix) Then Continue For   ' already moved by an earlier run
            If Not oGroups.ContainsKey(sLayer) Then
                oGroups.Add(sLayer, ThisApplication.TransientObjects.CreateObjectCollection)
            End If
            oGroups(sLayer).Add(oSeg)
            iCount += 1
        Next
    Next
Next

For Each sLayer As String In oGroups.Keys
    Dim oNewLayer As Layer = Nothing
    Try
        oNewLayer = oDrawDoc.StylesManager.Layers.Item(sLayer & sSuffix)
    Catch
        oNewLayer = oDrawDoc.StylesManager.Layers.Item(sLayer).Copy(sLayer & sSuffix)
    End Try
    oNewLayer.Color = oColor
    oNewLayer.LineWeight = dWeightCm
    oSheet.ChangeLayer(oGroups(sLayer), oNewLayer)
Next

Logger.Info(iCount & " line segments of " & sOccPath & " moved to " & oGroups.Count & " layer(s)")

What to change:

What we measured

Why a layer, and not each curve

Each DrawingCurve has its own Color and LineWeight, so you can set them one by one. That works (we read the color back), but it is one change per curve: 132.4 s against 29.9 s on the big sheet. Sheet.ChangeLayer takes the whole collection in one call. It has been in the API since Inventor 2011, according to the Autodesk help.

Inventor 2025.1 and later: color only, one call per view

Inventor 2025.1 added DrawingView.SetComponentLineColor (Autodesk help). It sets the line color of one component in a view, and nothing else: no line weight, no layer.

' Inventor 2025 and later: one call per view sets the line color of one component (color only, not the weight).
Dim sOccName As String = "AGITATOR:1"   ' CHANGE: component name as shown in the assembly browser (top level)
Dim oDrawDoc As DrawingDocument = ThisDoc.Document
Dim oColor As Inventor.Color = ThisApplication.TransientObjects.CreateColor(255, 0, 0)   ' CHANGE: color
Dim iViews As Integer = 0

For Each oView As DrawingView In oDrawDoc.ActiveSheet.DrawingViews
    Try
        Dim oAsmDoc As AssemblyDocument = oView.ReferencedDocumentDescriptor.ReferencedDocument
        oView.SetComponentLineColor(oAsmDoc.ComponentDefinition.Occurrences.ItemByName(sOccName), oColor)
        iViews += 1
    Catch
        ' view of another model, or the component is not in this view
    End Try
Next

Logger.Info(sOccName & " recolored in " & iViews & " view(s)")

On the agitator sheet it ran in 0.35 s, rule start included (0.16 s on the big sheet). The sheet showed the agitator in red in all 3 views, and the frame and tank unchanged. The layers did not change (84 before and after), and GetComponentLineColor on the view returns the red. On the big sheet the curves kept their own color property: the view returns the red, the curves do not, and no curve of SUB_A:2 turned red. So if you need the weight too, or you have an older Inventor, use the layer rule above.

References

More drawing work by code: dimension styles in Inventor with scripts and auto balloons in assembly drawings. How we make complete drawings from a STEP: fabrication drawings from STEP files.