Inventor iLogic - How to Identify a part feature's type?

Inventor iLogic - How to Identify a part feature's type?

tdswanson
Collaborator Collaborator
2,444 Views
4 Replies
Message 1 of 5

Inventor iLogic - How to Identify a part feature's type?

tdswanson
Collaborator
Collaborator

Hey everyone:

 

I'm working on a small piece of code that will allow the user to select holes and apply various tolerances to them.  However, I'd like to exclude any features selected in error.  

 

For example, if the user selects a hole and a fillet, I'd like to use a For loop that would process the hole, then identify that selected feature #2 is ineligible by its type, then move on to the next feature in the selection set.

 

However, after quite a bit of searching, I haven't been able to find a way to take a selected feature and differentiate it by it's type (Hole, fillet, chamfer, extrude, revolve, etc.).  Anyone have any advice?

 

Thanks!

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

Curtis_Waguespack
Consultant
Consultant

Hi tdswanson,

 

Here's a quick example based on what I found at these links:

http://adndevblog.typepad.com/manufacturing/2013/11/do-selection-from-ilogic.html

http://adndevblog.typepad.com/manufacturing/2016/01/keep-selection-between-rule-executions.html

 

This example simply filters out the features that are not holes from the selection set. You would add your code to then run on the selection set of holes.

 

Also just as a tip, you can search and ask programming questions of this type on the Inventor Customization forum:
http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/bd-p/120

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

' Set a reference to the active part document.
Dim oDoc As PartDocument
oDoc = ThisApplication.ActiveDocument
oSet = oDoc.CreateHighlightSet

While True
  Dim oFeature As Object
    oFeature = ThisApplication.CommandManager.Pick(
      SelectionFilterEnum.kPartFeatureFilter, 
      "Select a Hole Feature (press ESC to continue)") 
	
	' If nothing gets selected then we're done	
	If IsNothing(oFeature) Then Exit While
	
	If TypeOf oFeature Is HoleFeature Then 
    	oSet.AddItem(oFeature)
	End If
End While

'your code here
	'example: 
	'message to display count Of selection Set
	MessageBox.Show(oSet.Count & " holes selected.", "iLogic")

'clear the selection set
oSet.Clear

 

EESignature

0 Likes
Message 3 of 5

cwhetten
Advisor
Advisor
Accepted solution

Something like this should get you going in the right direction:

 

For Each loopFeature In selectedFeatures
	If loopFeature.Type = ObjectTypeEnum.kHoleFeatureObject Then
		'code to process the hole feature
	End If
Next

I didn't test it with a selection set of features, but it should work for you.  Post back to let us know how it works.

 

Edit:  What Curtis said.  Smiley Happy

 

Cameron Whetten
Inventor 2016

Message 4 of 5

tdswanson
Collaborator
Collaborator

Thank you guys very much for your help!  I've just posted my code in the customization forum.  

 

Here's a link.

 

Thanks again!

0 Likes
Message 5 of 5

h.memis
Contributor
Contributor

Hello there,

I want to select and chamfer lines of holes of the same diameter. Can you help ?

thank you

Ekran Alıntısı.PNG

0 Likes