Community
Hi all
Does anyone know why I am getting this error?
Failed:
Traceback (most recent call last):
File "C:/Users/YouElz/AppData/Roaming/Autodesk/Autodesk Fusion 360/API/Scripts/NewScript2/NewScript2.py", line 11, in run
design = adsk.fusion.Design.cast(app.activeProduct)
^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'cast'
import adsk.core, adsk.fusion, adsk.cam, traceback
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
design = adsk.fusion.Design.cast(app.activeProduct)
ui.messageBox('Hello script')
except:
print('Failed:\n{}'.format(traceback.format_exc()))
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
Solved! Go to Solution.
Solved by j4n.vokurka. Go to Solution.
Hi,
what workspace is active in the document when you call this script?
this should return a string which defines in which workspace you are:
product = app.activeProduct
productType = product.productType
If the value does not match with one of these, I would expect the error you reported to occur.
Thank you for the reply.
I was in the design workspace.
I restarted Fusion and VSCode then debug and it worked... not sure what happened.
Can't find what you're looking for? Ask the community or share your knowledge.