Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
JhoelForshav
in reply to: Anonymous

Hi @Anonymous 

To get your rule to run, I'd recommend getting the sketch by its name:

Dim oDoc As Document = ThisDoc.Document
Dim oSketch As PlanarSketch = oDoc.ComponentDefinition.Sketches.Item("sketch name") 'sketch name = Name of sketch
Dim oColor As Color
oColor = ThisApplication.TransientObjects.CreateColor(255, 255, 255) 'White

Dim oLine As SketchLine = oSketch.SketchLines(2)
oLine.OverrideColor = oColor
oLine.LineWeight = 2 'Set Lineweight

Identifying a specific line is a bit difficult. You could use RefKeys like @Anonymous is doing here:

https://forums.autodesk.com/t5/inventor-customization/change-sketch-constraints-programmatically-ilogic/td-p/9542773

 

If you have the sketch visible though, maybe it's enough to just have the user pick the line like this?

'Get the sketchLine
Dim oLine As SketchLine = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kSketchCurveLinearFilter, "Pick the sketchline")
'Set the color
oLine.OverrideColor = ThisApplication.TransientObjects.CreateColor(255, 255, 255)
'Set the line weight
oLine.LineWeight = 2