• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Autodesk Inventor

    Reply
    Contributor
    Posts: 24
    Registered: ‎01-16-2013

    iLogic If then formulas

    159 Views, 5 Replies
    02-06-2013 12:40 AM

    Hi!

     

    I have an assembly with several parts where I use a pattern to duplicate the parts in the height. I cannot use the pattern sideways due to different center distances between the parts. I could get this distance by using several patterns, but I rather not if there is another way.

     

    I have made a code for suppressing the parts in element 2 if the same part is suppressed in element 1.

    IfComponent.IsActive("FB-07 midtstykke-001:1")=False ThenComponent.IsActive("FB-07 midtstykke-001:2")=FalseElseComponent.IsActive("FB-07 midtstykke-001:2")=TrueEndIf

    which works fine, however, I only want the rule to run if two criterias are true. I`ve tried the following:

     

    If Component.IsActive("FB-02 midtstykke-001:1") = False And No = 2 Then

    component.IsActive("FB-07 midtstykke-001:2") = False

    Else

    Componen.....

    End if

     

    But this rule runs even if No = 3, which it shouldnt. Any ideas?

     

    Thanks in advance :smileyhappy:

    Please use plain text.
    Valued Contributor
    Posts: 94
    Registered: ‎09-10-2012

    Re: iLogic If then formulas

    02-06-2013 02:37 AM in reply to: 128848

    I usually use this method as I have had trouble using 'AND'.

     

    If Component.IsActive("FB-02 midtstykke-001:1") = False

             If No = 2 Then

             component.IsActive("FB-07 midtstykke-001:2") = False

             Else

             Componen.....

             End If

    Else

    Component...

    End if

     

    It's basically just an IF within an IF

    Wayne Helley
    Inventor 2013 Certified Professional

    Autodesk Inventor Professional 2011
    Windows 7 Enterprise, 64-bit
    Please use plain text.
    Contributor
    Posts: 24
    Registered: ‎01-16-2013

    Re: iLogic If then formulas

    02-06-2013 06:44 AM in reply to: waynehelley

    Nice, Thank you!

    However, this code does not turn the part back on if Component.IsActive("FB-02 midtstykke-001:1") = True

     

    If Component.IsActive("FB-07 midtstykke-001:1")=False Then	IfNo=2 ThenComponent.IsActive("FB-07 midtstykke-001:2")=FalseElseComponent.IsActive("FB-07 midtstykke-001:2")=TrueEndIf	EndIf
    IfComponent.IsActive("FB-07 midtstykke-001:1")=TrueThen IfNo=2 ThenComponent.IsActive("FB-07 midtstykke-001:2")=TrueElseComponent.IsActive("FB-07 midtstykke-001:2")=FalseEndIfEndIf

    What would the code be if I should have used 1 if then code? Is it better to use 1 more complex then 2 "easier" code?this code will be copied maaaaany times!

    Please use plain text.
    Contributor
    Posts: 24
    Registered: ‎01-16-2013

    Re: iLogic If then formulas

    02-06-2013 06:45 AM in reply to: 128848

    some thing happend there.

     

    Basically the same formula, but if compon... = True then

    if No = 2 then

    Com....

    Please use plain text.
    Valued Contributor
    Posts: 94
    Registered: ‎09-10-2012

    Re: iLogic If then formulas

    02-06-2013 07:22 AM in reply to: 128848

    You shouldn't have to copy the code twice with 'False' replaced with 'True.  The function after 'Else' should do this for you. 

     

    What is 'No'?  If it is a parameter, then you will need to replace it with 'Parameter("No")'.   

     

    I'm not sure I understand what you are wanting to achieve but try pasting the following. 

     

    If Component.IsActive("FB-02 midtstykke-001:1") = False Then

             If Parameter("No") = 2 Then

             Component.IsActive("FB-07 midtstykke-001:2") = False

             Else

             Component.IsActive("FB-07 midtstykke-001:2") = True

             End If

    Else

    component.IsActive("FB-07 midtstykke-001:2") = True

    End if

    Wayne Helley
    Inventor 2013 Certified Professional

    Autodesk Inventor Professional 2011
    Windows 7 Enterprise, 64-bit
    Please use plain text.
    *Expert Elite*
    mrattray
    Posts: 1,485
    Registered: ‎09-13-2011

    Re: iLogic If then formulas

    02-06-2013 09:55 AM in reply to: 128848

    The "And" function works just fine for me in my applications, I use it extensively. Can you post your files or an example that shows the same problem for me to look at?

    Mike (not Matt) Rattray

    Please use plain text.