TriadCommandInputについては昨年もチラッと記載しましたが
こちらの質問に答えようと思い作ったサンプルです。
How to use Triad for for simple user-controlled Scaling - Autodesk Community
# Fusion360API Python script import traceback import adsk.fusion import adsk.core _app: adsk.core.Application = None _ui: adsk.core.UserInterface = None _handlers = [] CMD_INFO = { 'id': 'kantoku_test', 'name': 'test', 'tooltip': 'test' } _triadIpt: adsk.core.TriadCommandInput = None class MyCommandCreatedHandler(adsk.core.CommandCreatedEventHandler): def __init__(self): super().__init__() def notify(self, args: adsk.core.CommandCreatedEventArgs): adsk.core.Application.get().log(args.firingEvent.name) try: global _handlers cmd: adsk.core.Command = adsk.core.Command.cast(args.command) inputs: adsk.core.CommandInputs = cmd.commandInputs onDestroy = MyCommandDestroyHandler() cmd.destroy.add(onDestroy) _handlers.append(onDestroy) onExecute = MyExecuteHandler() cmd.execute.add(onExecute) _handlers.append(onExecute) global _triadIpt _triadIpt = inputs.addTriadCommandInput( '_triadIptId', adsk.core.Matrix3D.create() ) _triadIpt.setScaleVisibility(True) except: _ui.messageBox('Failed:\n{}'.format(traceback.format_exc())) class MyExecuteHandler(adsk.core.CommandEventHandler): def __init__(self): super().__init__() def notify(self, args: adsk.core.CommandEventArgs): global _triadIpt dump_matrix3D(_triadIpt.transform) class MyCommandDestroyHandler(adsk.core.CommandEventHandler): def __init__(self): super().__init__() def notify(self, args: adsk.core.CommandEventArgs): adsk.terminate() def dump_matrix3D(mat: adsk.core.Matrix3D): pnt, xVec, yVec, zVec = mat.getAsCoordinateSystem() msglist = [ '*****', f'origin:{pnt.asArray()}', f'x vecter:{xVec.asArray()}', f'y vecter:{yVec.asArray()}', f'z vecter:{zVec.asArray()}', ] global _app _app.log('\n'.join(msglist)) def run(context): try: global _app, _ui _app = adsk.core.Application.get() _ui = _app.userInterface cmdDef: adsk.core.CommandDefinition = _ui.commandDefinitions.itemById( CMD_INFO['id'] ) if not cmdDef: cmdDef = _ui.commandDefinitions.addButtonDefinition( CMD_INFO['id'], CMD_INFO['name'], CMD_INFO['tooltip'] ) global _handlers onCommandCreated = MyCommandCreatedHandler() cmdDef.commandCreated.add(onCommandCreated) _handlers.append(onCommandCreated) cmdDef.execute() adsk.autoTerminate(False) except: if _ui: _ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
え~質問が複数あるような気がする上、意味がわからないのですが、
transformとダイアログ上の値が違うって事じゃないのかな・・・。
GUIのボディの移動等と同じだと思うんだけど、これは確かに
使いにくいと思う。