Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

1 REPLY 1
Reply
Message 1 of 2
ross.korsky
314 Views, 1 Reply

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

 

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 😉

1 REPLY 1
Message 2 of 2
marshaltu
in reply to: ross.korsky

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 360 Developer
Autodesk, Inc.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report