iLogic code for Range between numbers

iLogic code for Range between numbers

Anonymous
Not applicable
1,481 Views
10 Replies
Message 1 of 11

iLogic code for Range between numbers

Anonymous
Not applicable

HI, I have most up to date Inventor Software. 

 

I have always used greater than or less than symbols in my iLogic code but now I want to create a range and I can not figure out how to get it to work. 

 

I VERY simply just want to specify a range of simple whole numbers. For example..

 

If 14 < Valve_Width < 26 Then

(Valves with widths between the ranges of 15 and 25 are configured differently than those 14 or less or 26 and up)

any help is appreciated!

Thanks

Sandro

0 Likes
1,482 Views
10 Replies
Replies (10)
Message 2 of 11

bradeneuropeArthur
Mentor
Mentor
Public Sub range()

Dim a As Integer
a = 14
Dim b As Integer
b = 24

If b > 14 And b < 26 Then
MsgBox "yes"
End If
End Sub

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 11

Anonymous
Not applicable

wow that seems more complicated than it should be. sounds like something for the "Idea" page.

I will give this a try however it would be incomplete for me. I am going to have another range afterwards from 26 to 36 and then more ranges after that. How would you add that in there?

0 Likes
Message 4 of 11

bradeneuropeArthur
Mentor
Mentor

give me the ranges and I will define them.

it is not complicated....

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 5 of 11

Anonymous
Not applicable

sorry i have no experience with "Dim" or "Sub". To my knowledge that is VBA stuff that I haven't dove into yet.

 

I am currently working out the ranges. 

 

I actually just figured out that I can write my code like this and it seems to work how i want...

 

If Valve_Width >14 And Valve_Width <26 Then

 

Is there a reason you wouldnt just do it this way? I feel the "And" should be unnecessary but whatever works. 

0 Likes
Message 6 of 11

bradeneuropeArthur
Mentor
Mentor

 

Public Sub main()


Dim  Valve_Width As Integer
Valve_Width = 24

' 14 to 26
If  Valve_Width > 14 And  Valve_Width < 26 Then
MsgBox "yes1"
End If

' 26 to 36
If  Valve_Width > 26 And  Valve_Width < 36 Then
MsgBox "yes2"
End If

' 36 to 46
If  Valve_Width > 36 And  Valve_Width < 66 Then
MsgBox "yes3"
End If

' ETC ETC ETC ETC
' NOT COMPLICATED
' LOGIC
End Sub

 

 

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 7 of 11

bradeneuropeArthur
Mentor
Mentor

it is definitely better to start using "Dim"

Also for Ilogic!!!

Sub Main for Ilogic!!!

This is the way to do it, the best way and gives less errors.

 

Regards,

 

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 8 of 11

Anonymous
Not applicable

Many of the times I come on here requesting help I feel as though I am met with sarcasm and condescension. Its unnecessary, rude, and pretty pathetic. It's sad if Inventor experience is what brings you ego. Having said that, I may have misinterpreted this time so ignore that. If that is not the case right now then I apologize and I thank you very much for the help, I appreciate it. I will try learning about this Dim code.

0 Likes
Message 9 of 11

bradeneuropeArthur
Mentor
Mentor

What went wrong than?

Good to hear that you are start learning things here!

Good luck!

Regards,

Could you mark this as solved for administrative reasons?

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 10 of 11

philip1009
Advisor
Advisor

To put it simply, it is VBA stuff since iLogic is based on it, it's just not necessary to use Dim to make a variable every time, and it's also not necessary to use Sub Main if you aren't going to use additional sub-routines or functions in that rule.

 

It is recommended to learn VBA in your spare time, it will make coding the logic much easier, then you only need to learn the slight differences between iLogic and VBA, learn about the included iLogic Snippets, and then learning to use the Inventor API to master the program.  Here's a playlist of YT videos to teach you all the basics of VBA:

https://www.youtube.com/watch?v=mM3zB3QWuv8&list=PLC601DEA22187BBF1&index=1

 

What's your goal with the range?  Are you just checking to see if a variable is in that range, or do you want to check every number in that range, or do you want to check a list of Variables to see if each of them are in that range?  If there's always a list to check, then using a For loop might be faster than a whole bunch of If this Then that statements.

0 Likes
Message 11 of 11

bradeneuropeArthur
Mentor
Mentor

With "Dim" you are declaring variables and object etc.

It is definitely better to get used to it and declare this way. 

I have seen many errors because of not taking the time to program this correctly.

This has secondarily to do with the option in ilogic "Using Straight VBA Code".

But you are right for illogic and also Vba it is not always necessary, and has to do with the settings.

But still I prefer to learn people to use "Dim" in illogic too, and to use "Dim and Set" in VBA.

For VB.net the "Set" is also not recommended..

Regards,

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature