Message 1 of 4
ExportManager(stlOptions) RuntimeError: 2 : InternalValidationError : success
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Ok I must say, I love it ! 😍
I get an error to tell me "success" 🤣
Anyway, this is pretty annoying , as the script stop working, after running properly for a while.
Here is the exact error I am getting (sorry, repetitive errors trying to upload that tiny image)
here is the script itself, s it's pretty short:
#Author-BG
#Description-Copy bodies from a full assembly into a single component, to make it easier to export a STL
# The goal is to copy bodies from a full assembly into a new component, so that it will be possible
# to export as STL from Fusion with a common origin (and axis)
# Beginning on 23/2/2020 :59 by BG
# Now the script DO NOT copy bodies, just export them as STL, only if the component is visible
import adsk.core, adsk.fusion, traceback
# Create a collection to store our bodies
sourceBodies = adsk.core.ObjectCollection.create()
folder = "C:/Users/bgros/Documents/Rosetta/Machine Nicolas/ApiExport"
def traverse(occurences):
# recursive method to get all bodies from components and sub-components
for occ in occurences:
visiFlag = occ.isLightBulbOn
bodies = occ.bRepBodies
for bod in bodies:
if visiFlag:
bod.name = occ.fullPathName
sourceBodies.add(bod)
adsk.doEvents()
visiFlag = False
if occ.childOccurrences:
traverse(occ.childOccurrences)
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
# Get active design
product = app.activeProduct
design = adsk.fusion.Design.cast(product)
if not design:
ui.messageBox('It is not supported in current workspace, please change to MODEL workspace and try again.')
return
# History must be captured for this to work
if design.designType == adsk.fusion.DesignTypes.DirectDesignType:
design.designType = adsk.fusion.DesignTypes.ParametricDesignType
# Get root component in this design
rootComp = design.rootComponent
# Get all Components below root
occs = rootComp.occurrences
# add all bodies from all components in the collection
traverse(occs)
# # create the new component , adding "for STL Export" to the name
# newComp = occs.addNewComponent(adsk.core.Matrix3D.create())
# newComp.component.name = rootComp.name + " for STL Export"
adsk.doEvents()
# copy paste ALL bodies to the new component
#newComp.component.features.copyPasteBodies.add(sourceBodies)
for oneBody in sourceBodies:
#oneBody.name = rootComp.name + " " + oneBody.name
# newComp.component.features.copyPasteBodies.add(oneBody)
# Construct the output filename.
oneBody.name = oneBody.name.replace(":", "-")
filename = folder + "/" + oneBody.name + '.stl'
# Save the file as STL.
exportMgr = adsk.fusion.ExportManager.cast(design.exportManager)
stlOptions = exportMgr.createSTLExportOptions(oneBody, filename)
stlOptions.meshRefinement = adsk.fusion.MeshRefinementSettings.MeshRefinementHigh
stlOptions.isOneFilePerBody = True
stlOptions.sendToPrintUtility = False
exportMgr.execute(stlOptions)
adsk.doEvents()
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))