Get selected sketch segments

Get selected sketch segments

george1985
Collaborator Collaborator
285 Views
4 Replies
Message 1 of 5

Get selected sketch segments

george1985
Collaborator
Collaborator

Hello,

 

I selected a line and an arc in my Inventor Sketch.
I would like to get this line and the arc via Inventor API.
How can I do that?

 

I found a method app.ActiveDocument.GetSelectedObject
But I don't know which inputs to use for it.

 

I also see that there is app.ActiveDocument.SelectSet.

But when I try to call: app.ActiveDocument.SelectSet.Count, it returns 0.

 

Can someone help me, how to return the selected line and arc inside Sketch?

I would be very grateful for any kind of help.

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

bradeneuropeArthur
Mentor
Mentor
Dim s As Object = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kSketchCurveFilter, "PICK")
If s.Type = ObjectTypeEnum.kSketchArcObject  Then
	MsgBox ("Yes")
End If
	

This should work. 

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

Message 3 of 5

george1985
Collaborator
Collaborator

Hi @bradeneuropeArthur ,
Thank you very much for the reply.

Is ThisApplication.CommandManager.Pick raising a dialog, which allows selection?

In my case, the sketch segments are already manually selected in Inventor.
I would like to access that already existing selection.
For example, in AutoCAD we can do it via:
Application.DocumentManager.MdiActiveDocument.Editor.GetSelection().Value.GetObjectIds()

But I don't know how to do it in Inventor.

0 Likes
Message 4 of 5

bradeneuropeArthur
Mentor
Mentor
Accepted solution

This will do that:

 

Dim s As SelectSet = ThisDoc.Document.SelectSet

If s.Item(1).Type = ObjectTypeEnum.kSketchArcObject  Then
	MsgBox ("Yes")
End If

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

Message 5 of 5

george1985
Collaborator
Collaborator

Hi @bradeneuropeArthur ,
Thank you very much for the help!
I got an error at "ThisDoc.Document.SelectSet" saying: "Document property does not exist."

I googled a bit, and it seems ThisDoc.Document is an iLogic function. I apologize for not stating at the very beginning, that I am not using iLogic.

Very strangely I tried again app.ActiveDocument.SelectSet.Count, and it returned "2" instead of "0", as initially.
Then I was able to access both sketch segments with your example code: app.ActiveDocument.SelectSet.Item(1)/(2)

Thank you very much for all your help!