Is it possible to display the tolerance values, in this case from a bilateral dimension, in a textbox on a user form?
Thanks in advance
Try following example: Get Dimension Tolerance Example (VBA)
Alt Codes List of Alt Key Codes Symbols look at this it will give you most of what you need.
Dim swDim As SldWorks.Dimension
Dim swTol As SldWorks.DimensionTolerance
Set swDim = swDispDim.GetDimension
Set swTol = swDim.Tolerance
TextBox.text = "Max = " & swTol.GetMaxValue & " Min = " & swTol.GetMinValue
Thanks for all the replies everyone. I've got it partially working but am getting zeros instead of the tolerances. The code is as follows. Not all lines are specific to this just did a quick cut and paste. If someone could help me get this working that would be great.
Dim swDim As SldWorks.DimensionDim swTol As SldWorks.DimensionToleranceDim swApp As SldWorks.SldWorksDim swModel As SldWorks.ModelDoc2Dim swSelMgr As SldWorks.SelectionMgrDim swDisplayDimension As SldWorks.DisplayDimensionDim swDimension As SldWorks.Dimension
Private Sub UserForm_Initialize()
Dim swApp As ObjectDim Part As ObjectDim boolstatus As BooleanDim longstatus As Long, longwarnings As LongDim swcomp As SldWorks.Component2
Dim maxValue As DoubleDim minValue As Double
Set swApp = Application.SldWorksSet Part = swApp.ActiveDocSet swModel = swApp.ActiveDoc
Set MYDIMENSION = swModel.Parameter("D1@sketch1")
Me.LBLDIM1.Caption = Format((MYDIMENSION.SystemValue * 39.3701), "###0.0000")
Me.txt1.Text = maxValueMe.txt2.Text = minValue
Set MYDIMENSION = swModel.Parameter("D2@sketch1")Me.LBLDIM2.Caption = Format((MYDIMENSION.SystemValue * 39.3701), "###0.0000")Me.TXT3.Text = maxValueMe.TXT4.Text = minValue
This code has the dimension value showing in labels and I would like to do the same for the high and low tolerance values in separate text boxes or labels. Thanks in advance.
Please post your whole macro here as I don't see where you declare MYDIMENSION
Retrieving data ...