PYTHON API IN NG
What’s new in NG
6 / 2 / 2016 - Samuli Ahonen
Webinar link: [Link]
Command Registration
Localizing commands
Action Panel
Selection & Context
Pick / Snap
Command Registration
COMMAND REGISTRATION
More freedom adding menu items
Custom buttons in
ribbon tabs
context menus
quick menus
...
HOME RIBBON
cmduri = getApplicationPath() + '[Link]'
cmd = loadCommand('cmdHello', cmduri)
addMenuItem(“VcTabHome/VcRibbonShow”, "say hello", -1, “cmdHello")
HOME RIBBON
addMenuItem(“VcTabHome/My group”, "say hello", -1, “cmdHello")
DRAWING RIBBON
addMenuItem("VcTabDrawing/My group", "say hello", -1, "cmdHello")
PROGRAM RIBBON
addMenuItem("VcTabTeach/My group", "say hello", -1, "cmdHello")
MODELING RIBBON
addMenuItem("VcTabAuthor/My group", "say hello", -1, "cmdHello")
QUICK MENU
addMenuItem("VcConfigureQuickmenu", "say hello", -1, "cmdHello")
3D CONTEXT MENU
addMenuItem("VcConfigure3DContextMenu", "say hello", -1, "cmdHello")
addMenuItem("VcTeach3DContextMenu", "say hello", -1, "cmdHello")
addMenuItem("VcDrawing3DContextMenu", "say hello", -1, "cmdHello")
addMenuItem("VcAuthor3DContextMenu", "say hello", -1, "cmdHello")
COMPONENT GRAPH TREE CONTEXT MENU
addMenuItem("VcAuthorTreeViewContextMenu", "say hello", -1, "cmdHello")
addMenuItem("VcAuthorTreeViewBehaviorsContextMenu", "say hello", -1, "cmdHello")
addMenuItem("VcAuthorTreeViewPropertiesContextMenu", "say hello", -1, "cmdHello")
addMenuItem("VcAuthorTreeViewRobotFramesContextMenu", "say hello", -1, "cmdHello")
addMenuItem("VcAuthorTreeViewFeaturesContextMenu", "say hello", -1, "cmdHello")
addMenuItem("VcAuthorTreeViewNodesContextMenu", "say hello", -1, "cmdHello")
addMenuItem("VcAuthorTreeViewToolContextMenu", "say hello", -1, "cmdHello")
addMenuItem("VcAuthorTreeViewBasesContextMenu", "say hello", -1, "cmdHello")
GALLERY
addMenuItem(VC_MENU_MODELING_WIZARDS + "/My Category", "say hello", -1, "cmdHello")
DOCUMENTATION
Not yet fully documented
Use the config file as raw doc
C:\Program Files\Visual Components\Visual Components Essentials with Modeling Pack
4.0\[Link]
Find examples in the python command installation
folder
C:\Program Files\Visual Components\Visual Components Essentials with Modeling Pack
4.0\Python\VisualComponents\FeatureTreeTools
C:\Program Files\Visual Components\Visual Components Essentials with Modeling Pack
4.0\Python\VisualComponents\Wizards
Action Panel
USING ACTION PANEL WITH COMMANDS
Create properties to the
command
executeInActionPanel()
Properties flagged visible are
shown in the action panel
VISUAL COMPONENTS I [Link]
Localizing commands
LOCALIZE GUI
• Localize
• Command names (”Text”)
• Tooltips (”Tooltip”)
• GUI Icons (”Icon”)
LOCALIZE PROPERTIES
• Localize
• property names
• tooltips
• Localize before creating the property
Selection and Context
SELECTION
New Selection manager in python API
[Link]
Use this instead of
[Link]( ... )
[Link]
CONTEXT
Context controls
What can be selected in 3D
What panels are shown and where
VC_CONTEXT_CONFIGURE = “Configure“
VC_CONTEXT_DRAWING = "Drawing“
VC_CONTEXT_TEACH = "Teach“
VC_CONTEXT_AUTHOR = "Author"
CONTEXT
Python API
Access all available contexts
Set and get active context
Event for context change
Access active objects in context
CONTEXT
Set the active context
Access active objects
Snap
SNAP COMMAND
Interface same as in 2014 but with small additions
cmd. SnapOnBoundType
[Link]()
Improved control for highlighting
SNAP COMMAND
SnapOnBoundType
Cherry on the cake
RECOMPILING PYTHON COMMANDS
No need to recompile commands manually
Save the .py file and execute the command again
The command is automatically recompiled