Invalid font name when changing a sketch Text using APS with Fusion360

Invalid font name when changing a sketch Text using APS with Fusion360

Linushaddad
Explorer Explorer
210 Views
2 Replies
Message 1 of 3

Invalid font name when changing a sketch Text using APS with Fusion360

Linushaddad
Explorer
Explorer
Hello,

I'm using APS with Fusion360, and in my appBundle, i'm trying to change the text of a sketch that i retrieve from a document, however, i get "invalid input font name" when i try to change the text, i do not wish to change the font at all, here's an example code. I also have to say that i'm new at scripting with Autodesk,
  const doc = getDocument(app, false, "", scriptParameters.fileURN);
  const design = app.activeProduct as adsk.fusion.Design;
  const rootComp = design.rootComponent;
  const sketches = rootComp.sketches;
  const textSketch = sketches.itemByName("Text1");
  const sketchTexts = textSketch.sketchTexts;
  const sketchText = sketchTexts.item(0);
  const newText = scriptParameters.parameters.Text1;

   adsk.log(sketchText.text) /* I get the actual text from the sketch here, eg: Test*/
  adsk.log(sketchText.fontName) /*  i get "Arial" in the log, correct font name of the sketch*/
  adsk.log(newText) /* I get correctly what i'm sending on parameter on the workItem*/

  sketchText.text = newText; /* This is where the bug occurs,  i basically get :
{"message":"3: TASK_ERRORCODE_SCRIPT_EXCEPTION: GENERICEXCEPTION: Exception detected.\nError: GETLASTERROR: invalid input font name */
 
I also tried to assign it to Arial maybe to overwrite but same issue
I'm i missing something ? is it a known issue ? is there any workaround ? 

Thank you in advance for your answers.
0 Likes
Accepted solutions (1)
211 Views
2 Replies
Replies (2)
Message 2 of 3

vinit_pahilajani
Autodesk
Autodesk
Accepted solution

 

Hello, @Linushaddad 

Thank you for reaching out. I understand that you are encountering an "invalid input font name" error when attempting to change the sketch text in your appBundle.
Due to an internal technical issue, we encounter this problem right now. However, I can suggest the following workaround:
adsk.log(sketchText.text)
adsk.log(sketchText.fontName)
adsk.log(newText) sketchText.fontName = "DejaVu Sans"; // Work around for the error.
sketchText.text = newText; // This should not throw any errors now.

Besides "DejaVu Sans", you could also try using other fonts such as "Arimo".
I would highly recommend you to refer "extrude-text.ts" sample script, as it uses a similar approach. These samples should be available in Fusion Automation API Add-In listed under: https://aps.autodesk.com/en/docs/design-automation/v3/developers_guide/fusion_specific/typescript 

Thank you for your patience, and please let us know if you have any further questions or issues.
Best regards,
Vinit Pahilajani

Message 3 of 3

CGBenner
Community Manager
Community Manager

@vinit_pahilajani 

 

Hello.  Did the information provided answer your question? If so, please use Accept Solution so that others may find this in the future. Thank you very much!

Did you find a post helpful? Then feel free to give likes to these posts!
Did your question get successfully answered? Then just click on the 'Accept solution' button.  Thanks and Enjoy!


Chris Benner
Community Manager

0 Likes