iLogic Unit Converter

@ClintBrown3D Autodesk Inventor iLogic Unit Converter

This blog post a bit of a throwback to a few years ago, it’s based on a very old unit converter that was hosted on Autodesk’s website.

The idea of this blog post, is an iLogic rule to fire up the unit converter inside of Inventor, as shown in the animation below.

@ClintBrown3D Unofficial Autodesk Inventor iLogic web view
Click me for higher resolution version

To make this display in Inventor, I am using the “web browser” sample from the Inventor API. My iLogic code displays a simple HTML website that I knocked together in notepad. The custom html site simply hosts an iFrame of the original unit converter which is now hosted on the internet archive (wayback machine), it then scrolls and positions just the parts of the site that I want to display in the window. The one minor issue, is that because the page is now hosted on the internet archive, it has a small delay in loading.

To set this up is very easy, just follow the instructions below:

Instructions:

  • Download the HTML File here
  • Save the HTML file to C:\Temp
  • Create an new iLogic Rule and paste in the code below
  • Ensure that the “oURL” path in the code matches the download location of the html file (the code is defaulted to C:\Temp)
  • You may need to resize the window the first time it is run, it will remember it’s size for the next time you run the rule.

Here is the iLogic Code:

'iLogic Rule by @ClintBrown3D
'Originally posted here: https://clintbrown.co.uk/unitconverter
'Download the HTML File form here: https://drive.google.com/file/d/1EnpHkGJEPjEyKwRO__Z-Ab9VK3EJQc4y/view
'Save the HTML file to C:\Temp

oURL = "file:///C:/Temp/Unofficial Inventor.html" 

' Create a WebBrowserDialog (Show the Unit Converter)
	Dim oWebBrowserDialog As WebBrowserDialog
	oWebBrowserDialog = ThisApplication.WebBrowserDialogs.Add(oURL)
	oWebBrowserDialog.WindowState = kNormalWindow
	oWebBrowserDialog.WindowState = kSmallWindow
	oWebBrowserDialog.Navigate(oURL)

Here is a screenshot of what the old Autodesk website used to look like.

40clintbrown3d-autodesk-inventor-03

Additional help:

You may get this error (Object reference not set to an instance of an object) initially, don’t worry it’s easy to fix.

Object Reference not set to an instance of an object

This error is due to Windows security settings. Simply unblock the downloaded HTML file by right clicking on it and then ticking “Unblock” as shown below. The iLogic code should now run without any issues.

@ClintBrown3D Autodesk Inventor 12

 

Notes:

This version of the code was briefly tested in Inventor 2020 and 2019. If the converter does not display correctly on your system, you may need to tweak the HTML file.

Please note that I cannot offer any additional support, this blog post is offered as-is, and is aimed at the more advanced user.

As always, please test all iLogic code extensively on non-production files. Do not use any code in a production environment until YOU have thoroughly tested it and have verified that it works as expected. Always back up any data before running any experimental code. You are ultimately responsible for any iLogic code that you run, so make sure you test it thoroughly!