Cannot select .shx fonts on SketchText object

matt_bucknall
Participant

Cannot select .shx fonts on SketchText object

matt_bucknall
Participant
Participant

Hi,

 

If I try setting fontName on a SketchText object to any of the .shx font names ('Iso', 'Romans' etc), I get the following error:

font-error.png

 

This does not happen if I set the font to a system font like 'Arial'.

 

If I get fontName on a SketchText object that has had its font set to an .shx font via the GUI (EDIT TEXT) then the correct font name is returned without the extension (i.e. if 'Iso.shx' is selected, fontName returns 'Iso').

 

I've tried setting fontName to 'Iso' with and without the .shx extension - It makes no difference.

 

Matt.

 

0 Likes
Reply
Accepted solutions (1)
9,259 Views
42 Replies
Replies (42)

matt_bucknall
Participant
Participant

I'm pretty sure this is a bug - Is this the right place to report bugs?

0 Likes

goyals
Autodesk
Autodesk

Hi @matt_bucknall,

 

Thank you for reporting this.  UP-39610 is created in our internal system to track this.  Your feedback is really crucial to help us in making Fusion great product.

 

Regards,

Shyam Goyal



Shyam Goyal
Sr. Software Dev. Manager
0 Likes

matt_bucknall
Participant
Participant

Okay - Doesn't look like there is public access bug tracking available - How will I know when the issue is fixed? 

0 Likes

goyals
Autodesk
Autodesk

Issue is already fixed on our side but it will be available for public in next release. I will update you through this thread once the fix is available.



Shyam Goyal
Sr. Software Dev. Manager
1 Like

matt_bucknall
Participant
Participant

No sign of this being fixed in the August 22nd update. Likely to be in the next one?

0 Likes

goyals
Autodesk
Autodesk

Yes, the fix did not make it to August release. It will be part of next release.



Shyam Goyal
Sr. Software Dev. Manager
0 Likes

matt_bucknall
Participant
Participant
Accepted solution

Looks to be sorted now - Thanks.

0 Likes

JadeNJoy
Explorer
Explorer

Good day,

 

I'm having issues trying to set the sketchText input for a textbox using a shx font. I can change the following text with Arial font without any errors: 

textBoxInput = 'sample'
textBox1.text = textBoxInput
 
However, I run into the runtime error 3: invalid input font name when changing to shx.  Can you please help?
Attached error message.
1 Like

thomasa88
Advocate
Advocate

I can confirm the behavior seen by @JadeNJoy  .

 

Fusion v 2.0.9006.

 

Trying to append ".shx" in the script does not fix it:

try:
	sketch_text.text = evaluate_text(text)
except RuntimeError as e:
	print(e)
	if '3 : invalid input font name' in str(e):
		print("FONT OLD:", sketch_text.fontName)
		sketch_text.fontName = sketch_text.fontName + '.shx'
		print("FONT NEW:", sketch_text.fontName)
		sketch_text.text = evaluate_text(text)
					
					
3 : invalid input font name
FONT OLD: Weidner
FONT NEW: Weidner

 

I found a workaround though! Set the fontName to a true type font temporarily.

old_font = sketch_text.fontName + '.shx'
sketch_text.fontName = 'Arial'
sketch_text.text = evaluate_text(text)
sketch_text.fontName = old_font

 

0 Likes

Anonymous
Not applicable

@goyals @thomasa88 

Hello

 

I used the same work around to make changes to .shx fonts:

 

currentFontName = textBox1.fontName

textBox1.fontName = 'Arial'
textBox1.text = 'change here'
textBox1.fontName = currentFontName +'.shx'
 
This still works fine on old style textboxes (from old templates I have) but doesn't work anymore on new style textboxes (probably since this week's update as of 19 Oct 2020).
 
I have "RunTimeError 3: Invalid input font name" on textBox1.fontName = 'Arial' 
Has there been a change in the way to change fontName? I looked in the reference manual but I havent seen changes and the new Sketch Text API Sample doesnt address it.
1 Like

thomasa88
Advocate
Advocate

Ping @anandjoshi  , developer of new font feature.

 

I can confirm the issue seen by @Anonymous . Also, what has not been mentioned earlier is that changing the .text property fails if the font is an SHX font, with "3 : invalid input font name"  (the switch to Arial workaround above "solved" this, but that is now broken as well.)

 

