Using Random function in iLogic what is the Code

Using Random function in iLogic what is the Code

Anonymous
Not applicable
1,584 Views
2 Replies
Message 1 of 3

Using Random function in iLogic what is the Code

Anonymous
Not applicable

I know you can use an operator in the parameters as "random()" to produce a random number >0 and <1 as a decimal, but what is the code for doing this in Inventor iLogic? Random just isn't an expression when it comes to iLogic it just says it's a type. Any Insight ?

I could use it in my parameter but once it is in a formula then "random" stays one value.

Accepted solutions (1)
1,585 Views
2 Replies
Replies (2)
Message 2 of 3

bradeneuropeArthur
Mentor
Mentor
Accepted solution

With this piece of code:

 

Sub Main()

    'Initialize the random number generator
    '=> Randomize : add this before you call the Rnd function to obtain completely random values
    Randomize
    
    'Random whole number between 1 and 50 :
    random_number = Int(50 * Rnd) + 1
    
    MsgBox (random_number)
    
End Sub

Regards,

Autodesk Software: Inventor Professional 2018 | Vault Professional 2018 | Autocad Mechanical 2018
Programming Skills: Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
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 !

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

Message 3 of 3

vladimir_michl
Advisor
Advisor

See also an example of using random dimensional parameters and appearances to drive "dynamic" parts and assemblies in Inventor:

https://www.cadforum.cz/cadforum_en/random-shape-and-appearance-of-an-inventor-part-or-assembly-tip1...

 

 

Vladimir Michl, www.cadstudio.cz  www.cadforum.cz