Modifying Hole Feature

Modifying Hole Feature

jkorson
Enthusiast Enthusiast
2,560 Views
4 Replies
Message 1 of 5

Modifying Hole Feature

jkorson
Enthusiast
Enthusiast

Currently I have a part model that has counterbore holes. What I would like to do is easily switch the hole size from 1/4", #12, and #08 countersunk screws via iLogic. Can this be done? 

 

Attached is a picture. I highlighted what I want to change in the hole feature dialog.

 

I'm using Inventor 2022

jkorson_0-1619714127258.png

 

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

WCrihfield
Mentor
Mentor

Yes, I believe this can be done, as long as you supply the correct corresponding string data, that matches what's in the spreadsheet it references for the other size.  It's in the HoleFeature's 'ClearanceInfo' property, which is a read/write property.  I don't recall if you can just change the data within the existing HoleClearanceInfo object, or if you have to create a new HoleClearanceInfo object, then supply that in its place.  So, I'm showing both ways in the rule, with the new object process commented out for now.

Here is a fairly simple iLogic rule that attempts to change the specified fastener size for the clearance hole to fit.

Dim oPDoc As PartDocument = ThisApplication.ActiveDocument
Dim oPDef As PartComponentDefinition = oPDoc.ComponentDefinition
Dim oHoleFeats As HoleFeatures = oPDef.Features.HoleFeatures
Dim oHole As HoleFeature = oHoleFeats.Item(1)
'then either somethine like this:
If oHole.ClearanceInfo.FastenerSize = "#12" Then
	oHole.ClearanceInfo.FastenerSize = "#08"
End If
'or something like this:
'Dim oHCInfo As HoleClearanceInfo = oHoleFeats.CreateClearanceInfo("Ansi Unified Screw Threads", "Flat Head Machine Screw (82)", "#08", "Normal")
'oHole.ClearanceInfo = oHCInfo

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.

If you want and have time, I would appreciate your Vote(s) for My IDEAS 💡or you can Explore My CONTRIBUTIONS

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 5

jkorson
Enthusiast
Enthusiast

So how would I change to specifically call out a hole feature I want to change? For example I named my hole feature "LEFT SIDE FRONT FASCIA C-HOLE".

 

Thank you for your help.

0 Likes
Message 4 of 5

WCrihfield
Mentor
Mentor
Accepted solution

OK.  In this case, you can directly specify the hole feature's name within the Item() call, instead of its Index Integer.  Then, if it exists and the name is spelled correctly, it should recognize it and get it.

Also, I created a test part to test this code on my end, and determined that attempting to edit just the 'FastenerSize' string of the existing HoleClearanceInfo object won't work, but creating a new HoleClearanceInfo object, then setting that to the feature does work.

 

In case you weren't aware, there is a spreadsheet document within your Design Data\XLS\en-US\ folder (that last sub-folder will coincide with your installed language pack), called "clearance.xls".  There is also another spreadsheet file in that folder called "thread.xls".  When you use the Hole command to create either a clearance hole, or a threaded hole, it references the corresponding spreadsheet file for the available settings.  When you want to specify a different setting, you have to make sure it matches something that exists within the spreadsheet.

 

This variation of the code specifies the hole feature by its name, then without checking what the hole feature's current fastener size is set to, it creates a new info object, with each setting set the way you want it, then sets that info object in place of the hole feature's current info object.  This worked in my tests.

Dim oPDoc As PartDocument = ThisApplication.ActiveDocument
Dim oPDef As PartComponentDefinition = oPDoc.ComponentDefinition
Dim oHoleFeats As HoleFeatures = oPDef.Features.HoleFeatures
Dim oHole As HoleFeature = oHoleFeats.Item("LEFT SIDE FRONT FASCIA C-HOLE")
Dim oHCInfo As HoleClearanceInfo = oHoleFeats.CreateClearanceInfo("Ansi Unified Screw Threads", "Flat Head Machine Screw (82)", "#8", FastenerFitType.kNormalFitType)
oHole.ClearanceInfo = oHCInfo

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.

If you want and have time, I would appreciate your Vote(s) for My IDEAS 💡or you can Explore My CONTRIBUTIONS

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 5

jkorson
Enthusiast
Enthusiast

Thank you. This code will be useful.

0 Likes