SWVB101
Mechanical
- Jun 25, 2003
- 85
In A SolidWorks drawing...
When you select a Dimension the SelectionManager returns an object with the type value of 14 (Dimension)
I want to be able to select a dimension in solidworks and press a button to change the precision of the dimension and it's tolerance...
to do this you must use the DisplayDimension::SetPrecision method...
But this method is ONLY for the DisplayDimension object and not the Dimension Object...
The DisplayDimension displays the value of the Dimension object...
But like I said above when you select a DisplayDimension in a drawing the Selection Manager Returns the Dimension Object...
If you have the DisplayDimension you can get the Dimension Value using DisplayDimension::GetDimension method
Does anyone know how to do the oposite and get the DisplayDimension from the object that the selection manager Returns, or a better way to do the required task? here is a code sipplet to start with...
Thanks,
-Josh-
When you select a Dimension the SelectionManager returns an object with the type value of 14 (Dimension)
I want to be able to select a dimension in solidworks and press a button to change the precision of the dimension and it's tolerance...
to do this you must use the DisplayDimension::SetPrecision method...
But this method is ONLY for the DisplayDimension object and not the Dimension Object...
The DisplayDimension displays the value of the Dimension object...
But like I said above when you select a DisplayDimension in a drawing the Selection Manager Returns the Dimension Object...
If you have the DisplayDimension you can get the Dimension Value using DisplayDimension::GetDimension method
Does anyone know how to do the oposite and get the DisplayDimension from the object that the selection manager Returns, or a better way to do the required task? here is a code sipplet to start with...
Code:
Private Sub Command1_Click()
Dim swApp as object, Part as Object
Set swApp = CreateObject("SldWorks.Application")
Set Part = swApp.ActiveDoc
Dim SelMgr As SelectionMgr, SelObj As Object, DDim As DisplayDimension
Dim L As Long, P As Long, Ret As Long
Set SelMgr = Part.SelectionManager()
If (SelMgr.GetSelectedObjectCount >= 1) Then
Text1 = ""
P = 2 'Precision
For L = 1 To SelMgr.GetSelectedObjectCount
Text1 = Text1 & SelMgr.GetSelectedObjectType(L) & "; "
If (SelMgr.GetSelectedObjectType(L) = 14) Then
'The Next Line Causes an error...
Set DDim = SelMgr.GetSelectedObject2(L)
Ret = DDim.SetPrecision(False, P, P, P, P)
End If
Next
End If
End Sub
Thanks,
-Josh-