Пример #1
0
def run(context):
    ui = None
    try:
        app = Core.Application.get()
        ui = app.userInterface

        # Get the CommandDefinitions collection.
        cmdDefs = ui.commandDefinitions

        # Create a button command definition.
        buttonSample = cmdDefs.addButtonDefinition('S2MScriptId',
                                                   'Python S2M generator',
                                                   'Generate S2M pulley')

        # Connect to the command created event.
        sampleCommandCreated = SampleCommandCreatedEventHandler()
        buttonSample.commandCreated.add(sampleCommandCreated)
        handlers.append(sampleCommandCreated)

        # Execute the command.
        buttonSample.execute()

        # Keep the script running.
        Adsk.autoTerminate(False)
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
Пример #2
0
def run(context):
    global _app, _ui
    try:
        _app = adsk.core.Application.get()
        _ui = _app.userInterface
        cmdDefs = _ui.commandDefinitions

        btn = cmdDefs.itemById('gen-dxf-button')
        if btn:
            btn.deleteMe()

        btn = cmdDefs.addButtonDefinition('gen-dxf-button', "Generate DXF", "")
        h = ExportDialogHandler()
        btn.commandCreated.add(h)
        handlers.append(h)

        btn.execute()

        # panel = ui.allToolbarPanels.itemById('SolidScriptsAddinsPanel')
        # buttonControl = panel.controls.addCommand(btn)

        adsk.autoTerminate(False)

    except:
        if _ui:
            _ui.messageBox("Failed:\n%s" % (traceback.format_exc(), ), "Error")
Пример #3
0
def run(context):
    app = adsk.core.Application.get()
    ui = app.userInterface
    commandDefinitions = ui.commandDefinitions

    cmdDef = commandDefinitions.itemById(commandName1)
    if cmdDef:
        cmdDef.deleteMe()

    adsk.autoTerminate(False)

    newCommand1.onRun()
Пример #4
0
def run(context):
    try:
        commandDefs = ui.commandDefinitions
        batchPostCommandDefinition = commandDefs.itemById('BatchPostCommand')

        if not batchPostCommandDefinition:
            batchPostCommandDefinition = commandDefs.addButtonDefinition(
                'BatchPostCommand', 'Batch Post', 'Batch Post NC')

        onCreated = BatchPostCommandCreatedHandler()
        batchPostCommandDefinition.commandCreated.add(onCreated)
        handlers.append(onCreated)

        inputs = adsk.core.NamedValues.create()
        batchPostCommandDefinition.execute(inputs)
        adsk.autoTerminate(False)

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
Пример #5
0
def setup(target_script, script_name):

    global _script_to_run
    _script_to_run = target_script
    global _script_name
    _script_name = script_name

    ui = None
    try:
        print("in transaction.setup")
        app = Core.Application.get()
        ui = app.userInterface

        # Get the CommandDefinitions collection.
        cmdDefs = ui.commandDefinitions

        if cmdDefs.itemById(script_name):
            cmdDefs.itemById(script_name).deleteMe()

        # Create a button command definition.
        buttonSample = cmdDefs.addButtonDefinition(script_name, script_name,
                                                   "")

        # Connect to the command created event.
        sampleCommandCreated = SampleCommandCreatedEventHandler()
        buttonSample.commandCreated.add(sampleCommandCreated)
        handlers.append(sampleCommandCreated)

        # Execute the command.
        buttonSample.execute()

        # Keep the script running.
        Adsk.autoTerminate(False)
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))