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:Ā 

Possible ? API Text to sketch and scale to fit width ?

2 REPLIES 2
Reply
Message 1 of 3
info83PHN
331 Views, 2 Replies

Possible ? API Text to sketch and scale to fit width ?

Looking to create ( or pay to get created ) a Fusion API python script that can :

1. display a dialog with text input area, so I can Paste  7 lines of text ( or populate the text input from the Win system clipboard ? ).

2. Use the text in line 1 and Save the open design with that name.

3. Place the text from line 2 in to an existing text area in a sketch.

4. change the height of the text in that text area of the sketch, so that the width of the lettering does not exceed a specific dimension.

5. repeat steps 3 & 4 for another 5 lines, to 5 other text areas ( the 6 text areas can be in one sketch, or on separate sketches, whichever is easier ).

 

If step 4 is not possible, can the text be extruded, and then the bodies of the extruded text, scaled to a specific width ?

 

2 REPLIES 2
Message 2 of 3

I don't really have any answers for you, but I'm interested in the same thing (specifically step 4) since the base program doesn't give users any control over the actual width of text. You can control the height of text but then you're at the whim of the font to determine the width.

I do know that you'll probably have to access the SketchTexts object using the sketchTexts() method (notice the lowercase letter at the start of the method to differentiate it from the actual object). You can do this with the below line

textbox = <sketch object variable name>.sketchTexts.item(0)



To change the actual content of the text you would use

textbox.text = 'new text content'



It should definitely be possible to create the text, then measure the textbox via script, then adjust the text box by scaling it accordingly. The problem is that often the width of the textbox is only very loosely correlated with the actual width of the letter(s). So you might have to explode the text, then somehow find the smallest and highest X value points (the left and right extremes) and calculate the difference. That I assume is going to be the tricky part.

Message 3 of 3
kandennti
in reply to: info83PHN

Hi @info83PHN .

 

The easiest way to create a text sketch of arbitrary width was to draw a line as a guide and use the SketchTextInput.setAsFitOnPath method.

https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-E5C05A62-0282-4FBE-A13D-5A8BF099C2C2 

 

I've created a few and attached the files.

1.png

惻I have not done any saving.
惻It is possible to paste text from the clipboard.
惻The second line of text rewrites the specified sketch text.
惻The specified sketch text must be drawn horizontally on the sketch parallel to the XY plane to create the correct position.

 

When the number of characters in the sketch text increases, it is incomplete because we did not know how to get the direction in which the characters increase.

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