Here are my observations:

  1. Use the GUI to create a text with "Arial" as font.
  2. Set font as "Weidner.shx" using API (sketch_text.fontName = "Weidner.shx")
  3. Font is still rendered as Arial.
  4. Open the text edit dialog in the GUI. The font shows as "Weidner.shx" in the dropdown.
  5. Press OK. The font is now re-rendered.
  6. Try to change font to "Arial" using API:
    1. File "/ParametricText/ParametricText.py", line 561, in set_sketch_text
      sketch_text.fontName = 'Arial'
      File "/packages\adsk\fusion.py", line 58933, in _set_fontName
      return _fusion.SketchText__set_fontName(self, value)
      RuntimeError: 3 : invalid input font name
  7. Try to change .text -> RuntimeError: 3 : invalid input font name

 

 

  1. Use the GUI to create a text with "Arial Black" as font.
  2. Set font as "Arial" using API (sketch_text.fontName = "Arial")
  3. Font rendering is correctly updated to Arial.

 

This essentially breaks my add-in for SHX fonts (again).

2 Likes

Anonymous
Not applicable

Hello @anandjoshi

 

Can you advise re the mentioned issues or suggest an alternative way of updating textboxes with shx fonts?  This is crucial to my business operations to update templates.

 

Thanks

Antoine 

 

 

 

Thanks

Antoine

0 Likes

suraj.rawat2A43P
Autodesk
Autodesk

Hello @Anonymous,

 

Could you please share a sample script, that we can use in our investigation and validation.

Thanks,

Suraj

0 Likes

Anonymous
Not applicable

Hi @suraj.rawat2A43P , @goyals 

 

The below script used to work fine until last week. It is still possible to amend text when not in shx font. However, the problem is now changing the fontname itself doesnt work. In order to amend the text for textboxes with a shx font, the workaround was to first change the font to smth like Arial, then update the text and finally set the font back to a shx font. 

 

import adsk.core, adsk.fusion, adsk.cam, traceback

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface

        design = app.activeProduct
        rootComp = design.rootComponent
        sketches = rootComp.sketches

        textBox1Sketch = sketches.item(0)
        textBox1sketchTexts = textBox1Sketch.sketchTexts
        textBox1 = textBox1sketchTexts.item(0)

        try: 
            textBox1.text = "try this"
 
        except RuntimeError:
            #Special handling for SHX formats
            currentFontName = textBox1.fontName
            textBox1.fontName = 'Arial'
            textBox1.text = "try that"
            textBox1.fontName = currentFontName +'.shx'

 

1 Like

goyals
Autodesk
Autodesk

I am not able to see Arial.shx Shape font file in Fusion installed folder. Below is the list of shape font files present there. I tried your script with 'Weidner.shx' and it worked for me. May be you can try once on your side as well. Thanks.

 

goyals_0-1604049853090.png

 



Shyam Goyal
Sr. Software Dev. Manager
2 Likes

Anonymous
Not applicable

Hi @goyals 

 

I am not trying to use Arial.shx. I was using Arial font as a work around to amend the text of a textbox which had the font set to shx.

 

I am not able to change the fontName anymore using the code I provided. It used to work fine until the latest update. Are you able to change .fontName without getting the runTimeError 3? 

 

Also the fact that we cannot update text from textboxes with shx fonts is a separate issue. I am able to change the values for others font types. This has been outstanding for a long time. Has this been logged? 

 

Thanks for your help

0 Likes

goyals
Autodesk
Autodesk

Hi @Anonymous , 

 

Yes I am able to change the font name. Please take a look at attached video. 



Shyam Goyal
Sr. Software Dev. Manager
0 Likes

Anonymous
Not applicable

Hi @goyals 

 

When using the below code, I have two outcomes:

 

1) if the initial font is not shx then the text will be updated. The change to shx will not update on the sketch although when opening the EDIT TEXT window manually it will show that it has been updated to shx. Only when you click OK on the EDIT TEXT window it will update the display on the sketch to the correct font. 

 

2) if the initial font is shx, then I run into runtimeerror 3 on textBox1.fontName = "Arial"

 

This behaviour was also observed by @thomasa88  in this thread (message 12).

 

 

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui = app.userInterface

        textBox1 = app.activeProduct.rootComponent.sketches[0].sketchTexts[0]

        currentFont = textBox1.fontName

        if currentFont != "Arial":
            textBox1.fontName = "Arial"
            textBox1.text = 'try this'
            textBox1.fontName = "Simplex.shx"

 

0 Likes

thomasa88
Advocate
Advocate

Hi @goyals , I played around a bit in the attached video.

 

I was almost fooled that switching to/from SHX works, but as you can see later in the video, when I switch font in the GUI, Weidner.SHX has a completely different appearance.

 

2.0.9305
Active Plan: Fusion 360, Personal
Windows 10 (18363)

 

edit. Looks like one has to press the download button on this attachment. Also, I think the error "invalid font name" might be the API reading the SHX font without the ".shx" suffix and feeding it back to Fusion - for every call that changes the font.

0 Likes