Keyboard shortcuts for adding nodes to ICE trees

A customer recently asked me how to write a command that adds a node to an ICE tree. His ultimate goal was to assign a keyboard shortcut to the command, so that he could quickly insert commonly-used nodes.

Unlike menus, which can easily get the current ICE tree view, commands have to do a bit more work. A command has to find the ICE tree view in the active desktop layout (and there’s no way the command can figure which view is the “active” view).

So, here’s a Python snippet that finds an ICE Tree view and adds a Get Data node. If you make this into a command, then you can assign a shortcut key to it. I look first for a docked ICE Tree view, and if I don’t find that, I look for a floating view.

si = Application
views = si.Desktop.ActiveLayout.Views

# Find docked ICE Tree views
oICETreeViews = views.Filter( "View Manager" )(0).Views.Filter( "ICE Tree" )

# If no docked ICE Tree view, then look for floating
if oICETreeViews.Count == 0:
    oICETreeViews = views.Filter( "ICE Tree" )

if oICETreeViews.Count > 0:
    # Get the ICE tree that is loaded into the view
    sICETree = oICETreeViews(0).GetAttributeValue( "container" )

    si.AddICENode("$XSI_DSPRESETS\\ICENodes\\GetDataNode.Preset", sICETree )

2 thoughts on “Keyboard shortcuts for adding nodes to ICE trees

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s