Hi @info83PHN .
Probably not going to end up in a small script.
We worked on it a bit, but if the workflow has been changed, it is probably unnecessary.
I'm leaving this in case others can use it.
I created a function to get the names of fonts that can be used dynamically.
def getFontName() -> list:
app: adsk.core.Application = adsk.core.Application.get()
ui = app.userInterface
des: adsk.fusion.Design = app.activeProduct
root: adsk.fusion.Component = des.rootComponent
app.executeTextCommand(u'PTransaction.Start getFontName')
skt: adsk.fusion.Sketch = root.sketches.add(root.xYConstructionPlane)
sktTxtIpt: adsk.fusion.SketchTextInput = skt.sketchTexts.createInput2(
'hoge',
2.0
)
sktTxtIpt.setAsMultiLine(
adsk.core.Point3D.create(0, 0, 0),
adsk.core.Point3D.create(10, 5, 0),
adsk.core.HorizontalAlignments.LeftHorizontalAlignment,
adsk.core.VerticalAlignments.TopVerticalAlignment,
0
)
sktTxt: adsk.fusion.SketchText = skt.sketchTexts.add(sktTxtIpt)
sels: adsk.core.Selections = ui.activeSelections
sels.clear()
sels.add(sktTxt)
app.executeTextCommand(u'Commands.Start EditMTextCmd')
dialogInfo = app.executeTextCommand(u'Toolkit.cmdDialog')
app.executeTextCommand(u'NuCommands.CancelCmd')
skt.deleteMe()
app.executeTextCommand(u'PTransaction.Abort')
fontInfos = dialogInfo.split('TextFont,')[-1].split('TextExStyle,')[0].split('MenuItems:')[-1].split('\n')
fonts = [str.strip(t.split(',')[0]) for t in fontInfos]
return fonts
It took me about two hours just to do this because I am not proficient enough.
It seems that I am still lacking in study.