Message 1 of 1
Palette sample with useNewWebBrowser
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
Here is the version of the Palette sample in Python with useNewWebBrowser set to True.
The first modification is the last argument of Palettes.add sets to True at line 25:
palette = _ui.palettes.add('myPalette', 'My Palette', 'palette.html', True, True, True, 300, 200, True)
The second modification is in the event handler for the palette HTML event at line 108:
# Event handler for the palette HTML event.
class MyHTMLEventHandler(adsk.core.HTMLEventHandler):
def __init__(self):
super().__init__()
def notify(self, args):
try:
htmlArgs = adsk.core.HTMLEventArgs.cast(args)
if htmlArgs.action == 'response':
response = json.loads(htmlArgs.data)
msg = "An event has been fired from the html to Fusion with the following data:\n"
msg += ' Command: {}\n'.format(htmlArgs.action)
msg += ' Response: {}\n'.format(response['data'])
else:
data = json.loads(htmlArgs.data)
msg = "An event has been fired from the html to Fusion with the following data:\n"
msg += ' Command: {}\n arg1: {}\n arg2: {}'.format(htmlArgs.action, data['arg1'], data['arg2'])
_ui.messageBox(msg)
except:
_ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
Hope this helps.
Jérôme Briot, Freelance engineer - Mechanical design and prototyping
3D Print Plus / Pro | IDF Import | GitHub To Fusion 360 | Tube Bending Data Exchanger | Slice Data Export
Memory Used | Basic Calculator | Check Computer Specifications | Import spline from any CSV file