Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Draw Line Between Two Selected points in Part Sketch

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
inulobo
866 Views, 4 Replies

Draw Line Between Two Selected points in Part Sketch

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

Tags (2)
Labels (2)
4 REPLIES 4
Message 2 of 5
FINET_Laurent
in reply to: inulobo

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

Message 3 of 5
inulobo
in reply to: FINET_Laurent

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?

Message 4 of 5
inulobo
in reply to: inulobo

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
Message 5 of 5
JhoelForshav
in reply to: inulobo

@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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report