Add-InventorMenuItem
Add a menu item to an Inventor menu with an Action that is invoked when the menu item is clicked.
Syntax
Add-InventorMenuItem -Name <String> [-Tab <string>] [-Panel <string>] -Action <Scriptblock | String> -Icon <InventorMenuIcon> [<CommonParameters>]
Parameters
Type |
Name |
Description |
Default Value |
Optional |
|---|---|---|---|---|
String |
Name |
Display name of the menu item displayed in the Inventor tab |
no |
|
String |
Tab |
Display name of the tab in which the button will appear |
coolOrange |
yes |
String |
Panel |
Display name of the panel in which the button will appear |
General |
yes |
Scriptblock / String |
Action |
Script block or function name that is executed when the menu item is clicked. |
no |
|
Icon |
Image that will appear in the item displayed in the Inventor tab |
coolOrange |
yes |
Warning: Name must be unique for the same tab and panel
When multiple menu items are registered, the Name parameter must be unique for each menu item that has the same tab and panel name.
InventorMenuIcon
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Return type
empty
Remarks
The cmdlet can be used to extend the Inventor user interface with a new menu item which is displayed in a coolOrange Tab.
The coolOrange Tab and its menu items will be displayed in the following Inventor Ribbons:
Part
Assembly
Drawing
Presentations
The script block or function name passed to the Action parameter is invoked when the menu item is clicked.
The PowerShell variables provided by Open-VaultConnection and
a $inventor variable are available during the execution of the registered action to allow access to the Vault and Inventor APIs.
Menu items created by the cmdlet are not permanent, when Inventor is restarted the menus are reset to their original state.
Calling the cmdlet with the same Name parameter after a menu item has already been added, will update the Action for the menu item.
Calling the cmdlet with a tab or panel name that exists in Inventor by default (i.e. “Vault” and “Control”) will correctly place the button in the specified tab and panel.
Note
The cmdlet can only be used when running directly in an Inventor process.
The cmdlet is executed only after a successful login to Vault, which can be done via the Inventor Vault Add-in.
Examples
Adds a menu item to add a virtual compontent with an overridden Quantity to the structured BOM:
Add-InventorMenuItem -Name "Add oil to BOM" -Icon coolOrange -Action {
$compName = 'Oil'
$document = $inventor.ActiveDocument
$occur = $document.ComponentDefinition.Occurrences
try{
$virtualComponent = $occur.AddVirtual($compName, $inventor.TransientGeometry.CreateMatrix())
}catch {
Write-Host "Could not add virtual component!"
return
}
$BOM = $document.ComponentDefinition.BOM
if (-not $BOM.StructuredViewEnabled) {
$BOM.StructuredViewEnabled = $True
}
$structBomView = $BOM.BOMViews | Where-Object {$_.ViewType -eq [Inventor.BOMViewTypeEnum]::kStructuredBOMViewType } | Select-Object -First 1
$bomCom = $structBomView.BOMRows | Where-Object {($_.ComponentDefinitions | Select-Object -First 1).DisplayName -eq $compName}
$bomCom.TotalQuantity = '10'
}
Adds a menu item to the Change Order tab and Document panel to create a new Vault Change Order with current document attached:
Add-InventorMenuItem -Name "Create changeorder" -Tab "Change Order" -Panel "Document" -Action {
$docName = $inventor.ActiveDocument.DisplayName
$file = Get-VaultFile -Properties @{'Name' = $docName}
if($null -eq $file){
Write-Host "Could not find vaulted file for current document: '$docName'"
return
}
$coNumScheme = $vault.NumberingService.GetNumberingSchemes('CO', [Autodesk.Connectivity.WebServices.NumSchmType]::ApplicationDefault) | Select-Object -First 1
$coNumber = $vault.ChangeOrderService.GetChangeOrderNumberBySchemeId($coNumScheme.SchmID)
$co = Add-VaultChangeOrder -Number $coNumber
Write-Host "Created ChangeOrder with number '$coNumber'"
if($null -eq (Update-VaultChangeOrder -Number $co._Number -AddAttachments @($file._FullPath))){
Write-Host "Attaching file to changeorder failed"
}
}
Animate
AddRule
AddInManager
AddAssembly
Apply
ApplicationOptions
Appearance
AnimationTimeline
Back
AssignMaterials
Assembly
AppManager
Bold
BillOfMaterials
Bearing
BearingLoad
ChangeCategory
Chamfer
CaptureCamera
Bullets
Coil
CheckOut
CheckIn
ChangeState
Copy
Concentric
Comment
Combine
Cylinder
Cut
Crop
CreateComponent
DeleteFace
Decal
DataExchange
DataCards
DocumentSettings
DirectEdit
DerivedComponent
Delete
Emboss
DWG
DWF
Drawing
Extrude
Export
EventTriggers
Equal
Fix
Finish
Find
FaceDraft
Guide
GravityLoad
GetRevision
Gate
ImportFile
Image
Home
Hole
iProperties
InventorIdeas
InsertView
Info
LocalLights
LoadFull
iTrigger
Italic
Macros
LogOut
LogIn
Loft
MigrateSettings
Measure
Material
Mark
NewSheet
Move
MomentLoad
Mirror
Open
OpenVault
Next
NewWindow
Parameters
Pan
Orbit
Options
PDF3D
Part
PartsList
Partition
Presentation
Place
PlaceVault
PlaceCC
Rebuild
Purge
Print
Previous
Revolve
RevisionTable
RenderImage
Redo
Scale
Save
Rotate
Rib
Shell
SheetFormat
SharedViews
Select
STL
Sphere
Simplify
ShowDetails
Table
Symmetric
Sweep
SupplierContentCenter
Tick
Thread
ThickenOffset
Text
Underline
Trim
Trace
Torus
UpdateProperties
UnwrapFaces
Undo
UndoCheckOut
coolOrange