Loop "internal" parameters in a rule

Loop "internal" parameters in a rule

Wowbagger2
Enthusiast Enthusiast
387 Views
2 Replies
Message 1 of 3

Loop "internal" parameters in a rule

Wowbagger2
Enthusiast
Enthusiast

Hi,

 

I'm trying to create a For loop with an integer of 1 To 4 using "internal" parameters ("Dim Inlet1 As Double" maybe there's another name for parameters declared inside a rule?). The rule works if I use user parameters but I'd rather not as these parameters are only gonna be used for counting a number of features and adding it all together to an iproperty.

 

It looks like this:

 

Dim Inlet1 As Double
Dim Inlet2 As Double
Dim Inlet3 As Double
Dim Inlet4 As Double


For i As Integer = 1 To 4
	If Not Parameter("Inlet" & i & "Direction") = "Ingen vald" Then
		Inlet & i = Parameter("Inlet" & i & "Pattern_Num")
	Else
		Inlet & i = 0
	End If
Next	



iProperties.Value("Custom", "Test") = Inlet1 + Inlet2 + Inlet3 + Inlet4

 

 

Best,

Fredrik

0 Likes
Accepted solutions (1)
388 Views
2 Replies
Replies (2)
Message 2 of 3

MechMachineMan
Advisor
Advisor
Accepted solution

They are called variables in programming. But you cannot assign them dynamically like you are trying to do with "inlet & i". You must hardcode them or change your algorithm to accommodate this.

 

Something such as this should work:

 

Dim Sum As Double

For i As Integer = 1 To 4
	If Not Parameter("Inlet" & i & "Direction") = "Ingen vald" Then
		SUM = SUM + Parameter("Inlet" & i & "Pattern_Num")
	End If
Next	

iProperties.Value("Custom", "Test") = SUM

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 3 of 3

Wowbagger2
Enthusiast
Enthusiast

Thank you! This worked great!

 

One thing, I don't think the "Sum" needs to be declared as a Double or at all but could be wrong.

 

 

Thanks for the help!

 

/Fredrik

0 Likes