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: 

API Bug in Tolerance.SetToFits

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
639 Views, 3 Replies

API Bug in Tolerance.SetToFits

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

Tags (4)
Labels (2)
3 REPLIES 3
Message 2 of 4
WCrihfield
in reply to: Anonymous

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

EESignature

(Not an Autodesk Employee)

Message 3 of 4
Anonymous
in reply to: WCrihfield

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.

Message 4 of 4
Anonymous
in reply to: Anonymous

Just to be clear here are Screenshots of what this looks like:

Tolerance when set by hand in Inventor:

Tolerance set by handTolerance set by hand

Tolerance when set by code (vba macro):Tolerance set by codeTolerance set by code

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:

FitAPIWorkaround.PNGFor 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.

Post to forums  

Autodesk Design & Make Report