-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathShortcutItPy.py
More file actions
57 lines (50 loc) · 1.85 KB
/
ShortcutItPy.py
File metadata and controls
57 lines (50 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#Author-lf
#Description-Add a bunch of commands to a toolbar panel in Tools so they can be shortcut
import adsk.core, adsk.fusion, adsk.cam, traceback
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
ws = ui.workspaces.itemById('FusionSolidEnvironment')
panels = ws.toolbarPanels
myPanel = panels.itemById('ShortcutItPanel')
if myPanel:
myPanel.deleteMe()
myPanel = panels.add('ShortcutItPanel', 'Shortcut It', '')
needCmdDefs = (
('IsolateCmd', './isolate'),
('UnisolateCmd', './unisolate'),
('UnisolateAllCmd', './unisolate'),
('FindInBrowser', './findinbrowser'),
('FindInWindow', './findinbrowser'),
('SetOrbitCenterCommand', None),
('ResetOrbitCenterCommand', None),
('SoftDeleteCommand', None),
)
for cmdName, resDir in needCmdDefs:
cmd = ui.commandDefinitions.itemById(cmdName)
if not cmd:
ui.messageBox('Cannot find {}'.format(cmdName))
continue
if resDir is not None:
cmd.resourceFolder = resDir
cmd.controlDefinition.isVisible = True
cmd.controlDefinition.isEnabled = True
myPanel.controls.addCommand(cmd)
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
def stop(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
ws = ui.workspaces.itemById('FusionSolidEnvironment')
panels = ws.toolbarPanels
myPanel = panels.itemById('ShortcutItPanel')
if myPanel:
myPanel.deleteMe()
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))