I try to make an add-in for Fusion 360 where I could get a parametric assembly from web-server. I made a try but there was an error which I have no idea how to make it solved.
User has to click on add-in and then parametric assembly and palette should appear at the same time (custom palette is for choosing user's parameters).
Here are the code and an error:
Hello,
I guess that the problem is in the next block of code:
if palette:
palette.deleteMe()
The deleteMe() method deletes the palette object but it doesn't clear the palette variable. So the condition "if not palette:" is false and the code goes to the line "palette.isVisible = True". But the palette object doesn't exist anymore. So the code crashes.
A solution could be to set the variable to None:
if palette:
palette.deleteMe()
palette = None
But can you explain what you're trying to do?
Please use the "Insert/Edit code sample" tool ( </> icon in the toolbar) when you write your message.
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
Hi! We are trying to create an add-in application to design parametric assemblies (couplings). We want to get a parametric coupling assembly from web-server and put it into Fusion 360 active design (user has to choose desired parameters and then click on Build button).
Hi @state.of.grace.17 .
I'm not sure what 'index.html' is doing, but I modified it like this and the error was avoided.
・・・
class SampleCommandExecuteHandler(adsk.core.CommandEventHandler):
def __init__(self):
super().__init__()
def notify(self, args):
try:
# app = adsk.core.Application.get()
# ui = app.userInterface
# Create and display the palette.
palette = ui.palettes.itemById('myExport')
# if palette:
# palette.deleteMe()
if not palette:
#make the [close] button invisible
palette = ui.palettes.add('myExport', 'БИБЛИОТЕКА МУФТ', 'index.html', True, True, True, 400, 200)
# Dock the palette to the right side of Fusion window.
palette.dockingState = adsk.core.PaletteDockingStates.PaletteDockStateRight
palette.isVisible = True
url = "http://195.133.144.86:4200//Half-coupling1.f3d"
occ = importComponentFromURL(url)
except:
ui.messageBox('Command executed failed: {}'.format(traceback.format_exc()))
・・・
def importComponentFromURL(url) -> adsk.fusion.Occurrence:
・・・
# import f3d
app.executeTextCommand(u'Fusion.ImportComponent /NoMove {}'.format(dlFile))
# app.executeTextCommand(u'NuCommands.CommitCmd')
・・・
def stop(context):
# ui = None
try:
ui.messageBox('Stop addin')
・・・
We have also fixed the strange scope of 'ui'.