Message 1 of 2

Not applicable
08-10-2020
05:08 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, I am having the following script (which I already run a couple of times before). Now, whenever I run it again a get the error (shown below). I assume there is some small bug in the stop function, but I cannot really find it. If anyone can help, I would very much appreciate it!
#Author-
#Description-
import adsk.core, adsk.fusion, adsk.cam, traceback
_handlers = []
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
### SETUP:
# Create a command definition and add a button to the CREATE panel.
createHolesCmdDef = ui.commandDefinitions.addButtonDefinition('CreateHolesAddIn', 'Add holes in model to reduce heat', 'Creates holes in the model that help reduce heat', 'resources')
# grabbing correct toolbar panel
addinsPanel = ui.allToolbarPanels.itemById('SolidScriptsAddinsPanel')
createHolesButton = addinsPanel.controls.addCommand(createHolesCmdDef)
# adding the button into the Solid Addins Panel
createHolesControl = addinsToolBar.controls.addCommand(createHolesCmdDef, 'createHolesControl')
# putting this button in the panel instead of dropdown menu
createHolesControl.isPromotedByDefault = True
createHolesControl.isPromoted = True
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
ui.messageBox('You stopped "CREATE HOLES" addin.')
createHolesButton = addinsPanel.controls.itemById('CreateHolesAddIn')
if createHolesButton:
createHolesButton.deleteMe()
cmdDef = ui.commandDefinitions.itemById('CreateHolesAddIn')
if cmdDef:
cmdDef.deleteMe()
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
#class CreateHolesCommandCreatedHandler(adsk.core.CommandCreatedEventHandler):
Solved! Go to Solution.