Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Change FastenerSize of HoleClearanceInfo

wolfgang_nickl
Advocate

Change FastenerSize of HoleClearanceInfo

wolfgang_nickl
Advocate
Advocate

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 Sub

Best Regards

 

Wolfgang

0 Likes
Reply
Accepted solutions (1)
693 Views
7 Replies
Replies (7)

chandra.shekar.g
Autodesk Support
Autodesk Support

@wolfgang_nickl,

 

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



0 Likes

HermJan.Otterman
Advisor
Advisor

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

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


0 Likes

marcin_otręba
Advisor
Advisor
Accepted solution

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

wolfgang_nickl
Advocate
Advocate

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

0 Likes

HermJan.Otterman
Advisor
Advisor

according to the Inventor Help, you should be able with this to edit the HoleFeature object

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


wolfgang_nickl
Advocate
Advocate

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

0 Likes

marcin_otręba
Advisor
Advisor

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)...

0 Likes