Heads or Tails in Inventor with iLogic

autodesk inventor ilogic heads or tails coin

This is admittedly a bit of a random idea! This blog post shows how to flip a coin using iLogic in Inventor.

UPDATE: There is a new version that uses a 3D Coin in an Inventor .IPT; available here.

The idea came from my previous blog post, looking at generating random numbers to create colours. Initially I thought it would be interesting to create a form and to use an enabling parameter to swap out an image, but I decided that it would be better to fire up a website containing the image, it also made this simpler to share, as it is only a few short lines of code.

Below is an animated GIF showing the code in action:

Coin Toss.gif

Here is the iLogic code:

'iLogic code by @ClintBrown3D, originally posted at https://clintbrown.co.uk/heads-or-tails
'Generate a random number (In this case 1 or 0)

HEADSorTAILS = Round(Rnd * 1)
'If the result is 0 then the answer is Heads, if the result is 1 , then the answer is tails
If HEADSorTAILS = 0 Then : GoTo HEADS: Else : GoTo TAILS: End If



Comments are closed.

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: