For my script I need to automate loading the CAD model (STEP file); however, my Fusion 360 script (python) crashes unless I manually open a STEP file first.
In this scenario, the script below runs but crashes with the error "Error: Autodesk Translation Services failed to translate the step file, please make sure the step file isn't corrupt!"
#Author-Ivan Walker
#Description-Automate the rendering task
import adsk.core, adsk.fusion, adsk.cam, traceback, math, time
app = None
ui = None
app = adsk.core.Application.get()
if app:
ui = app.userInterface
def run(context):
ui = None
try:
user = app.userName
ui = app.userInterface
#######################################################################
# Load a STEP file
#######################################################################
# Get import manager
importManager = app.importManager
# Get active design
doc = app.documents.add(adsk.core.DocumentTypes.FusionDesignDocumentType)
design = adsk.fusion.Design.cast(app.activeProduct)
#move_camera(app, app.activeViewport)
# Get root component
rootComp = design.rootComponent
# rootComp.activateRootComponent()
# Get step import options
stpFileName = '/Volumes/Ivan' + '\'' + 's Spare Tire/Partpic/Parts DB/Part 1/91247A679.STEP'
stpOptions = importManager.createSTEPImportOptions(stpFileName)
# Import step file to root component
importManager.importToTarget(stpOptions, rootComp)
#######################################################################
adsk.terminate()