- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello together,
I want to Change a Holedefinition of a Clearance Hole.
I can query the current size. In API docu it is descript as Read-write,
but I can't set a new value. Open the attached file or any part with
a clearance hole and start the Sub below. The first Messagebox shows
the Size but it results in an error when I try to set a new value.
What is wrong?
Sub subWNHolefeatureUpdate()
Dim oWNPartDoc As PartDocument
Set oWNPartDoc = ThisApplication.ActiveDocument
Dim oWNHoleFeature As HoleFeature
For Each oWNHoleFeature In oWNPartDoc.ComponentDefinition.Features.HoleFeatures
MsgBox oWNHoleFeature.ClearanceInfo.FastenerSize
On Error Resume Next
oWNHoleFeature.ClearanceInfo.FastenerSize = "M6"
MsgBox Err.Description
Next
End SubBest Regards
Wolfgang
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Unfortunately, properties of HoleClearanceInfo for HoleFeature are read only. Please log this wish list at idea station using below link.
https://forums.autodesk.com/t5/inventor-ideas/idb-p/v1232/tab/most-recent
Thanks and regards,
CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I think you need to create a new ClearanceInfo...
you should be able to do this with:
Dim mhtns As ModelHoleThreadNotes = oPartCompDef.ModelAnnotations.ModelHoleThreadNotes
Dim newholeclinfo As HoleClearanceInfo = Nothing
newholeclinfo = mhtns.CreateClearanceInfo("DIN" , "Countersunk Flat Head Screw DIN EN ISO 2009" , "M6")
and then replace the complete HoleClearanceInfo
but if you try to get the holeClearanceinfo.FastenerStandard from the hole you already created it gives an error....
and also creating the new one does not work.
with me trying to figure this out, my Inventor (2018.2.3) is crashing constantly, so I gues Autodesk have to fix things
Kudo's are also appreciated
Succes on your project, and have a nice day
Herm Jan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
It can be done differently,
Look for clearance.xls in your style folder, you can read values from it to get fastener size and corresponding diameters.
Give to user fasteners sizes in combo, and when he choose one, your script will change hole diameter looking for corresponding one to chosen fastener.
use something like:
Sub subWNHolefeatureUpdate()
Dim oWNPartDoc As PartDocument
Set oWNPartDoc = ThisApplication.ActiveDocument
Dim oWNHoleFeature As HoleFeature
Set oWNHoleFeature = oWNPartDoc.ComponentDefinition.Features.HoleFeatures.Item(1)
'oWNHoleFeature.HoleDiameter.Value = 10 ' in cm - corresponding value read from xls
oWNHoleFeature.HoleDiameter.Expression = "6,6" - corresponding value read from xls
oWNPartDoc.Update
End Sub
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello Jan,
ModelAnnotations I think is the wrong point.
I want to change the size of the clearancehole and not
the 3D dimensions.
Best Regards
Wolfgang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
according to the Inventor Help, you should be able with this to edit the HoleFeature object
Kudo's are also appreciated
Succes on your project, and have a nice day
Herm Jan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello Marcin,
its a workaround for a simple hole,
but if you have to distinguish countersinks it
isn't that easy. You have to set more then one
Value and it's not the same for cylindric and
cone sink.
I think Autodesk should make the value writeable.
Anyway thank you for your solution in special circumstances it will
work for me.
Best Regards
Wolfgang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
i think it is only more complex approach... idk what you're working at but you must decide if it is worth it... sadly i don't know any other way to do it (beside complex ifeature)...