I have some very weird (to me at least) behavior going. Im trying to set some part sketch parameters and their upper and bottom limits based on imperial values from a spreadsheet.
In the sample below i can see GetCellValues returns the correct value from the spreadsheet (as a string) of 4.003 inches. Also listed in this spreadsheet are the upper limit 4.006 and bottom limit of 4.003. The problem is that when i set these limits (even after converting to inches) it displays the tolerance as 8.009/8.003.
It appears the settolimits only accepts the values as a deviation and the lower value must be a negative to have it work correctly?
'Add dimensions from spreadsheet 'set oDims(1) = oSketch.DimensionConstraints.AddTwoPointDistance(oCenterLine.StartSketchPoint, oCenterLine.EndSketchPoint, kHorizontalDim, oCoord1, True) Set oDims(1) = oSketch.DimensionConstraints.AddOffset(oLines(3), oCenterLine, oTG.CreatePoint2d(-5, 0), True, False) oDims(1).Parameter.Name = "Dim4" oDims(1).Parameter.Value = ConvertInchtoCM(GetCellValues(CBoxFamily1.Value, CBoxEnd1.Value, 0, "Dim4")) Dim dblULimit As Double: dblULimit = ConvertInchtoCM(GetCellValues(CBoxFamily1.Value, CBoxEnd1.Value, 2, "Dim4")) Dim dblBLimit As Double: dblBLimit = ConvertInchtoCM(GetCellValues(CBoxFamily1.Value, CBoxEnd1.Value, 3, "Dim4")) If GetCellValues(CBoxFamily1.Value, CBoxEnd1.Value, 2, "Dim4") <> "NULL" Then Call oPartDoc.ComponentDefinition.Parameters("Dim4").Tolerance.SetToLimits(kLimitsStackedTolerance, dblULimit, dblBLimit) End If 'set precision here. oDims(1).Parameter.Precision = GetCellValues(CBoxFamily1.Value, CBoxEnd1.Value, 1, "Dim4")
Solved! Go to Solution.
Solved by philippe.leefsma. Go to Solution.
Hi
So far I'm not reproducing an unexpected behavior, I am testing with a simple sample as below. I have a parameter associated with a linear dimension:
Sub TolTest() Dim doc As PartDocument Set doc = ThisApplication.ActiveDocument Dim param As parameter Set param = doc.ComponentDefinition.parameters("adn") Call param.tolerance.SetToLimits(kLimitsStackedTolerance, "5 in", "3 in") End Sub
Keep in mind that the API units, if not explicitely specified, are always expressed in cm for length. If this is still an issue for, provide a sample document along with some code and the Excel functionality stripped away as I don't think they are relevant here.
Thank you,
Philippe.
I guess it was more my misunderstanding of what the method was looking for. When it says input the upper limit i think of the actual measurable value an inspector would check on a gauge.
What its actually looking for is deviation. So in your example you are saying the upper 'deviation' is +5cm and the lower 'deviation' is still +3cm.
Once i figured out what it wanted i simply adjusted my values in my spreadsheet to 0.003 and -0.003.