Hello, I might have found a bug when setting the tolerance of a parameter to a hole tolerance via api (VBA) in Inventor 2020.3 using mm units.
Steps to reproduce:
1. In a part set the tolerance of any parameter (e.g. diameter of a holefeature or a dimension in a sketch) to a hole tolerance ("H7") by hand without using the api. This would set the upper value of the tolerance for e.g. 10 mm H7 to +0,015 mm.
2. Do the same with vba and the upper value of the tolerance is set to +0,15 mm which is wrong.
Examplecode (set to hole tolerance manually before running the code):
Sub TestSetToFits()
Dim doc As Document, paras As Inventor.Parameters, para As Inventor.Parameter
Set doc = ThisApplication.ActiveDocument
Set paras = doc.ComponentDefinition.Parameters
Set para = paras("d0") 'change index or key (e.g. "d39") to the right one
Debug.Print para.Tolerance.Upper
para.Tolerance.SetToFits kLimitsFitsShowTolerance, "H7", ""
Debug.Print para.Tolerance.Upper
End Sub
As far as I could test this only happens with hole tolerances and not with shaft. Was this already solved? If yes is there a hotfix for Inventor 2020?
Inventor 2020.3
Windows 10 64 Bit
Most numbers used within the coding environment are understood as centimeters, except for a few situations. So you would have to convert the number to the target units using math or a converter routine. That's most likely what's going on.
Wesley Crihfield
(Not an Autodesk Employee)
Thanks for the reply but thats not it.
These values are actually stored in centimeters internally but i really mean that they are 10 times greater than they should be.
For example if you select the option to show the tolerance values they are shown 10x greater on the sketch dimension.
And this only happens with hole tolerance, not with shaft or symmetric etc.
That also means that i cannot use the values for calculations in a macro since i can't know if the user set the tolerance by hand or used my macro.
Just to be clear here are Screenshots of what this looks like:
Tolerance when set by hand in Inventor:
Tolerance when set by code (vba macro):
The property modelvalue which takes the tolerance into account (for example is the parameter is set to median) is then also wrong.
I have found this post from 2009 (!) in which the same problem was asked (Inventor 2008 to 2010).
I tested this workaround:
uom.LengthUnits = kCentimeterLengthUnits
para.Tolerance.SetToFits kLimitsFitsShowTolerance, "E8", ""
uom.LengthUnits = kMillimeterLengthUnits
It kinda works unfortunately it rounds the values too much:
For my purposes a error margin of up to 0,005 due to rounding is not acceptable, especially for fittings.
Can't find what you're looking for? Ask the community or share your knowledge.