iLogic write more easier

iLogic write more easier

dusan.naus.trz
Advisor Advisor
1,136 Views
5 Replies
Message 1 of 6

iLogic write more easier

dusan.naus.trz
Advisor
Advisor

Hello,
query by image. Is it possible to write more simply?

2019-11-01_20h03_20.png

 

Sub Main()
	dimension = "Part Number"
	Select Case Parameter("vyska")
		
	Case "varianta1"
		VELIKOST1
	Case "varianta2"
		VELIKOST2
	End Select
	
End Sub

	Public Sub VELIKOST1()
	'	dimension = "Part Number"
		iProperties.Value("Custom", dimension)=50
	End Sub


	Public Sub VELIKOST2()
	'	dimension = "Part Number"
		iProperties.Value("Custom", dimension)=100
	End Sub



'OK

'Sub Main()
	
'	Select Case Parameter("vyska")
		
'	Case "varianta1"
'		VELIKOST1
'	Case "varianta2"
'		VELIKOST2
'	End Select
	
'End Sub

'Public Sub VELIKOST1()
'	iProperties.Value("Custom", "Part Number")=50
'End Sub


'Public Sub VELIKOST2()
'	iProperties.Value("Custom", "Part Number")=100
'End Sub

 

0 Likes
Accepted solutions (1)
1,137 Views
5 Replies
Replies (5)
Message 2 of 6

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi @dusan.naus.trz 

 

Just as a hint, this question would probably have been better placed on the  Inventor Customization forum :
http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/bd-p/120

 

 

But to answer your question, here is an example.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

 

Class Thisrule
	
	Dim dimension As String =  "Part Number" 	
	
End Class

Sub Main()
	'trigger the rule when this changes
	oTrigger = vyska 
	
	Select Case Parameter("vyska")		
	Case "varianta1"
		VELIKOST1
	Case "varianta2"
		VELIKOST2
	End Select
	
End Sub

	Public Sub VELIKOST1()	
		iProperties.Value("Custom", dimension) = 50
	End Sub


	Public Sub VELIKOST2()
		iProperties.Value("Custom", dimension) = 100
	End Sub

 

 

EESignature

Message 3 of 6

dusan.naus.trz
Advisor
Advisor

Hello,
thank you very much. Curtis You're super.

0 Likes
Message 4 of 6

rhasell
Advisor
Advisor

Hi Curtis

 

What did I just learn here?

Can you place common declarations before "Sub Main", then you don't have to pass them through with each call?

eg:

call SubName (Variables)

 

Sub SubName (Variables)

 

Example, the variables in this are specific, I just showed this for syntax.

 

Annotation 2019-11-04 095940.png

 

If so, what are the rules and restrictions?

 

Thank you

 

Reg
2026.1
0 Likes
Message 5 of 6

Curtis_Waguespack
Consultant
Consultant

Hi @rhasell 

 

Yes, that's how I've used it.   

 

I've seen it used two ways:

 

Class ThisRule 
      'declarations here
End Class

Sub Main
      'code here
End Sub

 

Class ThisRule 
      'declarations here

  Sub Main
        'code here
  End Sub

End Class

 

Here is some info from the ilogic help that discusses the use of Class ThisRule.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

 

 

Excerpted from here:

https://knowledge.autodesk.com/support/inventor-products/learn-explore/caas/CloudHelp/cloudhelp/2014...

Additional statements

If you use Sub Main(), the rule follows standard VB.NET format for a class, except that the Class... and End Class statements are not visible, and the statements before Sub Main() are outside the class. Therefore, place all assignment statements inside a Sub, Function, or Property. You can include declaration statements for class member variables such as Private temp As Double = 4.5 outside of a subroutine or function.

You can add Sub, Function, Property, and Class definitions after Sub Main()... End Sub. Any Class you add is nested in the main rule Class for that rule and cannot be used from another rule. To add an independent Class or Module, explicitly declare the rule Class using the following:

Class ThisRule ' ...
Sub Main
End Sub
' ...
End Class

You can then add another Class or Module (or more than one) outside of this code. Class ThisRule becomes your main rule Class, and iLogic calls Sub Main (within it) to run your rule.

To include a Moduleor Class that is visible to multiple rules, put it in an external assembly (DLL). You can put more than one in the same DLL. You can also use AddVbRule to put them in a rule identified as "Straight VB code" within the Inventor document (). Or, use AddVbFile to put them in an external VB file.

When you develop advanced VB.NET code, use Visual Studio or Visual Basic Express rather than coding directly in a rule. You can then cut and paste relatively small snippets of code from Visual Studio into a rule. You can even paste in an entire dialog box Class (although resources are not easily supported). For larger units of code, or where required, create an assembly and use it as an external DLL from a rule.

You can store objects that are instances of a user-defined Class using the iLogic rule Shared Variable functions. To store these objects, serialize the Class, or it must be derived from MarshalByRefObject.

EESignature

Message 6 of 6

rhasell
Advisor
Advisor

Thank you.

I will play with it and see if I can use it to improve my limited coding skills.

 

Reg
2026.1
0 Likes