Zero tolerance values

<p><span style="color: #465584; font-family: Courier, 'Courier New', Verdana, Arial; font-size: 12px; background-color: #fafcfe;">Option Explicit</span></p><p><span style="color: #465584; font-family: Courier, 'Courier New', Verdana, Arial; font-size: 12px; background-color: #fafcfe;">Dim swApp As SldWorks.SldWorks</span></p><p><span style="color: #465584; font-family: Courier, 'Courier New', Verdana, Arial; font-size: 12px; background-color: #fafcfe;">Dim swModel As SldWorks.ModelDoc2</span></p><p><span style="color: #465584; font-family: Courier, 'Courier New', Verdana, Arial; font-size: 12px; background-color: #fafcfe;">Dim swSelMgr As SldWorks.SelectionMgr</span></p><p><span style="color: #465584; font-family: Courier, 'Courier New', Verdana, Arial; font-size: 12px; background-color: #fafcfe;">Dim swDisplayDimension As SldWorks.DisplayDimension</span></p><p><span style="color: #465584; font-family: Courier, 'Courier New', Verdana, Arial; font-size: 12px; background-color: #fafcfe;">Dim swDimension As SldWorks.Dimension</span></p><p><span style="color: #465584; font-family: Courier, 'Courier New', Verdana, Arial; font-size: 12px; background-color: #fafcfe;">Dim swDimensionTolerance As SldWorks.DimensionTolerance</span></p><p><span style="color: #465584; font-family: Courier, 'Courier New', Verdana, Arial; font-size: 12px; background-color: #fafcfe;">Dim fontHeight As Double</span></p><p><span style="color: #465584; font-family: Courier, 'Courier New', Verdana, Arial; font-size: 12px; background-color: #fafcfe;">Dim fontScale As Double</span></p><p><span style="color: #465584; font-family: Courier, 'Courier New', Verdana, Arial; font-size: 12px; background-color: #fafcfe;">Dim bRet As Boolean</span></p><p><br style="color: #465584; font-family: Courier, 'Courier New', Verdana, Arial; font-size: 12px;"></p><p><span style="color: #465584; font-family: Courier, 'Courier New', Verdana, Arial; font-size: 12px; background-color: #fafcfe;">Sub main()</span></p><p><span style="color: #465584; font-family: Courier, 'Courier New', Verdana, Arial; font-size: 12px; background-color: #fafcfe;">Set swApp = Application.SldWorks</span></p><p><span style="color: #465584; font-family: Courier, 'Courier New', Verdana, Arial; font-size: 12px; background-color: #fafcfe;">Set swModel = swApp.ActiveDoc</span></p><p><span style="color: #465584; font-family: Courier, 'Courier New', Verdana, Arial; font-size: 12px; background-color: #fafcfe;">Set swSelMgr = swModel.SelectionManager</span></p><p><span style="color: #465584; font-family: Courier, 'Courier New', Verdana, Arial; font-size: 12px; background-color: #fafcfe;">Set swDisplayDimension = swSelMgr.GetSelectedObject6(1, 0)</span></p><p><span style="color: #465584; font-family: Courier, 'Courier New', Verdana, Arial; font-size: 12px; background-color: #fafcfe;">If swSelMgr.GetSelectedObjectType3(1, -1) <> swSelDIMENSIONS Then Exit Sub</span></p><p><span style="color: #465584; font-family: Courier, 'Courier New', Verdana, Arial; font-size: 12px; background-color: #fafcfe;">Set swDimension = swDisplayDimension.GetDimension</span></p><p><span style="color: #465584; font-family: Courier, 'Courier New', Verdana, Arial; font-size: 12px; background-color: #fafcfe;">Set swDimensionTolerance = swDimension.Tolerance</span></p><p><span style="color: #465584; font-family: Courier, 'Courier New', Verdana, Arial; font-size: 12px; background-color: #fafcfe;">swDimensionTolerance.Type = swTolType_e.swTolFIT</span></p><p><span style="color: #465584; font-family: Courier, 'Courier New', Verdana, Arial; font-size: 12px; background-color: #fafcfe;">bRet = swDimensionTolerance.SetFitValues("H12", "")</span></p><p><span style="color: #465584; font-family: Courier, 'Courier New', Verdana, Arial; font-size: 12px; background-color: #fafcfe;">swDimensionTolerance.Type = swTolType_e.swTolFITTOLONLY</span></p><p><span style="color: #465584; font-family: Courier, 'Courier New', Verdana, Arial; font-size: 12px; background-color: #fafcfe;">swModel.GraphicsRedraw2</span></p><p><span style="color: #465584; font-family: Courier, 'Courier New', Verdana, Arial; font-size: 12px; background-color: #fafcfe;">End Sub</span></p>

In this case, the program will insert the "Fit", and the numerical values will be zeros. How to use swTolType_e, tolerance to match fit?

Or is it all a great bug?

SolidworksApi macros
Answers 3
AT
AT 2012-10-18 Best Answer

Hi Oleg,

I have been trying to find a way to load these values automatically but was unable :-(.

When you inserting the tolerance from API the Hole/Shaft fit toggles are not checked which enables/disables the manual values input. And I cannot find the API to enable this toggle. So if you toggle this button after running your code it will load the values.

I believe that this toggle could be forcibly checked with Win API by working with PMP as the dialog but it is too tricky and I'm not completely sure how long it may take for implementation. But if this issue is blocking for you, you may try. Look for Win API controls traversing, SendMessage and something similar.

______________________

Regards,

Artem Taturevych

Application Engineer at Intercad

http://intercad.com.au/

Tel: +61 2 9454 4444

SF
SF 2012-10-19

<span style="font-family: Verdana, Arial, Helvetiva, sans-serif; font-size: 11px; background-color: #ffffff;">Look for Win API</span>

Clear. I find it easier to write database (eg XML) and insert the values ​​manually.

AV
AV 2014-09-03

Hi:

I am also trying the same. I have used following line after changing the fit value. It is working fine. You can also try this.

bret = swmodel.EditDimensionProperties2(8, 0, 0, "H14", "", True, 9, 2, True, 12, 12, "", "", True, "", "", True)

Regards

V K Amirtharaj

EGS Computers India Pvt Ltd

Dassault System SolidWorks Reseller

Chennai | Tamilnadu | India

http://www.egsindia.com/solidworks.html

http://www.egs.co.in