Inventor : Assign a hole diameter to a parameter

Inventor : Assign a hole diameter to a parameter

jgomis.ext
Enthusiast Enthusiast
1,659 Views
13 Replies
Message 1 of 14

Inventor : Assign a hole diameter to a parameter

jgomis.ext
Enthusiast
Enthusiast

Hi,

In the hole configuration you can only select the size by a scrollable list. Is it possible to assign the diameter to a parameter ? To change it easily in a form after.

 

jgomisext_0-1668766119428.png

 

Thanks for your advices 🙂

0 Likes
Accepted solutions (2)
1,660 Views
13 Replies
Replies (13)
Message 2 of 14

WCrihfield
Mentor
Mentor

Hi @jgomis.ext.  I don't know if you are aware of this or not, but the values that are available within that hole feature dialog are all pulled directly from a couple of Excel files that are installed with Inventor.  These two files are usually located in a location similar to the following:

C:\Users\Public\Documents\Autodesk\Inventor 2022\Design Data\XLS\en-US\clearance.xls

C:\Users\Public\Documents\Autodesk\Inventor 2022\Design Data\XLS\en-US\thread.xls

The folks at Autodesk have designed that dialog, and have some code behind it that will automatically pull the appropriate data in to the dialog from those Excel files to match whatever options you choose within it, to make life easier.  Some folks have copied the original Excel file to preserve it, then created their own modified versions, with either extra listings, or fewer listings, to suit their needs.  If we simply put a list of hole diameters in a list, that by itself may not be enough to cause any other related settings to update to match the new hole diameter, the way the dialog works now.  If you were just doing some simple  through all holes, with no clearance, no taper, no threads, etc. it might work out OK though.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 14

jgomis.ext
Enthusiast
Enthusiast

Thank you for you response 🙂

And do you know how it is possible to change the thread and the size of my hole in a form ? 

I'm a begginer on inventor and I just know the way to use the parameters in a form.

 

Thanks you so much !

 

0 Likes
Message 4 of 14

WCrihfield
Mentor
Mentor

I do know how to change some of the settings of an existing threaded hole feature by code, but I have never done so with the help of an iLogic Form before.  I have just done simple hard-coded size/thread changes from one specific size to another.  The code process for making these changes is a bit more complicated than some other similar sounding tasks though.  It might be a bit to complex to simply explain here by typing stuff in a forum post.  An example file, and example Form, and example ilogic rule would probably be in order to more properly convey how this automation task could be set-up.

I do know that currently the only way to have a multi-value list in a simple iLogic Form is by using a multi-value parameter, which is rather limiting.  And I also know that we can not make multi-value iProperties yet, which would be nice.  If the iLogic Form is an 'internal' one (versus an 'global' one), then any changes you make within the form will immediately effect the model, without waiting for you to click something like an Apply or OK button, which is usually really nice, but that behavior can make it pretty difficult when you need to set multiple settings correctly before applying those settings to the model.  For instance, if the model currently had a really small diameter threaded hole, and you were changing it to a much larger threaded hole, when you first select the other larger diameter in the form, it will immediately try to apply that to the model, before you can change the thread to one that would fit that size hole, so it might throw an error, or reject the parameter change, or break the feature.  When using a 'global' iLogic Form, changes you make in the form must be applied by clicking the Apply button or OK button, before they will effect the model, which might be better in this case, but I have not tested it in this exact scenario before.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 14

jgomis.ext
Enthusiast
Enthusiast

Thanks for this response, my work will be so complicated !

Is it possible to do something like that with a tapped hole ?

 

Dim oPDoc As PartDocument = ThisApplication.ActiveDocument
Dim oPDef As PartComponentDefinition = oPDoc.ComponentDefinition
Dim oHole As HoleFeature = oPDef.Features.HoleFeatures.Item(1)
If oHole.IsClearanceHole Then
	oHole.ClearanceInfo.FastenerSize = "M10"
End If

 

0 Likes
Message 6 of 14

jgomis.ext
Enthusiast
Enthusiast
Accepted solution

If someone want to know how to do this, I found my happyness here :

Dim oDoc As PartDocument = ThisDoc.Document
Dim oCD As ComponentDefinition = oDoc.ComponentDefinition

Dim oHoleFeature As HoleFeature = oCD.Features.HoleFeatures.Item(1)

'define tap info
oRightHand = True
oThreadStandard = "ISO Metric profile" 
'oThreadDes = "M5x0.8"
oThreadDes = flasdiamperctype
'oThreadDes = "M20x2.5"
oClass = "6H"
oFullThread = True

'Set hole As tapped
Dim oTappedInfo As HoleTapInfo = oCD.Features.HoleFeatures.CreateTapInfo(oRightHand, oThreadStandard, oThreadDes, oClass, oFullThread)
oHoleFeature.TapInfo = oTappedInfo

 

Message 7 of 14

WCrihfield
Mentor
Mentor

Glad to see you got it figured out.  I had some other stuff going on at work, but I did create an example code I was going to post.  I use Imperial specifications by default though, instead of metric, so my example would not have been a perfect match to your scenario anyways.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 8 of 14

WCrihfield
Mentor
Mentor

