Attempting to read "fontName" on a "SketchTextInput" crashes fusion

Attempting to read "fontName" on a "SketchTextInput" crashes fusion

Anonymous
511 Views
1 Reply
Message 1 of 2

Attempting to read "fontName" on a "SketchTextInput" crashes fusion

Anonymous
Not applicable

 

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 😉

0 Likes
512 Views
1 Reply
Reply (1)
Message 2 of 2

marshaltu
Autodesk
Autodesk

Hello,

 

Thank you for reporting the issue to us. It was an API bug and logged as UP-38040 in our internal system. 

 

Thanks,

Marshal



Marshal Tu
Fusion Developer
>
0 Likes