-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyPaletteMessageReceivedEventHandler.py
More file actions
53 lines (45 loc) · 1.84 KB
/
MyPaletteMessageReceivedEventHandler.py
File metadata and controls
53 lines (45 loc) · 1.84 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
# Event handler for the palette HTML event.
import json
import traceback
import adsk.core
import adsk.fusion
import adsk.cam
class MyPaletteMessageReceivedEventHandler(adsk.core.HTMLEventHandler):
def __init__(self):
self.app = adsk.core.Application.get()
self.ui = self.app.userInterface
super().__init__()
def notify(self, args):
try:
htmlArgs = adsk.core.HTMLEventArgs.cast(args)
data = json.loads(htmlArgs.data)
app = adsk.core.Application.get()
ui = app.userInterface
# Get current design
design = adsk.fusion.Design.cast(app.activeProduct)
# If there is no active design, send error message
if not design:
ui.messageBox('No active Fusion 360 design', 'No Design')
return
# determine which chapter should be skipped (implementation not finished yet)
chaptersToBeSkipped = 0
if data['command'] == 'skipChapter1':
chaptersToBeSkipped = 1
if data['command'] == 'skipChapter2':
chaptersToBeSkipped = 2
if data['command'] == 'skipChapter3':
chaptersToBeSkipped = 3
if data['command'] == 'skipChapter4':
chaptersToBeSkipped = 4
if data['command'] == 'skipChapter5':
chaptersToBeSkipped = 5
if data['command'] == 'skipChapter6':
chaptersToBeSkipped = 6
if data['command'] == 'skipChapter7':
chaptersToBeSkipped = 7
if data['command'] == 'skipChapter8':
chaptersToBeSkipped = 8
if data['command'] == 'skipChapter9':
chaptersToBeSkipped = 9
except:
self.ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))