Message 1 of 3
Not applicable
04-29-2016
12:49 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I'm writing a simple python script to walk through the component hierarchy and export each bRepBody as a separate STL as shown below
import adsk.core, adsk.fusion, traceback
app = adsk.core.Application.get()
ui = app.userInterface
try:
product = app.activeProduct
design = adsk.fusion.Design.cast(product)
exportMgr = design.exportManager
outDir = "c:/temp/fusion1"
# Get the root component of the active design.
rootComp = design.rootComponent
# Iterate over any bodies in the root component.
for j in range(0, rootComp.bRepBodies.count):
body = rootComp.bRepBodies.item(j)
fileName = outDir + "/" + "root_" + body.name
# create stl exportOptions
stlExportOptions = exportMgr.createSTLExportOptions(body, fileName)
stlExportOptions.sendToPrintUtility = False
exportMgr.execute(stlExportOptions)
# Iterate through all of the occurrences in the assembly.
for i in range(0, rootComp.allOccurrences.count):
occ = rootComp.allOccurrences.item(i)
# Get the associated component.
comp = occ.component
for k in range(0,comp.bRepBodies.count):
brbody = comp.bRepBodies.item(k)
fileName = outDir + "/" + comp.name.replace(" ","_" ) + brbody.name
# create stl exportOptions
stlExportOptions = exportMgr.createSTLExportOptions(brbody,fileName) # <--- HERE IT FAILS with InternalValidationError: bRet
stlExportOptions.sendToPrintUtility = False
exportMgr.execute(stlExportOptions)
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
But the script fails in the line where "createSTLExportOptions" is called with an error message "InternalValidationError : bRet".
Any help is appreciated.
Thanks in advance,
Raju
Solved! Go to Solution.