Even after looking further into this though, and doing some testing with a part model, I do not see an actual Parameter in the Parameters dialog box for that specification within the HoleFeature dialog.  I see Parameters in there for the other three hole features, such as diameter and location point sketch dimensions, but none of those holes are threaded.  I could not find an existing Parameter for any of those specifications for the tapped hole.  If this is the case, that would make controlling this feature's size & specifications by a form a bit more complicated.  You would have to create several text type user parameters for the specifications you want to control.  Then after making changes to those parameters in the form, you would then have to run an iLogic rule to push these values into the thread info specs of the hole feature, similarly to what you did above, but using values from the user parameters, instead of hard coded values.  You could set the rule up to run every time one of those parameter values changes, but I don't think that would be best.  It would probably be better to include a button in your form that when clicked will run that iLogic rule to update the hole feature.  That way you have better control, and all specs will be sent to the feature at one time.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 9 of 14

jgomis.ext
Enthusiast
Enthusiast

I have a little problem if you have 30s 🙂

My code didn't accept that I turn oFullThread to False, I don't know why but it says me that the type don't match.

Do you see what is wrong ?

 

Dim oDoc As PartDocument = ThisDoc.Document
Dim oCD As ComponentDefinition = oDoc.ComponentDefinition

Dim oHoleFeature As HoleFeature = oCD.Features.HoleFeatures.Item(1)

'define tap info
oRightHand = True
oThreadStandard = "ISO Metric profile" 
oThreadDes = flasdiamperctype
oClass = "6H"
oFullThread = True

'Set hole As tapped
Dim oTappedInfo As HoleTapInfo = oCD.Features.HoleFeatures.CreateTapInfo(oRightHand, oThreadStandard, oThreadDes, oClass, oFullThread)
oHoleFeature.TapInfo = oTappedInfo

 

0 Likes
Message 10 of 14

WCrihfield
Mentor
Mentor

Yes.  When you do not want the treads to go full depth, you must specify the last of the variables, named 'ThreadDepth' as input into the HoleFeatures.CreateTapInfo method.  The code you posted does not include that final input that would be right after the Boolean for 'FullTapDepth'.  That final input can either be a Double type number (it will represent centimeters by default, if you use number), or it can be a String.  If you specify a String (I recommend that), be sure to include the units specifier after the numbers, within the string, similar to what it would look like in the Equation column of the Parameters dialog box.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 11 of 14

jgomis.ext
Enthusiast
Enthusiast

Hi WCrihflied ! Hope you zre fine !

Do you can help me to complete my code ?

I tried since 2h to specify my variable as string but nothing work :'(

 

I used this thread to inspire me but it's not easy : https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/ilogic-control-threaded-hole-sizes-o... 

 

Have a good day 🙂

0 Likes
Message 12 of 14

jgomis.ext
Enthusiast
Enthusiast

I tried this but  it's not working 😞

 

Dim oDoc As PartDocument = ThisDoc.Document
Dim oCD As ComponentDefinition = oDoc.ComponentDefinition

Dim oHoleFeature1 As HoleFeature = oCD.Features.HoleFeatures.Item("Perçage 1 flasque boulonné côté 1")
Dim oTappedInfo1 As HoleTapInfo = oCD.Features.HoleFeatures.CreateTapInfo(oRightHand1, oThreadStandard1, oThreadDes1, oClass1, oFullThread1, OThreadDepth1)

'define tap info hole 1
oRightHand1 = True
oThreadStandard1 = "ISO Metric profile" 
oThreadDes1 = flas1bouldiamperc1type
oClass1 = "6H"
oFullThread1 = False
oThreadDepth1 = "4 cm"

'Set hole As tapped
oHoleFeature1.TapInfo = oTappedInfo1
0 Likes
Message 13 of 14

jgomis.ext
Enthusiast
Enthusiast
Accepted solution

I find my solution sorry 🙂

 

Dim oDoc As PartDocument = ThisDoc.Document
Dim oCD As ComponentDefinition = oDoc.ComponentDefinition

Dim oHoleFeature1 As HoleFeature = oCD.Features.HoleFeatures.Item(1)
'Dim oTappedInfo1 As HoleTapInfo = oCD.Features.HoleFeatures.CreateTapInfo(oRightHand1, oThreadStandard1, oThreadDes1, oClass1, oFullThread1)

'define tap info hole 1
oRightHand1 = True
oThreadStandard1 = "ISO Metric profile" 
oThreadDes1 = flas1bouldiamperc1type
oClass1 = "6H"
oFullThread1 = False
oThreadDepth1 = "4 cm"

'Set hole As tapped
Dim oTappedInfo1 As HoleTapInfo = oCD.Features.HoleFeatures.CreateTapInfo(oRightHand1, oThreadStandard1, oThreadDes1, oClass1, oFullThread1, oThreadDepth1)
oHoleFeature1.TapInfo = oTappedInfo1
0 Likes
Message 14 of 14

sbalasubramanianJJDFU
Enthusiast
Enthusiast

@johnsonshiue I have a excel driven parameter for threaded hole where the thread size (diameter), depth and hole depth are driven from excel.  whats the right or best way to do link it? as Inventor just shows drop down for thread size..

0 Likes