Message 1 of 2
Attempting to read "fontName" on a "SketchTextInput" crashes fusion

Not applicable
02-08-2018
05:29 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
import adsk.core, adsk.fusion, traceback def Point3D(x, y): return adsk.core.Point3D.create(x, y, 0) def run(context): ui = None try: app = adsk.core.Application.get() ui = app.userInterface des = adsk.fusion.Design.cast(app.activeProduct) root = des.rootComponent sketch = root.sketches.add(root.xYConstructionPlane) msg = 'Is this thing working?' text_input = sketch.sketchTexts.createInput(msg, 0.25, Point3D(1, 1)) default_font = text_input.fontName # BOOM text_input.fontName = 'Consolas' txt = sketch.sketchTexts.add(text_input) text_p = txt.boundingBox.maxPoint.copy() text_p.x = -(text_p.x - 1) / 2 text_p.y = -(text_p.y - 1) / 2 text_p.z = 0 txt.position = text_p except: if ui: ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
The above code causes a "hard crash" of fusion (on the line commented with BOOM) - it crashes so hard that I don't even get the submit crash info dialog.
Why am i trying to read the font? because consolas isn't available on all OS's and I can't find a way to enumerate what fonts are available - so I was planning to take the python way of asking forgiveness but for that to work I need to know what value to set the font name back to after the "unknown font" exception is raised and caught. I have a hack-around for myself but this is clearly a bug that should get squished 😉