Hi
So I'm trying to get thread data for external threads in a part file.
I noticed that when the model states differ in the thread designation a feature uses, the `.MajorDiameterMax` property becomes empty and the `.MajorDiameterMin` property takes its value--or something like it--instead.
To reproduce this, make a part file with external thread, create a model state and ensure member edit scope is set to active member and change the thread through the feature (changing part geometry as necessary).
Can someone please confirm whether this is/is not working for them?
Here's a simple test script to display the values obtained.
Thanks
Edit: it looks like what it's actually doing is getting all the internal thread data instead, which both explains why the `.MajorDiameterMax` is missing and why the values that do obtain are slightly off from what's expected.
Sub Main
Dim oCompDef As PartComponentDefinition = ThisDoc.Document.ComponentDefinition
For Each oMS As ModelState In oCompDef.ModelStates
oMS.Activate
For Each oThreadFeature As ThreadFeature In oCompDef.Features.ThreadFeatures
Dim oThreadData As StandardThreadInfo = oThreadFeature.ThreadInfo
MsgBox(
"Model State: " + oMS.Name + vbCrLf + vbCrLf _
+ oThreadData.ThreadDesignation + vbCrLf _
+ "Internal: " & oThreadData.Internal & vbCrLf + vbCrLf _
+ "Major Max: " & oThreadData.MajorDiameterMax & vbCrLf _
+ "Major Min: " & oThreadData.MajorDiameterMin & vbCrLf _
+ "Minor Max: " & oThreadData.MinorDiameterMax & vbCrLf _
+ "Minor Min: " & oThreadData.MinorDiameterMin & vbCrLf
)
Next
For Each oHoleFeature As HoleFeature In oCompDef.Features.HoleFeatures
Dim oThreadData As StandardThreadInfo = oHoleFeature.TapInfo
MsgBox(
"Model State: " + oMS.Name + vbCrLf + vbCrLf _
+ oThreadData.ThreadDesignation + vbCrLf _
+ "Internal: " & oThreadData.Internal & vbCrLf + vbCrLf _
+ "Major Max: " & oThreadData.MajorDiameterMax & vbCrLf _
+ "Major Min: " & oThreadData.MajorDiameterMin & vbCrLf _
+ "Minor Max: " & oThreadData.MinorDiameterMax & vbCrLf _
+ "Minor Min: " & oThreadData.MinorDiameterMin & vbCrLf
)
Next
Next
End Sub
Solved! Go to Solution.
Solved by meGVGMF. Go to Solution.
Hi @meGVGMF. I had to fix something in your code, and after that, I got the results I was expecting. I just created a simple block with a threaded HoleFeature that goes all the way through the part, and an extruded circular rod with a ThreadFeature applied to it. I used that same spec for both internal & external for the same ModelState, then different thread spec for other ModelState in my tests. I had to change 'StandardThreadInfo' Type to 'HoleTapInfo' Type for the HoleFeatures loop though. I'm using Inventor Pro 20222.4.1 right now.
Sub Main
Dim oPDoc As PartDocument = ThisDoc.FactoryDocument
Dim oPDef As PartComponentDefinition = oPDoc.ComponentDefinition
Dim oMSs As ModelStates = oPDef.ModelStates
For Each oMS As ModelState In oMSs
oMS.Activate
Dim oTFs As ThreadFeatures = oPDef.Features.ThreadFeatures
If oTFs.Count = 0 Then GoTo CheckTHoles
For Each oTF As ThreadFeature In oTFs
Dim oTData As StandardThreadInfo = oTF.ThreadInfo
Logger.Info("Model State: " + oMS.Name + vbCrLf + vbCrLf _
+ oTData.ThreadDesignation + vbCrLf _
+ "Internal: " & oTData.Internal & vbCrLf + vbCrLf _
+ "Major Max: " & oTData.MajorDiameterMax & vbCrLf _
+ "Major Min: " & oTData.MajorDiameterMin & vbCrLf _
+ "Minor Max: " & oTData.MinorDiameterMax & vbCrLf _
+ "Minor Min: " & oTData.MinorDiameterMin & vbCrLf)
Next 'oTF
CheckTHoles :
Dim oHFs As HoleFeatures = oPDef.Features.HoleFeatures
For Each oHF As HoleFeature In oHFs
Dim oHTI As HoleTapInfo = oHF.TapInfo
Logger.Info("Model State: " + oMS.Name + vbCrLf + vbCrLf _
+ oHTI.ThreadDesignation + vbCrLf _
+ "Internal: " & oHTI.Internal & vbCrLf + vbCrLf _
+ "Major Max: " & oHTI.MajorDiameterMax & vbCrLf _
+ "Major Min: " & oHTI.MajorDiameterMin & vbCrLf _
+ "Minor Max: " & oHTI.MinorDiameterMax & vbCrLf _
+ "Minor Min: " & oHTI.MinorDiameterMin & vbCrLf)
Next 'oHF
Next 'oMS
End Sub
Below is the result I got in my iLogic Log window:
INFO| 5: >>---------------------------
INFO|Model State: Master
1/2-13 UNC
Internal: False
Major Max: 0.4985
Major Min: 0.4876
Minor Max: 0.4069
Minor Min:
INFO|Model State: Master
1/2-13 UNC
Internal: True
Major Max:
Major Min: 0.5
Minor Max: 0.434
Minor Min: 0.417
INFO|Model State: Model State1
1/2-20 UNF
Internal: False
Major Max: 0.4987
Major Min: 0.4906
Minor Max: 0.4392
Minor Min:
INFO|Model State: Model State1
1/2-20 UNF
Internal: True
Major Max:
Major Min: 0.5
Minor Max: 0.457
Minor Min: 0.446
Wesley Crihfield
(Not an Autodesk Employee)
I don't see ACME threads listed as a possibility to choose from, and did not find a tab for that in my 'thread.xls' file. Is there another name for them.
Wesley Crihfield
(Not an Autodesk Employee)
So, it turns out, if you have a thread with the same class for both Internal and External threads (e.g. ACME's '2G', like UN '2A' but without equivalent '2B' counterpart), when you differentiate model states by changing the threading of the feature, the `StandardThreadInfo` object within it will for some reason refer only to the internal thread limits.
Can't find what you're looking for? Ask the community or share your knowledge.