Fusion360のイベント処理が少しづつ理解出来るようになってきた・・・つもり。
前からCADを操作したログが、何処かにあるのではないかな?と思ってはいる
のですが、未だに見つからず。
逆にイベントを利用すると取得出来ることに気が付き、今後の事もあってログを
取得するためのアドインを作りました。
#Fusion360 python adinn #Author-kantoku #Description-command logging import adsk.core, adsk.fusion, adsk.cam, traceback _handlers = [] _app = adsk.core.Application.cast(None) class CommandHandler(adsk.core.ApplicationCommandEventHandler): def __init__(self): super().__init__() def notify(self, args): try: data = { 'act_cmd':'ui.activeCommand', 'args_cmd_id':'args.commandId' } ui = _app.userInterface cmdlog = [] for key in data: res = None try: res = eval(data[key]) except: res = '(null)' cmdlog.append(key + '||{:35}'.format(res)) print(' - '.join(cmdlog)) except: print('errer!!') def run(context): ui = None try: global _app _app = adsk.core.Application.get() ui = _app.userInterface onCommand = CommandHandler() ui.commandTerminated.add(onCommand) _handlers.append(onCommand) print('--- Start addin ---') 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 for hdl in _handlers: ui.commandTerminated.remove(hdl) _handlers.clear() print('--- Stop addin ---') except: if ui: ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
ログ取得なんて大げさに書きましたが、デバッグコンソールに垂れ流しているだけです。
”これが何に役立つの?” と思うかもしれませんが、分かっていないです。
但し、他人には間違いなく役に立たないです。
ちょっと欲しいものと違うんだよなぁ・・・。