Magic 8 Ball in Inventor With iLogic

Magic 8 ball Autodesk Inventor iLogic

I built a magic 8 ball using iLogic, utilising the random number generator to create a random answer. You are probably wondering why… Well the answer is, why not! I got the idea while stuck in traffic, and it was really quick and easy to knock together, so I thought I would share it here.

The animated GIF below shows the magic 8 ball in action:

magic 8 ball

The iLogic code works by generating a random number between 0 and 19, which is mapped to one of the potential answers. This answer is then written to a user parameter called “answer”. The user parameter is used in a sketch, which is extruded to form the answer on the model.

@ClintBrown3D Autodesk Inventor magic 8 ball

I put this together in Inventor 2020, and have shared the model below.

Download the Inventor 2020 file here:

Here is the iLogic code:

'iLogic code by @ClintBrown3D, originally posted at https://clintbrown.co.uk/magic-8-ball-in-inventor-with-ilogic
'It's not pretty, but it works :)

'Generate a Random Number 0-19 and assign an answer to each value
RANDOMISER = Round(Rnd * 19)
If RANDOMISER = 0 Then 
RANDOMISER = "Reply hazy, Try again"
Else If RANDOMISER = 1 Then
RANDOMISER = "It Is certain" 
Else If RANDOMISER = 2 Then
RANDOMISER = "It Is decidedly so" 
Else If RANDOMISER = 3 Then
RANDOMISER = "Without a doubt"
Else If RANDOMISER = 4 Then
RANDOMISER = "Yes - definitely"
Else If RANDOMISER = 5 Then
RANDOMISER = "You may rely On it"
Else If RANDOMISER = 6 Then
RANDOMISER = "As I see it, yes"
Else If RANDOMISER = 7 Then
RANDOMISER = "Most likely"
Else If RANDOMISER = 8 Then
RANDOMISER = "Outlook good"
Else If RANDOMISER = 9 Then
RANDOMISER = "Yes"
Else If RANDOMISER = 10 Then
RANDOMISER = "Signs Point To yes"
Else If RANDOMISER = 11 Then
RANDOMISER = "Reply hazy, Try again"
Else If RANDOMISER = 12 Then
RANDOMISER = "Ask again later"
Else If RANDOMISER = 13 Then
RANDOMISER = "Cannot predict Now"
Else If RANDOMISER = 14 Then
RANDOMISER = "Concentrate And ask again"
Else If RANDOMISER = 15 Then
RANDOMISER = "Don't count on it"
Else If RANDOMISER = 16 Then
RANDOMISER = "My reply Is no"
Else If RANDOMISER = 17 Then
RANDOMISER = "My sources say no"
Else If RANDOMISER = 18 Then
RANDOMISER= "Outlook Not so good"
Else If RANDOMISER = 19 Then
RANDOMISER = "Very doubtful"
End If

'Change the Camera View, set the answer
'update the model and move the camera to reveal the answer
InventorVb.SetViewCamera(ViewCameraOption.FitExtents, New Double() {12.630962504963469, 12.255962504963456, 12.255962504963469}, New Double() {0.375, 0, 0}, New Double() {-0.40824829046386291, 0.81649658092772626, -0.40824829046386318}, New Double() {10.965266851243031, 12.967785754450382})
Answer = UCase(RANDOMISER)
iLogicVb.UpdateWhenDone = True
InventorVb.SetViewCamera(ViewCameraOption.FitExtents, New Double() {-15.297630656897097, -0.63590545337838689, 3.9579955217014948}, New Double() {0.57036705617065286, -0.060368809609580062, 1.0564509604125576}, New Double() {-0.013773171507537903, 0.99249061932162, 0.12154287434980059}, New Double() {8.3378292368836426, 9.8604502239531531})
ThisApplication.StatusBarText = "Magic 8 Ball says "& "''" & UCase(RANDOMISER) &"''                                @ClintBrown3D"