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: 

iLogic If then formulas

5 REPLIES 5
Reply
Message 1 of 6
128848
1760 Views, 5 Replies

iLogic If then formulas

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 🙂

5 REPLIES 5
Message 2 of 6
waynehelley
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 2023
Visual Studio 2022
Windows 10 Pro, 64-bit
Message 3 of 6
128848
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!

Message 4 of 6
128848
in reply to: 128848

some thing happend there.

 

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

if No = 2 then

Com....

Message 5 of 6
waynehelley
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 2023
Visual Studio 2022
Windows 10 Pro, 64-bit
Message 6 of 6
mrattray
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

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

Post to forums  

Autodesk Design & Make Report