Hello, thanks for coming on over,

The Autodesk Northern Europe Manufacturing Blog has now moved to a new home. Please come over and join us at.....


This blog will not be updated.

Thursday, 20 January 2011

Adding Social Network links into Autodesk Inventor

Since the release of Autodesk Factory Design Suite which includes tools directly inside of the Autodesk Inventor part of the suite to launch your favourite social networking sites, I've been asked many times if we can have these in the 'standalone' Autodesk Inventor.

Never one to shy away from such a challenge I decided to see what could be done to answer the requests. Some VBA and image editing later, this is what I managed to come up with:

It's really quick and easy to do, and to save you some time and effort I've put the instructions, code and files here for you to download and use.

1) Download the icons from the link below:

http://www.mfg-area.com/social_link_icons.zip

2) Unzip the contents of social link icons to C:\Users\Public\Documents\Autodesk\Inventor 2011

3) Launch Autodesk Inventor (no need to start a new document)
4) Go to the VBA editor which is on the Tools ribbon
5) Open or create a module within Default.ivb
6) Copy and paste the following code into the top of the module:

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal _
lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

7) Copy the rest of the code from below and paste it after the first piece of code you pasted:

Public Sub Autodesk()
Input_URL = "http://www.autodesk.com"
ShellExecute 0&, vbNullString, Input_URL, vbNullString, _
vbNullString, SW_SHOWNORMAL
End Sub

Public Sub Blog()
Input_URL = "http://autodeskmfg.blogspot.com"
ShellExecute 0&, vbNullString, Input_URL, vbNullString, _
vbNullString, SW_SHOWNORMAL
End Sub

Public Sub Flickr()
Input_URL = "http://www.flickr.com/photos/autodeskmfggallery/"
ShellExecute 0&, vbNullString, Input_URL, vbNullString, _
vbNullString, SW_SHOWNORMAL
End Sub

Public Sub YouTube()
Input_URL = "http://www.youtube.com/user/manufacturingarea"
ShellExecute 0&, vbNullString, Input_URL, vbNullString, _
vbNullString, SW_SHOWNORMAL
End Sub

Public Sub Facebook()
Input_URL = "http://www.facebook.com/#!/group.php?gid=144941045545462"
ShellExecute 0&, vbNullString, Input_URL, vbNullString, _
vbNullString, SW_SHOWNORMAL
End Sub

Public Sub Twitter()
Input_URL = "http://twitter.com/autodeskmfg"
ShellExecute 0&, vbNullString, Input_URL, vbNullString, _
vbNullString, SW_SHOWNORMAL
End Sub

7) In the zero doc environment right mouse click over the Get Started ribbon and select Customise User Commands…
(you don't have to add the tools to the Get Started panel, you could add them to any ribbon panel you want using the same method)

8) From the drop down list at the top select macros where each of the macros we pasted in to the VBA editor will be listed.

9) Use the Add>> button to move each of the macros from the left column, to the right column.

Re-start Autodesk Inventor and when it re-starts you should see your links on the Get Started ribbon for you to use.

Clicking on the link will launch your default browser so it doesn't matter if you use IE, FireFox, Chrome etc.

The macro code is very simple and you can easily change it for different web sites if you want, here’s an example:

Public Sub Autodesk()
Input_URL = "http://www.autodesk.com"
ShellExecute 0&, vbNullString, Input_URL, vbNullString, _
vbNullString, SW_SHOWNORMAL
End Sub

The name of the Sub is the name that is shown on the ribbon, so in the example above Autodesk() = Autodesk on the ribbon text.

And then you just need to edit the URL to go wherever you want it to go.

If you want to change the icons you will need to .bmp files – one 32 x32 pixels and one 16 x 16 pixels.

Save them in C:\Users\Public\Documents\Autodesk\Inventor 2011 (or wherever the .ivb file you have used is) and give them a name of:

• modulename.macroname.Large.bmp - for the 32 x 32 image
• modulename.macroname.Small.bmp - for the 16 x 16 image

For example, I have called my icon images module1.autodesk.Large.bmp, module1.youtube.Large.bmp, module1.facebook.Large.bmp etc

You will have to have both small and large images in the folder.

Enjoy!