
Not applicable
02-29-2016
07:44 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have two python files, one with Utility functions and some with a script for running in Fusion 360. Both scripts are in the same directory. Normally using import Utility or Utility.py or from Utility import ReportMessageBox would work in a python enviroment. But when I do this and run my script, nothing happens in fusion 360. If I copy the code into my script it runs fine, so its definetly an import issue. How do I fix this?
import adsk.core, adsk.fusion, adsk.cam, traceback import Utility.py def run(context): ui = None try: app = adsk.core.Application.get() ui = app.userInterface ui.messageBox('Hello script') Utility.reportMessageBox(ui, "Report is through", ("random")) except: if ui: ui.messageBox('Failed:\n{}'.format(traceback.format_exc())) #Next File #import adsk.core, adsk.fusion, adsk.cam # #def createNewComponent(rootComp): # allOccs = rootComp.occurrences # newOcc = allOccs.addNewComponent(adsk.core.Matrix3D.create()) # return newOcc.component # #def nameObject(objectA, name): # objectA.name = name; def reportMessageBox(ui, message, parameters): ui.messageBox("In here") for parameter in parameters: newMessage = message.replace("{}", str(parameter),1) if message == newMessage:#{} was not found and replaced message+=", "+str(parameter) else: message = newMessage ui.messageBox(message)
Solved! Go to Solution.