Draw Line Between Two Selected points in Part Sketch

Draw Line Between Two Selected points in Part Sketch

inulobo
Advocate Advocate
1,084 Views
4 Replies
Message 1 of 5

Draw Line Between Two Selected points in Part Sketch

inulobo
Advocate
Advocate

How do you collect two selected sketch points, get their sketch point2d geometry, and draw a line to connect the selected points. 

0 Likes
Accepted solutions (1)
1,085 Views
4 Replies
Replies (4)
Message 2 of 5

FINET_Laurent
Advisor
Advisor

Maybe having a look at this whould help?

 

https://forums.autodesk.com/t5/inventor-customization/ilogic-sketch-creation/m-p/4906204/highlight/t...

 

Regards,

 

FINET L.

If this post solved your question, please kindly mark it as "Solution"

If this post helped out in any way to solve your question, please drop a "Like"

@LinkedIn     @JohnCockerill

0 Likes
Message 3 of 5

inulobo
Advocate
Advocate

Not exactly what I am looking for. That seems to work with given inputs. I am trying to have it use 2 selected points as my inputs. How do I grab the two selected or active points?

0 Likes
Message 4 of 5

inulobo
Advocate
Advocate

This is as close as I have gotten. I have to select the two points after I run it. I cannot figure out a way to work with preselected points.

 

Public Sub JoinPoints()

    'set a reference to the active sketch.
    Dim oSketch As PlanarSketch
    Set oSketch = ThisApplication.ActiveEditObject
    
    Dim oSketchPoints As SketchPoints
    Set oSketchPoints = oSketch.SketchPoints
    
    Dim skPoint As SketchPoint
    Set skPoint = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kSketchPointFilter, "Select point")
    
    Dim skPoint2 As SketchPoint
    Set skPoint2 = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kSketchPointFilter, "Select second point")
    
    
    Dim oLines As SketchLine
    Set oLines = oSketch.SketchLines.AddByTwoPoints(skPoint, skPoint2)
    
End Sub
0 Likes
Message 5 of 5

JhoelForshav
Mentor
Mentor
Accepted solution

@inulobo 

If the points are selected they will be in the documents selectset. I wrote this macro for you. Make sure there are only two selected entities and that they are two sketchpoints in the same sketch 🙂

Public Sub JoinPoints()
Dim oSelSet As SelectSet
Set oSelSet = ThisApplication.ActiveDocument.SelectSet
    
If oSelSet.Count = 2 Then
If TypeOf oSelSet(1) Is SketchPoint And TypeOf oSelSet(2) Is SketchPoint Then
    Call oSelSet(1).Parent.SketchLines.AddByTwoPoints(oSelSet(1), oSelSet(2))
End If
End If
End Sub