Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iLogic Code Case or Sub Statements

1 REPLY 1
Reply
Message 1 of 2
tim.mulder
298 Views, 1 Reply

iLogic Code Case or Sub Statements

Hello All,

 

Need some help to get off on the right foot.

I am writing some code that requires me to run PART of the code only if a certain value is present.

 

Example

 

If Parameter("Test") < 20 Then

   BLAH BLAH BLAH

   BLAH BLAH BLAH

   BLAH BLAH BLAH

End If

 

The BLAH BLAH BLAH bit only needs to run if the Statement at the start is true i.e Parameter("Test") < 20

If it is not I want the code to skip it.

 

I tried to seperate the code into 2 rules

 

Example

 

If Parameter("Test") < 20 Then

   iLogicVb.RunRule("Whatever")

End If

 

But that doesn't seem to work unless I'm missing something as the edited parameters are updating anyway.

 

What keywords/Statements can I use to achieve this? Case....Sub?

 

Many Thanks

 

Tim

1 REPLY 1
Message 2 of 2
MegaJerk
in reply to: tim.mulder

What you have written should be working unless the parameter in question is not located where the code that is running it happens to reside. 

Try the code below with the text replaced with your parameter name. 

If Parameter("ParameterNameHere") < 20 Then 
	MessageBox.Show("True") 
	Else 
	MessageBox.Show("False")
End If 

 
Or if the parameter is local along with the rule, you could write it as : 

If ParameterNameHere < 20 Then 
	MessageBox.Show("True") 
	Else
	MessageBox.Show("False") 
End If 

 
Perhaps simply seeing which 'state' your parameter is in (using those message boxes as a poor man's debugger) will help you see a problem with the math or something else. If you require further help, please post your entire code block or even a zip file of the files in question. 




If my solution worked or helped you out, please don't forget to hit the kudos button 🙂
iLogicCode Injector: goo.gl/uTT1IB

GitHub

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

Post to forums  

Autodesk Design & Make Report