iLogic: Enhanced iProperties Copied to Clipboard

This iLogic utility isolates a pre-selected component and activates the Orbit command, once the user exits the orbit command, a set of iProperties are shown, these iProperties are then copied to the clipboard. The code then zooms back out and sets the model to a “home” view.

This blog post’s iLogic code was the basis for the iProperty Tool-Tip with iLogic blog post. I came across my original code while looking for something else, so tidied it up and thought it would be worth sharing. The code is not well commented, as it was not initially going to be shared, but is is relatively simple. I do use quite a few “Inventor Commands” (see Brian Ekins post on this) to set views etc. Hopefully I’ll expand on this concept in an upcoming blog post.

The animated GIF below shows the code in action

Click me for High Res Version

Once the code is run, the values shown in the pop-up box and the status bar, are coped to the clipboard, in this instance:

Unofficial Inventor : Flare Base:1

Material = Titanium
Mass = 0.1344 kg
Volume = 29809 mm^3
Surface Area = 43185 mm^3

Here is the iLogic Code

'Code by @ClintBrown3D 'Originally posted at https://clintbrown.co.uk/ilogic:-enhanced-iproperties-copied-to-clipboard 
On Error GoTo ClintsErrorTrap

UnofficialInventor = ThisApplication.ActiveDocument
If UnofficialInventor.DocumentType <> kAssemblyDocumentObject Then
MessageBox.Show("This rule can only be run in an Assembly File >>>> Now Exiting Rule...", "Unofficial Inventor")
Return
End If

Call ThisApplication.CommandManager.ControlDefinitions.Item("AssemblyIsolateCmd").Execute

For Each oObject In ThisDoc.Document.SelectSet
Unofficial_Inventor = 1
Thing = oObject
If TypeOf oObject Is Face Then
Unofficial_Inventor = 0
End If
If Unofficial_Inventor = 1 Then

System.Threading.Thread.CurrentThread.Sleep(5)
ThisApplication.StatusBarText = "Unofficial Inventor  : "

ClintBrown3D = Thing.Name
Dim oVolume As Integer
Dim oSurfaceArea As Integer

ThisApplication.StatusBarText = "Unofficial Inventor:"
oMaterial = iProperties.MaterialOfComponent(ClintBrown3D)
oMassive = iProperties.MassOfComponent(ClintBrown3D)
oMass = Round(oMassive,4)
oVolume = iProperties.VolumeOfComponent(ClintBrown3D)
oSurfaceArea = iProperties.AreaOfComponent(ClintBrown3D)

System.Threading.Thread.CurrentThread.Sleep(5)
ThisApplication.StatusBarText = "Unofficial Inventor  : "

Call ThisApplication.CommandManager.ControlDefinitions.Item("AppIsometricViewCmd").Execute
Call ThisApplication.CommandManager.ControlDefinitions.Item("AppRotateViewCmd").Execute2(True)

ThisApplication.StatusBarText = "Unofficial Inventor  : " & _ 
ClintBrown3D & "  >>> Material = " & oMaterial & "  >>> Mass = " & oMass & " kg" & _ 
"  >>> Volume = " & oVolume & " mm^3" & "  >>> Surface Area = " & oSurfaceArea & " mm^3"

MessageBox.Show("Selected Part is:  " & ClintBrown3D & vbLf & vbLf & _
"Material  =  " & oMaterial & vbLf & _ 
"Mass    =  "& oMass & " kg" & vbLf & vbLf & _ 
"Surface Area    =   " & oSurfaceArea & " mm^2" & vbLf & _ 
"Volume    =   " & oVolume & " mm^3"& vbLf & vbLf & vbLf & _  
"", "Unofficial Inventor  :  " & ClintBrown3D)

Dim oClipboard As String = "Unofficial Inventor  : " & _ 
ClintBrown3D & vbLf & vbLf & "  >>> Material = " & oMaterial & vbLf & _ 
"  >>> Mass = " & oMass & " kg" & vbLf & _ 
"  >>> Volume = " & oVolume & " mm^3" & vbLf & "  >>> Surface Area = " & oSurfaceArea & " mm^3"
Clipboard.SetText(oClipboard)

End If
Next

Call ThisApplication.CommandManager.ControlDefinitions.Item("AssemblyIsolateUndoCmd").Execute
Call ThisApplication.CommandManager.ControlDefinitions.Item("AppPreviousViewCmd").Execute 'AppIsometricViewCmd        
Call ThisApplication.CommandManager.ControlDefinitions.Item("AppZoomAllCmd").Execute
Call ThisApplication.CommandManager.ControlDefinitions.Item("AppIsometricViewCmd").Execute '
Return 

ClintsErrorTrap :
MessageBox.Show("Someting went wrong, make sure you are in an Assembly and select a Component BEFORE running this rule :)", "@ClintBrown3D")

Notes:

This version of the code was tested with Inventor 2020. 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.