Inventor Engineer-To-Order (Read-Only)
Welcome to Autodesk’s Inventor ETO Forums. Share your knowledge, ask questions, and explore popular Inventor ETO topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

if statement controlling parameters in child...

5 REPLIES 5
Reply
Message 1 of 6
matthew.nichols
469 Views, 5 Replies

if statement controlling parameters in child...

Question on building an if statement for 

I want to say:

if this value is less than 50 then

d0 = Width

d1 = length

else

d0 = length

d1 = width

end if

How would i go about setting this one up, because i don't see the option for an if statement inside of a child.

 

Thank you for the help.

5 REPLIES 5
Message 2 of 6

Hi,

What you can do is write a method that takes the necessary parameters and returns a list. Something like this :

 

Method Method_Name (value_to_check as number, threshold as number,length as number,width as number) as List

 if value_to_Check>threshold then

  return {width,length}

 else

  return {length,width}

 end if

end Method

 

And the childrule will become somethig like this :

 

child XYZ as :child_design

 d0 = First(Method_Name(this_value,50,Length,Width))

 d1 = Second(Method_Name(this_value,50,Length,Width))

end child

 

Hopes this helps ?

 

Cheers,

Mark

Message 3 of 6

What I forgot to mention :

It's also possible to do something like this

 

Child child1 as :childrule

...

 do=(if this_value<50 then length else width)

 d1=(if this_value<50 then width else length)

...

end child

 

 

Cheers,

Mark

Message 4 of 6

Yes, a Child rule body is not a procedural block, like is available in other rules and methods.  You can't put ifs around parameter assignments.  And remember, this is very important: your assignments might NEVER be evaluated.  The assignments are only evaluated on demand.  This is not a list of assignments that happens when the child instance is created.  It is a list of things the child can get.  You can assign to a non-existent parameter, and it will never tell you, and it will never evaluate it.

 

Although I haven't read them in detail, Mark's answers are legit, but maybe it is more normal to handle the conditions inside the child's Design definition. But I guess it depends on the situation.

Message 5 of 6

Jack,

If I understand you correctly : when a parameter is used in a method and the parametervalue changes, the method is not re-executed and therefore all other rules, that consume this method, are also not updated !

 

Cheers,

Mark

Message 6 of 6

No, I was only talking about the Child rule construct:

 

Child FooBar As :FunkyMonkey

  param1 = "yes" + "no"

  param2 = false

  param3 = sqrt(1 + aspectRatio^2)

  param86 = setDate(System.DateTime.Now)

End Child

 

Let's say that param1, param2, and param3 are parameter rules in FunkyMonkey.  They may or not get evaluated here.  And, if param1 is evaluated, there is no guarantee that param3 will be, because these are only evaluated when demanded.  A child rule is never "run".  It is not a block of code.

 

And, furthermore, if FunkyMonkey has no Parameter param86, the setDate( ) call will never happen.

 

Your actual question uses terms that we do not, so I want to be careful.  "consume this method" doesn't make sense.  Methods are uncached rules that take arguments (like functions).  The only thing that evaluates anything is a demand for it.  If you have a specific construct you would like me to address, that would allow me to give a clearer answer.

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

Post to forums  

Autodesk Design & Make Report