Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Potential bug with model states and StandardThreadInfo.MajorDiameterMax via ThreadFeature.ThreadInfo/HoleFeature.TapInfo

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
meGVGMF
493 Views, 5 Replies

Potential bug with model states and StandardThreadInfo.MajorDiameterMax via ThreadFeature.ThreadInfo/HoleFeature.TapInfo

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

 

 

 

 

 

 

 

 

 

 

 

 

5 REPLIES 5
Message 2 of 6
WCrihfield
in reply to: meGVGMF

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

EESignature

(Not an Autodesk Employee)

Message 3 of 6
meGVGMF
in reply to: WCrihfield

Thanks for the reponse.

Could you do me a favour and try it with ACME thread? It does indeed work for me with UN thread
Message 4 of 6
WCrihfield
in reply to: meGVGMF

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

EESignature

(Not an Autodesk Employee)

Message 5 of 6
meGVGMF
in reply to: WCrihfield

Oh interesting...
They're threads with a hexagonal profile used for translation/converting rotational motion to linear.
https://www.engineersedge.com/hardware/acme-threads-calculator.htm
If you don't have them, that could mean it's a problem with the way the spreadsheet was formatted... Or it's just part of the North American distribution for Inventor? I really don't know.
Do you have anything like them?
Message 6 of 6
meGVGMF
in reply to: meGVGMF

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.

Post to forums  

Autodesk Design & Make Report