-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathFRCTools.py
More file actions
63 lines (48 loc) · 2.64 KB
/
FRCTools.py
File metadata and controls
63 lines (48 loc) · 2.64 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
58
59
60
61
62
63
# Assuming you have not changed the general structure of the template no modification is needed in this file.
import adsk.core
from . import commands
from .lib import fusionAddInUtils as futil
from . import config
app = adsk.core.Application.get()
ui = app.userInterface
def run(context):
try:
# ******** Add a button into the UI so the user can run the command. ********
# Get the target workspace the button will be created in.
workspace = ui.workspaces.itemById( config.WORKSPACE_ID )
# Get the panel the FRCTools dropdown will be created in.
solid_panel = workspace.toolbarPanels.itemById( config.SOLID_CREATE_ID )
sketch_create_panel = workspace.toolbarPanels.itemById( config.SKETCH_CREATE_ID )
sketch_modify_panel = workspace.toolbarPanels.itemById( config.SKETCH_MODIFY_ID )
# Create the the FRCTool submenu in the solid-create, sketch-create, and sketch-modify panels.
solid_panel.controls.addDropDown( "FRCTools", "", config.FRC_TOOLS_DROPDOWN_ID )
sketch_create_panel.controls.addDropDown( "FRCTools", "", config.FRC_TOOLS_DROPDOWN_ID )
sketch_modify_panel.controls.addDropDown( "FRCTools", "", config.FRC_TOOLS_DROPDOWN_ID )
# This will run the start function in each of your commands as defined in commands/__init__.py
commands.start()
except:
futil.handle_error('run', True)
def stop(context):
try:
# Remove all of the event handlers your app has created
futil.clear_handlers()
# This will run the stop function in each of your commands as defined in commands/__init__.py
commands.stop()
workspace = ui.workspaces.itemById(config.WORKSPACE_ID)
solid_panel = workspace.toolbarPanels.itemById( config.SOLID_CREATE_ID )
sketch_create_panel = workspace.toolbarPanels.itemById( config.SKETCH_CREATE_ID )
sketch_modify_panel = workspace.toolbarPanels.itemById( config.SKETCH_MODIFY_ID )
solid_submenu = solid_panel.controls.itemById( config.FRC_TOOLS_DROPDOWN_ID )
# Delete the Solid->Create FRCTools submenu
if solid_submenu:
solid_submenu.deleteMe()
sketch_create_submenu = sketch_create_panel.controls.itemById( config.FRC_TOOLS_DROPDOWN_ID )
# Delete Sketch->Create FRCTools submenu
if sketch_create_submenu:
sketch_create_submenu.deleteMe()
sketch_modify_submenu = sketch_modify_panel.controls.itemById( config.FRC_TOOLS_DROPDOWN_ID )
# Delete Sketch->Modify FRCTools submenu
if sketch_modify_submenu:
sketch_modify_submenu.deleteMe()
except:
futil.handle_error('stop')