Highlighting sketch line start and endpoints

Highlighting sketch line start and endpoints

Anonymous
Not applicable
604 Views
2 Replies
Message 1 of 3

Highlighting sketch line start and endpoints

Anonymous
Not applicable
I'm trying to highlight a sketched line's startpoint in green and the line's endpoint in red. I don't get an error, but it's not working either - what am I doing wrong?

Set oPartDoc = ThisApplication.ActiveDocument

Set oSketch = fActivateSketch(oPartDoc)

Set oSelect = oPartDoc.SelectSet

Set oStartHLSet = oPartDoc.CreateHighlightSet

Set oEndHLSet = oPartDoc.CreateHighlightSet

Set oRed = ThisApplication.TransientObjects.CreateColor(255, 0, 0)

Set oGreen = ThisApplication.TransientObjects.CreateColor(0, 255, 0)

Set oBlue = ThisApplication.TransientObjects.CreateColor(0, 0, 255)

For Each oEnt In oSelect
If TypeOf oEnt Is SketchLine Then
Set oLine = oEnt

' Get the start and endpoints.
'
Set oStartPoint = oLine.StartSketchPoint
Set o3DStartPoint = oSketchII.SketchToModelSpace(oStartPoint.Geometry)

' CreatePointGraphics o3DStartPoint, kEndPointStyle

Set oEndPoint = oLine.EndSketchPoint
Set o3DEndPoint = oSketchII.SketchToModelSpace(oEndPoint.Geometry)

' CreatePointGraphics o3DEndPoint, kFilledCircleSelectPointStyle

oStartHLSet.AddItem oStartPoint
oEndHLSet.AddItem oEndPoint

End If

Next oEnt

oStartHLSet.Color = oGreen
oEndHLSet.Color = oRed
0 Likes
605 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
The primary problem with what you're trying to do is that the entities
you're trying to highlight are selected. The selection overrides the
highlight so you don't see anything. Here's a different implementation that
gets all of the selected lines, clears the selection, and then highlights
the end points.

Public Sub HighlightEnds()
Dim oDoc As PartDocument
Set oDoc = ThisApplication.ActiveDocument

' Iterate over the contents of the select set looking for lines.
Dim colLines As New Collection
Dim oEnt As Object
For Each oEnt In oDoc.SelectSet
If TypeOf oEnt Is SketchLine Then
colLines.Add oEnt
End If
Next

oDoc.SelectSet.Clear

' Create a green highlight set.
Dim oGreenHS As HighlightSet
Set oGreenHS = oDoc.CreateHighlightSet
oGreenHS.Color = ThisApplication.TransientObjects.CreateColor(0, 255, 0)

' Create a red highlight set.
Dim oRedHS As HighlightSet
Set oRedHS = oDoc.CreateHighlightSet
oRedHS.Color = ThisApplication.TransientObjects.CreateColor(255, 0, 0)

' Add the end points to the highlight sets.
For Each oEnt In colLines
Dim oSketchLine As SketchLine
Set oSketchLine = oEnt

' Add the start point to the green highlight set.
oGreenHS.AddItem oSketchLine.StartSketchPoint

' Add the end point to the red highlight set.
oRedHS.AddItem oSketchLine.EndSketchPoint
Next

MsgBox "Points are highlighted."
End Sub


--
Brian Ekins
Autodesk Inventor API
0 Likes
Message 3 of 3

Anonymous
Not applicable
Ahh... That works perfectly!

Thanks Brian!
0 Likes