I want to select desired line with Inventor api.

I want to select desired line with Inventor api.

hayattangercekler2
Advocate Advocate
562 Views
2 Replies
Message 1 of 3

I want to select desired line with Inventor api.

hayattangercekler2
Advocate
Advocate

Using Inventor API, I create lines by opening a sketch in the inverter and giving the specified points. I am opening this sketch in an assembly file. In this assembly file, I want to do the line selection event, which I manually made over the sketch in the ipt file, using the inventor api. Is it possible to do this with api or with ilogic?

0 Likes
563 Views
2 Replies
Replies (2)
Message 2 of 3

Dev_rim
Advocate
Advocate

Hi there,

You need to use SelectEvent and PreSelectEvent events. They are inside of SelectEvents. By using them, You can filter which type of objects will highlighted or not. And you can create your own filters. You have to create a filter for SketchLines.

 

 

devrimyoyen_0-1667901184163.png

As you see there is a parameter named DoHighlight. You can add event to your code (VB.net, c#, VBA all of them have this feature) and you can do some filter like this.

If PreSelectEntity Is Not SketchLine
     DoHighlight = True
Else
     DoHighlight = Fasle
End If

 

and then you can use OnSelect event to get object that selected.

devrimyoyen_1-1667901393318.png

JustSelectedEntities returns the object(s) that you selected. 

In SelectEvents object there is a property named 'SingleSelectEnabled'. If you make it True, it will allow user to select only one object.

Here is the Select event object.

devrimyoyen_2-1667901580676.png

 

Best Regards

Devrim

If my answer is solved your problem, please mark it as Solution

Freundliche Grüße / Kind Regards
0 Likes
Message 3 of 3

CattabianiI
Collaborator
Collaborator

The follwing rule, select the second line in the selected sketch (select a sketch before running the rule!)

To select the desired instead the second one you have to define some criteria (e.g. SketchLine.Lenght or define an attribute in SketchLine.AttributeSets)

 

Dim doc As Document = ThisApplication.ActiveDocument

Dim selset As SelectSet
selset = doc.SelectSet

Dim sketch As Sketch = selset.Item(1)

' Open the sketch for edit.
' This is only required for drawing sketches, not part.
'sketch.Edit

Dim sl As SketchLine = sketch.SketchLines.Item(2)
selset.Clear
selset.Select(sl)

 

 

0 Likes