Message 1 of 3
Change Text Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
i am new in scripting and i am facing a problem i am runnign this script that another member of the forum wrote but the thing is i am managing to change the text but it doesnt change the model unless i run compute all i tried adding adsk.doEvent() but still no change in the model... any idea why? the script i am running is:
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
design = app.activeProduct
rootComp = design.rootComponent
# 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('What 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
for i in range(100):
time.sleep(0.01)
adsk.doEvents()
# Write in the path to the folder where you want to save STL‘s
folder = 'C:\stl\zz'
for i in range(100):
time.sleep(0.01)
adsk.doEvents()
# 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 = adsk.fusion.ExportManager.cast(design.exportManager)
stlOptions = exportMgr.createSTLExportOptions(rootComp)
stlOptions.meshRefinement = adsk.fusion.MeshRefinementSettings.MeshRefinementMedium
stlOptions.filename = filename
exportMgr.execute(stlOptions)
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))