Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all,
I've been trying to run to modify text and export the body as an stl. The text changes and the message box at the end displays that "it's finished", however the stl does not export. I would like to export one body or the root body of the project. Are there limitations using the API with the personal version or am I missing something? Any help would be appreciated.
import adsk.core, adsk.fusion, adsk.cam, traceback
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
design = app.activeProduct
rootComp = design.rootComponent
exportMgr = design.exportManager
# Get the sketch named "ChangeText"
sk = rootComp.sketches.itemByName('ChangeText')
# Get the first sketch text.
skText = sk.sketchTexts.item(0)
#Prompts the user for the new Text
(returnValue, cancelled) = ui.inputBox('Enter text:', 'New text:', )
# Grab the sketch and first text entity
sk = rootComp.sketches.itemByName('ChangeText')
skText = sk.sketchTexts.item(0)
# Change the text.
skText.text = returnValue
# Write in the path to the folder where you want to save STL's
folder = 'C:/Users/millsl/Documents/BobbinSTL'
# Construct the output filename. Name will be the same as you‘ve changed the text into.
filename = folder +skText.text + '.stl'
# Save the file as STL.
exportMgr = design.exportManager
stlOptions = exportMgr.createSTLExportOptions(rootComp)
stlOptions.meshRefinement = adsk.fusion.MeshRefinementSettings.MeshRefinementMedium
stlOptions.filename = filename
exportMgr.execute(stlOptions)
ui.messageBox('Finished.')
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
Solved! Go to Solution.