Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations 3DDave on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

SolidWorks BOM & equations with 3 or more variables. 2

Status
Not open for further replies.

Standing

Mechanical
Jan 14, 2002
1,578
The following equation works in SolidWorks to set QTY to FT or just plain QTY.
={2}IF('UoM'="FT";(`Total_Length`/12)" FT";'QTY')

The following also works to put in a quantity of 0 for a property of UoM =’s “NA” or just plain QTY.
={2}IF('UoM'="NA";"0";'QTY')

Does anyone know how to combine the 2 equations to give answers to 3 properties for UoM which are FT, EA and NA.

I have searched here and the web with no luck. I could not find it in the SolidWorks help manual.


Bradley
 
Replies continue below

Recommended for you

IF statements can be nested. Test for one value with the first (outermost) IF, then have another IF statement that tests for the other two values as part of the "FALSE" result for the first IF.
 
TheTick,
Thanks for the reply. I have been trying all kinds of syntax for nesting, with no luck at all. This is the last formula I have tried. Do you have any suggestions?

={2}IF('UoM'="EA";('UoM'="FT";(`Total_Length`/12)" FT";('UoM'="NA";'0')'QTY')


Bradley
 
Try this;

={2}IF('UoM'="EA";'QTY';IF('UoM'="FT";('Total_Length'/12)" FT";IF('UoM'="NA";"0";"?")

The "?" will be returned if the input is anything other than "EA", "FT" or "NA". It can be substituted by any character or left blank as "".

[cheers]
 
I am trying to learn that "IF THEN ELSE" in the equations - obviously the above is a non-starter for me.

I tried to follow
"D1@Sketch1" = (IIf("D1@Sketch4">15, 20, 10)) + 8
explanation from SW2006 Help, but I am getting syntax errors - I suspect the sample is wrong.

I must add some years ago I was doing some programming in Basic (NOT VisualBasic), also in Assembler and in C and I do understand the following:

IF

THEN

ELSE

ENDIF

Could anybody vrite some simple IF that could be used in the SW equation - that would get me started.

Thanks in advance.
 
CorBlimeyLimey and TheTick

I wish I could give you both more than one star. You helped me a great deal with this problem. Once I knew where to go (with your help) I came up with the following:

={2}IF('UoM'="EA";'QTY';IF('UoM'="FT";('Length'/12)" FT";IF('UoM'="NA";"0";'QTY')))

I changed the ? to QTY because lots of our models never got a UoM property. Also added a couple of ).

Thanks again for the help.


Bradley
 
Bradley ... just noticed (because of Jacek0841's post) that the IF function should be IIF and the semi-colons should be commas.

jacek0814 ... that equation works OK for me. Are you using a model with suitable sketches and dimensions.
i.e. one with at least 4 sketches and a D1 dimension in at least Sketch1 and Sketch4?

[cheers]
 
CorBlimeyLimey,

I tried changing IF to IIF and the semi-colons to commas.

={2}IIF('UoM'="EA",'QTY',IIF('UoM'="FT",('Length'/12)" FT",IIF('UoM'="NA","0",'QTY')))

That did not work for me. SolidWorks just put the formula in QTY box. The following is working so I think I will leave it at that.

={2}IF('UoM'="EA";'QTY';IF('UoM'="FT";('Length'/12)" FT";IF('UoM'="NA";"0";'QTY')))

Thanks so much for your help.


Bradley
 
Which version of SW are you using? SW06 and SW07 reported syntax errors for me if I used IF or semi-colons.

[cheers]
 
I am using SolidWorks 2007 Sp 2.0 XP 64 bit.
I really like this SolidWorks BOM better than Excel.

Bradley
 
SW2006 SP 5.0

Finally got it working - thanks for the help.

BTW, my confusion was also that IIF - I thought that's a typo, I thought it should be IF.

Second thing - I have to use , if I use ; it reports syntax error ...
 
Oops sorry ... I was referring to an equation in a part. I missed that you were in a BOM. The SW table based BOM uses the IF and semi-colon. Nice consistency SolidWorks! Go figure!

[cheers]
 
CorBlimeyLimey,
I tried to find this information in the SolidWorks 2007 Online User’s Guide – SP0.0.

How do you learn these things? All I found in User’s Guide is the following:

IF(logical_test; value_if_true; value_if_false).


Bradley
 
You just have to keep poking around and follow all the Related Topics links and the hyperlinks within them.

[cheers]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor