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

InventorMenuIcon

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

Animate Animate

AddRule AddRule

AddInManager AddInManager

AddAssembly AddAssembly

Apply Apply

ApplicationOptions ApplicationOptions

Appearance Appearance

AnimationTimeline AnimationTimeline

Back Back

AssignMaterials AssignMaterials

Assembly Assembly

AppManager AppManager

Bold Bold

BillOfMaterials BillOfMaterials

Bearing Bearing

BearingLoad BearingLoad

ChangeCategory ChangeCategory

Chamfer Chamfer

CaptureCamera CaptureCamera

Bullets Bullets

Coil Coil

CheckOut CheckOut

CheckIn CheckIn

ChangeState ChangeState

Copy Copy

Concentric Concentric

Comment Comment

Combine Combine

Cylinder Cylinder

Cut Cut

Crop Crop

CreateComponent CreateComponent

DeleteFace DeleteFace

Decal Decal

DataExchange DataExchange

DataCards DataCards

DocumentSettings DocumentSettings

DirectEdit DirectEdit

DerivedComponent DerivedComponent

Delete Delete

Emboss Emboss

DWG DWG

DWF DWF

Drawing Drawing

Extrude Extrude

Export Export

EventTriggers EventTriggers

Equal Equal

Fix Fix

Finish Finish

Find Find

FaceDraft FaceDraft

Guide Guide

GravityLoad GravityLoad

GetRevision GetRevision

Gate Gate

ImportFile ImportFile

Image Image

Home Home

Hole Hole

iProperties iProperties

InventorIdeas InventorIdeas

InsertView InsertView

Info Info

LocalLights LocalLights

LoadFull LoadFull

iTrigger iTrigger

Italic Italic

Macros Macros

LogOut LogOut

LogIn LogIn

Loft Loft

MigrateSettings MigrateSettings

Measure Measure

Material Material

Mark Mark

NewSheet NewSheet

Move Move

MomentLoad MomentLoad

Mirror Mirror

Open Open

OpenVault OpenVault

Next Next

NewWindow NewWindow

Parameters Parameters

Pan Pan

Orbit Orbit

Options Options

PDF3D PDF3D

Part Part

PartsList PartsList

Partition Partition

Presentation Presentation

Place Place

PlaceVault PlaceVault

PlaceCC PlaceCC

Rebuild Rebuild

Purge Purge

Print Print

Previous Previous

Revolve Revolve

RevisionTable RevisionTable

RenderImage RenderImage

Redo Redo

Scale Scale

Save Save

Rotate Rotate

Rib Rib

Shell Shell

SheetFormat SheetFormat

SharedViews SharedViews

Select Select

STL STL

Sphere Sphere

Simplify Simplify

ShowDetails ShowDetails

Table Table

Symmetric Symmetric

Sweep Sweep

SupplierContentCenter SupplierContentCenter

Tick Tick

Thread Thread

ThickenOffset ThickenOffset

Text Text

Underline Underline

Trim Trim

Trace Trace

Torus Torus

UpdateProperties UpdateProperties

UnwrapFaces UnwrapFaces

Undo Undo

UndoCheckOut UndoCheckOut

coolOrange coolOrange

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"
    }
}