I am trying to do a very simple thing, But I think I lack some technique, so please help me out.
I have a shaft whose length is defined by a global variable called "length". I have holes on the shaft at different places
Case:1....... when the length of the shaft is 50 inches or less there should only be two holes on each end of the shaft.
Case;2.........when the lenght of the shaft is 50 to 70 inches there should be 2 holes on each side and 2 holes in the center.
case:3..........when the length of the shaft is 70 to 90 there should be holes on each end of the shaft and two holes on the 1/3 part and 2 holes on the 2/3rd part.(attachment is a picture of this)
Basically i want some method where i can put a range to the length to unsuppress or suppress a feature(in this case holes). I tried using if statement but it never took me anywhere. anyone to solve this little problem...
SolidworksConfigurations design Tables
Do you have Solidworks 2012 or newer? You can do that using equations (If/Then statements).
Hi Alin,
Thanks for your help, and to Anna as well.
I will post a model on Monday.
We are using SW2012 SP5, just got the newest upgrade installed.
Looking forward to SW2013 SP1.
A wonderful weekend to you both...
Hi Anna and Alin,
here is the part attached in the post about which i was talking about,I have set up a global variable "length" assigned to the Length of the shaft and I have inserted all the holes into place and confined those holes to the equations. Now
Condition 1: I want to show the "RH/LH end holes" at all times no matter what is the length of the shaft.(simple one no need to do any thing about it)
Condition 2: I want to show the "Center holes" only when the length of the shaft is more than 50 inches and less than, equals to 70 inches( I tried if statement and when i put the equations.......... If ("length">50,"unsuppress", "suppress") and if (length<=70,"unsupress","suppress").....it only considers the later condition and not the first condition.
Condition3: I want to show the "4 Hinge mid holes" only when the length of the shaft is more than 70 inches and less than, equals to 90 inches.(I tried if statement again and getting thge same problem as above)
Condition4: I want to show the "5 Hinge mid holes" only when the length of the shaft is more than 90 inches and less than, equals to 110 inches(I get this to working because i dont care about the holes if they show up when the length is above 110 inches because we only have shafts below 110 inches". I used one if statement (if("length">90,"unsuppress","suppress"))).
Thanks for your help guys and please help me further to get me out of this problem
Hello to all
I have same question. would be happy to get answer. a bit more complicated situation.
if I have two global variable: WIDTH and HEIGHT. how can I write an equation for the 2 conditions to suppress or unsuppress feature in assembly file? how I write the condition AND in the statement?
to make it clear: the conditions are: "WIDTH">500 AND "HEIGHT">1000 , if the both are true "unsuppress" , if the both false "suppress"
thank you
John,
Try this file and here are the equations:
Paul
Thank you so much paul
You are a life saver, it worked exactly how i wanted it to work.
thanks again
Hi Yosi,
You will be using the exact same logic as paul described above. I have attached a simple part to this reply for you. it is just an example of what you have asked and i have added the same equations to it as paul gave me.
Hey Paul,
BTW i could not find this "iif" statement anywhere in the documentation or any tutorials or not even in the classes. Can you tell me where have you found this, i mean i am asking this so that in future i can add that to my search area.
Thanks
John,
Well, to be honest it shouldn't have to be iif, it should just be if... but SPR 620043 says that nested if's are broken... so knowing that VBA is available you can use iif (based on prior knowledge of stuff like this as well as this thread: https://forum.solidworks.com/message/301290#301290, and the one it references here: https://forum.solidworks.com/message/301201#301201)
also S-055893 asks about being able to use VBA logical operators in the equation editor and lays it out like this:
---------------------------------------
Assume the value of a dimension is "D1@Sketch1" = 110
1. Logical Operator: NOT
If a condition is true, NOT makes it false. If a condition is false, NOT makes it true.
"A"= IIF(not("D1@Sketch1")>150,100,80)
Result: A=100
2. Logical Operator: AND
All conditions must be true before an action can be taken.
"B" = IIF("D1@Sketch1">50 AND "D1@Sketch1"<150,100,80)
Result: B=100
3. Logical Operator: OR
At least one of the conditions must be true before an action can be taken.
"C"= IIF("D1@Sketch1">60 OR "D1@Sketch1"<80,100,80)
Result: C = 100
---------------------------------------
so, basically I always use a forum search and a KB search on the customer portal and be very vague with what I search for so I make sure I don't remove what I would really like to see. A little bit of work, but I usually learn something that I can use later even if it isn't what I'm searching for anyway.
Also, your syntax while looking valid, will not even evaluate in Excel. For example try this in excel:
the formula is in the last cell so you can see what I did... it doesn't work. The IF logical test can only be ONE test, but the AND is testing multiple conditions for ALL to be true. So the only way to do it is with nested IF statements... then you have to go down the path I said for finding that nested if's are broken and so on and so forth.
Happy logical testing.
Thanks Paul,
I am a starter in VBA and I only knew about the "if" statement and not about the "iif" but now i know. thanks to you.
also Solidworks does not take in the AND/OR equations and Neither it Works with nested "if" (It works with nested "iif"), that is why i was having hard time. But finally the thing matters that you got me out of it. Thanks for all the explanation and your time.
Hi John,
It helped me very much. thank you.