Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

IF statement in IV parameters?

14 REPLIES 14
Reply
Message 1 of 15
Anonymous
5132 Views, 14 Replies

IF statement in IV parameters?

Is there a way to use an IF statement in an IV parameter equation? For example, if I have one parameter (P) that may be set to either 6", 12" or 18", can another parameter (R) have an equation that says: IF P=6", THEN R=1; IF P = 12", THEN R=2, etc.? I guess I'm looking for something similar to what you could do in Excel. (Yeah, I know I could link/embed a spreadsheet, but it seems like a bit of a waste just to get one formula.) FYI, the values above are made up. I can't do something as simple as R=P/6. Thanks, Blane
14 REPLIES 14
Message 2 of 15
Anonymous
in reply to: Anonymous

You can simulate IF THEN statements using MIN Max statements but they get very ugly. A better solution is to be a VBA function. See my tutorial on the subject... http://www.sdotson.com/freetut/vba%20functions%20in%20parts%20part%20one.pdf (if you want to go the MIN MAX route see this tutorial. It's about motion but it shows you how to use them) http://www.sdotson.com/freetut/advanced%20motion%20part%20one.pdf -- Sean Dotson, PE Autodesk Inventor Certified Expert http://www.sdotson.com http://www.sdotson.com/forums/ Check the Inventor FAQ for most common questions http://tinyurl.com/2mk45 ----------------------------------------------------------------------- "BTBeilke" wrote in message news:40a268a9$1_3@newsprd01... > Is there a way to use an IF statement in an IV parameter equation? For > example, if I have one parameter (P) that may be set to either 6", 12" or > 18", can another parameter (R) have an equation that says: IF P=6", THEN > R=1; IF P = 12", THEN R=2, etc.? I guess I'm looking for something similar > to what you could do in Excel. (Yeah, I know I could link/embed a > spreadsheet, but it seems like a bit of a waste just to get one formula.) > > FYI, the values above are made up. I can't do something as simple as R=P/6. > > Thanks, > > Blane > >
Message 3 of 15
Anonymous
in reply to: Anonymous

This tutorial written by Sean Dotson shows exactly what you want: http://www.sdotson.com/freetut/vba%20functions%20in%20parts%20part%20one.pdf HTH Glenn "BTBeilke" wrote in message news:40a268a9$1_3@newsprd01... > Is there a way to use an IF statement in an IV parameter equation? For > example, if I have one parameter (P) that may be set to either 6", 12" or > 18", can another parameter (R) have an equation that says: IF P=6", THEN > R=1; IF P = 12", THEN R=2, etc.? I guess I'm looking for something similar > to what you could do in Excel. (Yeah, I know I could link/embed a > spreadsheet, but it seems like a bit of a waste just to get one formula.) > > FYI, the values above are made up. I can't do something as simple as R=P/6. > > Thanks, > > Blane > >
Message 4 of 15
Anonymous
in reply to: Anonymous

Either from the help or Sean's site, I found a list of functions that could be used in edit boxes. IF was not one of them. I don't think IV edit boxes can handle and "Logic" operators.

The only way I have found I can do this is with a linked spreadsheet. Both Sean's and Kent's sites have examples of this.

Pete
Message 5 of 15
Anonymous
in reply to: Anonymous

Thanks guys. I was already looking at Sean's tutorial, but since it was originally written for IV6, I was hoping maybe there was an easier way. Do to the problems that can arise from having VBA in too many parts in a large assembly, I've tried to refrain from using macros embedded in individual parts. But, in this case, I may have little choice. Also, I seem to remember reading that you can't put a macro like this in the Default.ivb. Is that a true statement? Thanks again, Blane
Message 6 of 15
Anonymous
in reply to: Anonymous

No, nothing new yet. While it is true about having too much code in too many files, I imagine you are not going to have this type of code in a majority of your files, therefore you should not have issues. I use this technique on multi-position air cylinders or linear slides to control positions. -- Sean Dotson, PE Autodesk Inventor Certified Expert http://www.sdotson.com http://www.sdotson.com/forums/ Check the Inventor FAQ for most common questions http://tinyurl.com/2mk45 ----------------------------------------------------------------------- "BTBeilke" wrote in message news:40a26da5$1_1@newsprd01... > Thanks guys. I was already looking at Sean's tutorial, but since it was > originally written for IV6, I was hoping maybe there was an easier way. Do > to the problems that can arise from having VBA in too many parts in a large > assembly, I've tried to refrain from using macros embedded in individual > parts. But, in this case, I may have little choice. > > Also, I seem to remember reading that you can't put a macro like this in the > Default.ivb. Is that a true statement? > > Thanks again, > > Blane > >
Message 7 of 15
shastu
in reply to: Anonymous

I went through this tutuorial and got it to work and am now trying to apply it to my application. Mine however is not dealing with intergers as an output. Instead I want to use parameter names.

So my outputs are:
EQUATION - 0
EQUATION - PITCH
Message 8 of 15
Anonymous
in reply to: Anonymous

User defined functions can have any number of arguments (Sean's tutorial
shows an example with two parameters). So you should be able to pass
EQUATION and PITCH as additional parameters.

You could also use the technique described in
http://discussion.autodesk.com/thread.jspa?messageID=5181024



wrote in message news:5198578@discussion.autodesk.com...
I went through this tutuorial and got it to work and am now trying to apply
it to my application. Mine however is not dealing with intergers as an
output. Instead I want to use parameter names.

So my outputs are:
EQUATION - 0
EQUATION - PITCH
Message 9 of 15
shastu
in reply to: Anonymous

This is a bit over my head, but if I am thinking right, I am not talking about the number of arguments, but a variable output. For example, in the tutorial, he has NumHoles = 6, 8, 10, and 12. For my example, I would want NumHoles to equal a parameter name.
Message 10 of 15
Anonymous
in reply to: Anonymous

His example can be modified so:

Public Function NumHoles(OutsideDiam as Double, MyParameter as Double) as
Double

if aOutsideDiam < = (6 *2.54) then
NumHoles = MyParameter
...

End Function

wrote in message news:5198636@discussion.autodesk.com...
This is a bit over my head, but if I am thinking right, I am not talking
about the number of arguments, but a variable output. For example, in the
tutorial, he has NumHoles = 6, 8, 10, and 12. For my example, I would want
NumHoles to equal a parameter name.
Message 11 of 15
shastu
in reply to: Anonymous

That is what I did and it doesn't work. Here, I even used the same example to simplify. Take a look.
Message 12 of 15
Anonymous
in reply to: Anonymous

When you call the function, you need to pass the other arguments like this:

VBA:NumHoles(d16;ONE;TWO;THREE;FOUR) * 1 ul

wrote in message news:5198846@discussion.autodesk.com...
That is what I did and it doesn't work. Here, I even used the same example
to simplify. Take a look.
Message 13 of 15
shastu
in reply to: Anonymous

THANKS!, I will try and apply that to mine now.
Message 14 of 15
shastu
in reply to: Anonymous

NEVER MIND! Message was edited by: shastu
Message 15 of 15
ACEDeSmedt
in reply to: Anonymous

It can be done in a simple way see my reply at this question ->  http://forums.autodesk.com/t5/inventor-general-discussion/if-then-operations-for-parameters/m-p/5304...

 

=================================
If this is the solution, push the solution button 😉 (and maybe some kudos)
Autodesk Product Design Suit - Ultimate edition (Subscription)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report