
Re: Referencing a range in an equation
Mike Pogue Jan 26, 2015 12:32 PM (in response to Oli Sparrow)You can do this with a straightforward mapping function, something like INT((B32001)/2000)+3, but not exactly.
Did you mean for your second bucket to have 3000 and all of the others to have 2000? That will make the mapping less elegant.

Re: Referencing a range in an equation
Mike Pogue Jan 27, 2015 12:58 AM (in response to Mike Pogue)This repeats every 2000 ad infinitum.
= 2 + IIF ("x" > = 2001 , 1 , 0 ) + IIF ( "x" > = 5001 , 1 , 0 ) + int ( ( "x"  5001 ) / 2000 ) * iif ( "x" > 5001 , 1 , 0 )


Re: Referencing a range in an equation
Steven Tietz Jan 26, 2015 12:42 PM (in response to Oli Sparrow)I think what you need is to use the AND function  see below:
= IIF ( "LENGTHd2@Sketch1" > 2000 and "LENGTHd2@Sketch1" < 4999.99, 3 , 2 )
in the above example I did not use 5000 because if D2 = 5000 then it is not less than 5000 & thus it would return the false. I don't think solidworks supports less than or equal to (or at least I cannot get it to work)

Re: Referencing a range in an equation
Gary Blenkhorn Jan 26, 2015 3:10 PM (in response to Steven Tietz)then you should use 5001 in the second part. with 4999.99 he would not get the 5000 referenced.

Re: Referencing a range in an equation
Steven Tietz Jan 26, 2015 4:03 PM (in response to Gary Blenkhorn)oh yeah that would make sense...
either way  using "and" should help to achieve desired results.



Re: Referencing a range in an equation
Kevin Chandler Jan 26, 2015 3:51 PM (in response to Oli Sparrow)I used four global variables to achieve what you're looking for.
cnt3 = if ( "testcnt" > 1999 and "testcnt" < 5001 , 3 , 0 )
cnt4 = if ( "testcnt" > 5000 and "testcnt" < 7001 , 4 , 0 )
cnt5 = if ( "testcnt" > 7000 and "testcnt" < 9001 , 5 , 0 )
TotalCount = cnt3 + cnt4 +cnt5
Replace "testcnt" with your dim variable (I didn't have a dim that large so I used a global var).
Then reference your instance variable to point to "TotalCount".
You may need to modify the test condition values.
Also, there's no explicit test for <2000 or >9000. if so, then your "TotalCount" will be zero.
I hope this helps.
Kevin

Re: Referencing a range in an equation
Kevin Chandler Jan 26, 2015 3:55 PM (in response to Kevin Chandler)Oops, I missed the <2000 count of 2 instances, but the basic scheme remains the same, just add cnt2:
cnt2 = if ( "testcnt" < 2001 , 2 , 0 )
cnt3 = if ( "testcnt" > 1999 and "testcnt" < 5001 , 3 , 0 )
cnt4 = if ( "testcnt" > 5000 and "testcnt" < 7001 , 4 , 0 )
cnt5 = if ( "testcnt" > 7000 and "testcnt" < 9001 , 5 , 0 )
TotalCount = cnt2 + cnt3 + cnt4 +cnt5
Kevin


Re: Referencing a range in an equation
Josh Brady Jan 26, 2015 6:15 PM (in response to Oli Sparrow)Just nest your "ifs" in the proper order. No need to confirm "inbetweenness"
Start by asking if less than 2000. Another "if" goes in the else part to check if less than 3000. etc etc.

Re: Referencing a range in an equation
Daen Hendrickson Jan 26, 2015 7:16 PM (in response to Josh Brady)And keep in mind it needs to be the Iinline IF construct [ IIF(...) ]. The IF(...) will throw a sintax error if nested in the equation manager. (at least is does in SW2013 SP3)
Also, the LESS THAN OR EQUAL TO and the GREATER THAN OR EQUAL TO abilities exist.
YourEquationManagerVariable = iif ( "Vert@Triangle Sketch" > 0 AND "Vert@Triangle Sketch" < = 2000 , 2 , iif ( "Vert@Triangle Sketch" > = 2001 AND "Vert@Triangle Sketch" < = 5000 , 3 , iif ( "Vert@Triangle Sketch" > = 5001 AND "Vert@Triangle Sketch" < = 7000 , 4 , 5 ) ) )
Daen

Re: Referencing a range in an equation
Josh Brady Jan 27, 2015 12:44 PM (in response to Daen Hendrickson)Actually, less than or equal to is not available in 2013 if my recollection is correct. SolidWorks will not accept anything that has an "=" sign on the right side of the main "=" of the equation. Might work in 2014.

Re: Referencing a range in an equation
Mike Pogue Jan 27, 2015 12:49 PM (in response to Josh Brady)Didn't know that. It does work in 2015.

Re: Referencing a range in an equation
Kevin Chandler Jan 27, 2015 12:53 PM (in response to Josh Brady)Nope, not in 2014, sp5.

Re: Referencing a range in an equation
Mike Pogue Jan 27, 2015 1:34 PM (in response to Kevin Chandler)This explains why it did not work at work but started working at home. Well, the rest of it is fine, you can just delete the equals signs and move the limits accordingly.


Re: Referencing a range in an equation
Daen Hendrickson Jan 27, 2015 1:20 PM (in response to Josh Brady)Josh,
I didn't think it worked either... But wanted to take a crack at this for my own education and the equation I posted above is copied from my equation manager and it is working (SW2013 SP3).
I'll attach the part file for anyone else to see if it works in pre2015 (can't figure out how to get to the advanced editor from a reply window).
Daen

Re: Referencing a range in an equation
Daen Hendrickson Jan 27, 2015 2:09 PM (in response to Daen Hendrickson)And the part file...
If you modify the triangle's vertical length dimension, the formulas adjust the horizontal length.
Made with SW2013 SP3.
Daen

Part3.SLDPRT.zip 36.1 KB






Re: Referencing a range in an equation
Oli Sparrow Jan 27, 2015 3:43 AM (in response to Oli Sparrow)To everyone, thanks for the input here. I'll give these a go today.
Thanks