I have code to apply various dia tolerances on a drawing viavarious buttons - works perfect for normal dimensions but I'mhaving issues applying it to hole wizard callouts:
Private Sub Tol1_0_Click()
Call Change_Tolerance(0.0000254, 0, 3, 3)
End Sub
Public Sub Change_Tolerance(UpperLimit, LowerLimit, Precision,DimType)
For i = 1 To swSelMgr.GetSelectedObjectCount()
Set swDimension = swSelMgr.GetSelectedObject2(i)
Set swDispDim = swSelMgr.GetSelectedObject3(i)
swDimType = swSelMgr.GetSelectedObjectType(i)
If swDimType = swSelDIMENSIONS Then
'If the selected item is a dimension
If swDispDim.IsHoleCallout() = False Then
retval = swDimension.SetToleranceType(DimType)
retval = swDimension.SetToleranceValues(LowerLimit, UpperLimit)
retval = swDispDim.SetPrecision(False, Precision, Precision,Precision, Precision)
'If the selected item is a callout
Else
Set swCalloutDimension = swDispDim.GetDimension()
retval = swCalloutDimension.SetToleranceType(DimType)
retval = swCalloutDimension.SetToleranceValues(LowerLimit,UpperLimit)
retval = swDispDim.SetPrecision(False, Precision, Precision,Precision, Precision)
End If
End If
Next i
End Sub
I was hoping I could use GetDimension to apply tolerances to theunderlying dimensions...which would then update in the callout.Maybe I'm just heading down the wrong path. Any ideas?SolidworksApi macros
Private Sub Tol1_0_Click()
Call Change_Tolerance(0.0000254, 0, 3, 3)
End Sub
Public Sub Change_Tolerance(UpperLimit, LowerLimit, Precision,DimType)
For i = 1 To swSelMgr.GetSelectedObjectCount()
Set swDimension = swSelMgr.GetSelectedObject2(i)
Set swDispDim = swSelMgr.GetSelectedObject3(i)
swDimType = swSelMgr.GetSelectedObjectType(i)
If swDimType = swSelDIMENSIONS Then
'If the selected item is a dimension
If swDispDim.IsHoleCallout() = False Then
retval = swDimension.SetToleranceType(DimType)
retval = swDimension.SetToleranceValues(LowerLimit, UpperLimit)
retval = swDispDim.SetPrecision(False, Precision, Precision,Precision, Precision)
'If the selected item is a callout
Else
Set swCalloutDimension = swDispDim.GetDimension()
retval = swCalloutDimension.SetToleranceType(DimType)
retval = swCalloutDimension.SetToleranceValues(LowerLimit,UpperLimit)
retval = swDispDim.SetPrecision(False, Precision, Precision,Precision, Precision)
End If
End If
Next i
End Sub
I was hoping I could use GetDimension to apply tolerances to theunderlying dimensions...which would then update in the callout.Maybe I'm just heading down the wrong path. Any ideas?SolidworksApi macros
