How to select a hole feature of a part in an assembly?

How to select a hole feature of a part in an assembly?

liminma8458
Collaborator Collaborator
507 Views
2 Replies
Message 1 of 3

How to select a hole feature of a part in an assembly?

liminma8458
Collaborator
Collaborator

Hi,

I am doing a code which needs to select a hole feature of a part in assembly mode. How to do it through API?

 

I try <ThisApplication.CommandManager.Pick(kAssemblyFeatureFilter, "Pick a feature in Assembly")>, and <ThisApplication.CommandManager.Pick(kAllCircularEntities, "Pick CircularEntities in Assembly")>. They can NOT pick a hole feature of a part in assembly.

 

I also try <oCtrlDef = ThisApplication.CommandManager.ControlDefinitions.Item("AppFeaturePriorityWrapperCmd")>. It works. But I don't know how to add a tool-tip (such as "please select a hole") with selecting arrow while doing the pick. So how to add a tool-tip for this way?

 

Thank you very much in advance

Limin

 

Thanks
Limin
Inventor pro 2023 64 bit update 5.3; Windows 11 pro 64 bit version 24H2; Office 2013 64 bit

Download iCable in App Store to Create Cables Easily

0 Likes
Accepted solutions (1)
508 Views
2 Replies
Replies (2)
Message 2 of 3

JhoelForshav
Mentor
Mentor
Accepted solution

Just tried this and it seemed to work 🙂

Dim doc As Document
    doc = ThisApplication.ActiveDocument

    ' Have an object selected.
    Dim selection As Object
    selection = ThisApplication.CommandManager.Pick( _
                                    SelectionFilterEnum.kPartFeatureFilter, _
                                    "Select a feature.") 
	MsgBox(selection.Name)

The code lets you pick a feature in a part from the containing assembly and writes the features name in a messagebox

 

Please accept as solution if you're happy with the reply 🙂

Message 3 of 3

liminma8458
Collaborator
Collaborator

It works perfectly! I have been thinking kPartFeatureFilter only works with part mode. Thank you very much!

Thanks
Limin
Inventor pro 2023 64 bit update 5.3; Windows 11 pro 64 bit version 24H2; Office 2013 64 bit

Download iCable in App Store to Create Cables Easily

0 Likes