几何尺寸与公差论坛

 找回密码
 注册
查看: 659|回复: 0

【转帖】ifthen equation

[复制链接]
发表于 2009-4-13 12:08:51 | 显示全部楼层 |阅读模式
if/then equation
hello everyone,
i am trying to do what is probably a fairly simple equation, but i am not having much success. i have a piece of formed channel sheet steel, and i have a hole that is patterned in it. i want to put a if/then that has three parameters in it that state if the overall length of the part is 120 or greater, then the pattern distance is 3. if the overall length of the part is 110 to 119, then the pattern distance is 2. and finally, if the overall length of the part is less than 110, then the pattern distance is 1.
does anyone know if this can be done, and if so, what the equation might look like?
aaron
solidworks/pdmworks 08 4.0
cadkey 99 r1.0 (yes, still using it!)

find a job or post a job opening
you can use the iif statement from vba.  syntax for iif is:
iif([condition],[value if true],[value if false])
iif statements can be nested.
basically, if your pattern distance is "p" and your overall length is "l" then your equation would be:
p = iif(l>=120,3,iif(l<110,1,2))
-handleman, cswp (the new, easy test)
you can also achieve the same in a design table where the hole pattern quantity has they typical if/then statement out of excel, referencing the length dimension.
jeff mirisola, cswp, certified driveworks ae
handleman,
i tried your suggestion, and i am still doing something wrong. i have uploaded a couple pictures of the equations i did to try and simulate what you did. am i doing something wrong with punctuation perhaps? im addition to using "p" and "l" in the equation, i tried it with the actual dimension names to no avail (pic 3).
aaron
solidworks/pdmworks 08 4.0
cadkey 99 r1.0 (yes, still using it!)

aaron,
create a design table that captures the length and the pattern distance. once created, click on the cell that contains the pattern distance and replace it with this formula:
=if(b2>=120,3,(if(b2<=110,1,2)))
b2 represents the cell that contains the length dimension, so change it accordingly.   
jeff mirisola, cswp, certified driveworks ae
jeff,
thank you, it works great! it will only update if i go into the design table though. is there a way to make it update after a rebuild?
aaron
solidworks/pdmworks 08 4.0
cadkey 99 r1.0 (yes, still using it!)

you should be able to hit 'ctrl+q' to get it to rebuild.
jeff mirisola, cswp, certified driveworks ae
that's the downside of a dt, it has to be opened to be updated; an equation doesn't.

here is a sample without a design table.  simply change the length and the rest changes as requested.  (the ref dimension showed is only to show that it is changing)
that's strange. the = isn't being accepted in the iif portion of the equation.
i think you've discovered a bug.

smcadman,
exactly what i was hoping to do! (except for the 119.999 thingy, but that can be dealt with) thank you sir!
aaron
solidworks/pdmworks 08 4.0
cadkey 99 r1.0 (yes, still using it!)
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|小黑屋|几何尺寸与公差论坛

GMT+8, 2024-12-23 23:45 , Processed in 0.035085 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表