Inventor General Discussion

Inventor General Discussion

Reply
Active Contributor
128848
Posts: 31
Registered: ‎01-16-2013
Message 1 of 6 (696 Views)

iLogic If then formulas

696 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:

Mentor
waynehelley
Posts: 151
Registered: ‎09-10-2012
Message 2 of 6 (684 Views)

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 2013
Windows 7 Enterprise, 64-bit
Active Contributor
128848
Posts: 31
Registered: ‎01-16-2013
Message 3 of 6 (667 Views)

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!

Active Contributor
128848
Posts: 31
Registered: ‎01-16-2013
Message 4 of 6 (666 Views)

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....

Mentor
waynehelley
Posts: 151
Registered: ‎09-10-2012
Message 5 of 6 (659 Views)

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 2013
Windows 7 Enterprise, 64-bit
*Expert Elite*
mrattray
Posts: 2,538
Registered: ‎09-13-2011
Message 6 of 6 (647 Views)

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

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.