Reply
Solved! Go to solution

ST8 / VBA : setting dimension upper and lower tolerance not working

Hi All

 

I'm a newbie to programming Solid Edge.  I've been given the task up updating some Excel VBA code to work with ST8.  It's currently working fine with an older version of Edge (ST3 or 4).  All seems good, except for some lines that are supposed to set the upper and lower tolerance on the draft file dimensions, for example:

 

      Set objDims = objSheet.Dimensions

      Set objDim = objDims.Item(i)

      objDim.PrimaryUpperTolerance = dblUpperTol
      objDim.PrimaryLowerTolerance = dblLowerTol

 

If I read the dimension tolerance properties back after setting them like this, they show the updated values, but nothing changes in the draft file.

 

I've tried using strings like "0.05 mm" instead of the double precision variables, but that doesn't work either.

 

What has changed between ST3/4 and ST8 that affects this behaviour?

 

Thanks in advance!

 

Steve

 

8 REPLIES

Re: ST8 / VBA : setting dimension upper and lower tolerance not working

[ Edited ]

There was a change in Tolerances in some version which I can not recall.  The tolerance can now be a text tolerance or a value..   "Alpha" or "Unit" Tolerence.     Looks like SolidEdgeFrameworkSupport.Dimension has property "Type"  that specifies the Tolerence type...

 

Take a look at DimDispTypeConstants:

"Unit Tol"  =  Constant igDimDisplayTypeUnitTolerance = 15

"Alpha Tol" = Constant igDimDisplayTypeTolerance = 2

 

HTH

 

6-1-2017 10-19-42 AM.png

 

 

 

 

===================================================
Matt Johnson
Solid Edge Certified Professional (ST7 & ST8)
Solid Edge ST9 (SEEC) - Production
NX10 (Tc Integration) Pre-Production Testing
Teamcenter 10.1.6

Re: ST8 / VBA : setting dimension upper and lower tolerance not working

[ Edited ]

Also, I believe that legacy drawing will be set to "Alpha" by default. so I assume that sending the DBL may be your issue unless you convert the objdim type to "Unit"  or leave it as "Alpha" and try sending a txt string "0.5"

===================================================
Matt Johnson
Solid Edge Certified Professional (ST7 & ST8)
Solid Edge ST9 (SEEC) - Production
NX10 (Tc Integration) Pre-Production Testing
Teamcenter 10.1.6

Re: ST8 / VBA : setting dimension upper and lower tolerance not working

"after setting them like this, they show the updated values, but nothing changes in the draft file."

maybe a quick oversight on my part... have you tried objDoc.UpdateAll()

or command Constant to update the draft.?
===================================================
Matt Johnson
Solid Edge Certified Professional (ST7 & ST8)
Solid Edge ST9 (SEEC) - Production
NX10 (Tc Integration) Pre-Production Testing
Teamcenter 10.1.6

Re: ST8 / VBA : setting dimension upper and lower tolerance not working

Hi Matt

 

Thanks for all the replies!

 

The dimensions the program is trying to update are set as limit type not alpha or unit tolerance.  I'm not sure waht difference that makes though - Edge remembers the upper and lower tolerances when switching between the types.

 

I've tried using strings to set the tolerance, and tried all the different formats I can think of: "0.05", "0.05mm", "0.05 mm" etc, even "5" - all these would work if typed in directly in Edge.  The only string that changes the setting in Edge from the program is "" - this blanks out the value in Edge (and it does it immediately, without an update command).

 

Setting other dimension properties, such as the text scale, updates the draft file immediately.

 

I'm not sure how to force an update though - objDoc doesn't have an UpdateAll function which you mention, only UpdatePropertyTextCacheAndDisplay and UpdatePropertyTextDisplay, neither of which fix my tolerance problem.

 

Thanks a lot for trying to help me, and if you've got any other ideas I'll gladly try them!

 

Steve

 

 

 

Re: ST8 / VBA : setting dimension upper and lower tolerance not working

Ok, I'm getting closer!  It seems that if the dimension type is set to Limits in the draft file, then changing PrimaryUpperTolerance has no effect.  If the dimension type is Alpha Tolerance then it does update.

 

I'll try programmatically changing the type to Alpha first, then back to Limits after I've changed the tolerances.

Re: ST8 / VBA : setting dimension upper and lower tolerance not working

Hmm, that's proving a bit tricky too.  The code referenced here

 

https://docs.plm.automation.siemens.com/docs/se/108/api/webframe.html

 

says to do this:

 

'set the dimension display type to Limits    

objDim.DisplayType = igDimDisplayTypeTolerance

 

but that doesn't work.

Re: ST8 / VBA : setting dimension upper and lower tolerance not working

[ Edited ]

Ok, it does work if there are values in the upper and lower tolerances!  Even if these are zeros.

 

Problem is that when I change the type to Limits is still ignores the PrimaryUpperTolerance and PrimaryLowerTolerance values I have set previously, and that show fine when the Type is Alpha Tolerance.

 

So, my workaround for now is going to be to change the display of all the tolerances to Alpha, set the upper and lower tolerances, and just leave them like that!

 

If the users complain I'll tell them it's better than having a zero tolerance band to aim for :-)

 

Solution
Solution
Accepted by topic author exeeco
‎06-07-2017 12:02 PM

Re: ST8 / VBA : setting dimension upper and lower tolerance not working

Hi again, thought I'd come back and close this out as I accidently stumbled across the solution whilst debugging another issue...

 

So, to set the upper and lower tolerances for dimensions set to Limits, you need to first set the display type to Unit Tolerance, then write to the each tolerance property using a string but avoiding any alpha characters such as 'mm' - the string has to represent a number only otherwise it will be ignored - and finally setting the display type back to Limits.

 

This code snippet gives a working example:

 

    'set the dimension display type to Unit Tolerance
    objDim.DisplayType = igDimDisplayTypeUnitTolerance
    'set Upper and Lower Tolerances, don't use alpha characters!
    objDim.PrimaryUpperTolerance = "0.05"
    objDim.PrimaryLowerTolerance = "-0.05"
    'set the dimension display type to Limits
    objDim.DisplayType = igDimDisplayTypeLimits

 

Hope this helps someone who's been as confused as I was!

 

Steve