Preview | SOLIDWORKS USER FORUM
Use your SOLIDWORKS ID or 3DEXPERIENCE ID to log in.
AKAhmed Kotb07/03/2012
Hello everyone. i hope you are so fine.
i am making a program which requires me to select a lot of dimensions, then modeify some of their properties (tolerance) according to a specified criterion.
i started by making a selection of all dimensions for them i want to change tolerances, then i, get access to each of them accoring to the selection order. the problem is that when i write the editing code, it changes all of them, which required an additional time to loop through them accurately.
i wrote the following code:
Set swApp = Application.SldWorks | ||
Set swModel = swApp.ActiveDoc | ||
Set swSelMgr = swModel.SelectionManager | ||
num = swSelMgr.GetSelectedObjectCount() | ||
If num = 0 Then | ||
MsgBox (" Please select one dimension at least to setup its tolerance!") | ||
Exit Sub | ||
End If | ||
For j = 1 To num | ||
Set swDispDim = swSelMgr.GetSelectedObject5(1) | ||
Set swDim = swDispDim.GetDimension | ||
dimValue = swDim.IGetValue3(swThisConfiguration, 1, "Default") | ||
dimText = swDispDim.GetText(1) | ||
MsgBox (dimText) | ||
If dimValue >= 1 And dimValue < 6 Then | ||
boolstatus = swModel.EditDimensionProperties2(swTolSYMMETRIC, 0.0001, 0, "", "", True, 9, 2, True, 12, 12, "", "", True, "", "", False) | ||
ElseIf dimValue >= 6 And dimValue < 30 Then | ||
boolstatus = swModel.EditDimensionProperties2(swTolSYMMETRIC, 0.0002, 0, "", "", True, 9, 2, True, 12, 12, "", "", True, "", "", False) | ||
ElseIf dimValue >= 30 And dimValue < 50 Then | ||
boolstatus = swModel.EditDimensionProperties2(swTolSYMMETRIC, 0.0003, 0, "", "", True, 9, 2, True, 12, 12, "", "", True, "", "", False) | ||
ElseIf dimValue >= 50 And dimValue < 100 Then | ||
boolstatus = swModel.EditDimensionProperties2(swTolSYMMETRIC, 0.0004, 0, "", "", True, 9, 2, True, 12, 12, "", "", True, "", "", False) | ||
ElseIf dimValue >= 100 And dimValue < 500 Then | ||
boolstatus = swModel.EditDimensionProperties2(swTolSYMMETRIC, 0.0005, 0, "", "", True, 9, 2, True, 12, 12, "", "", True, "", "", False) | ||
ElseIf dimValue >= 500 Then | ||
boolstatus = swModel.EditDimensionProperties2(swTolSYMMETRIC, 0.0006, 0, "", "", True, 9, 2, True, 12, 12, "", "", True, "", "", False) | ||
End If | ||
boolstatus = swModel.DeSelectByID(swDim.GetNameForSelection(), "DIMENSION", 0, 0, 0) |
Next |