Community
Fusion Design, Validate & Document
Stuck on a workflow? Have a tricky question about a Fusion (formerly Fusion 360) feature? Share your project, tips and tricks, ask questions, and get advice from the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Efficient ways to change text in a design, repeatedly

10 REPLIES 10
Reply
Message 1 of 11
Anonymous
3390 Views, 10 Replies

Efficient ways to change text in a design, repeatedly

Hello,

 

The question i'm trying to answer is a tad complex so bear with me.  Essentially, I create a lot of designs for 3D printing where each customer may give me different text for the design.  As it stands I have a saved file before exploding the text.  I open that file, type in the new text, explode it, and extrude it. 

 

However, now I wish to get much more complex.  I want to make designs that reference text and build a back plate around it, for example.  Is it possible to do this with fusion 360?  Can I "go back" in a design and edit exploded text for new designs?  

 

For comparison I've seen this done in openscad where you can type text to generate a design since it is script based.

 

Does anyone have any input?  Thanks

10 REPLIES 10
Message 2 of 11
etfrench
in reply to: Anonymous

You can change the text, but not if you explode it.  Once extruded, you can project the bodies to another sketch and the projected geometry will update as long as you don't change the number of characters.

ETFrench

EESignature

Message 3 of 11
l_kesiunas
in reply to: Anonymous

Hello,

I’ve came accross the same idea as yours that I wanted to achieve. After few days of reading, tinkering and “learning” how python works I’ve found really cool solution that I want to share with you guys. It lets me to change the text in the design in just two clicks and save that as an stl automatically – ready for 3D printing.

 

First, let’s start from the credits which goes to:

  1. ekinsb and rwillardphil from this forum had a discussion and did some Fusion API coding that I‘ve mixed together. (https://forums.autodesk.com/t5/fusion-360-api-and-scripts/script-to-select-sketchtext-and-have-a-dia...)
  2. Once again ekinsb made another awesome answer with the code on this forum thread that I‘ve mixed in (https://forums.autodesk.com/t5/fusion-360-api-and-scripts/script-api-to-change-parameter-and-then-ex...)

 

So to get started, first you need to create anew script (code below):

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
        
        # Get the sketch named "ChangeText"
        sk = rootComp.sketches.itemByName('ChangeText')
        
        # Get the first sketch text.
        skText = sk.sketchTexts.item(0)

        #Prompts the user for the new Text   
        (returnValue, cancelled) = ui.inputBox('What text?', 'New text:', )
        
        # Grab the sketch and first text entity 
        sk = rootComp.sketches.itemByName('ChangeText') 
        skText = sk.sketchTexts.item(0)

        # Change the text.
        skText.text = returnValue

        # Write in the path to the folder where you want to save STL‘s
        folder = 'C:/Users/Desktop/etc...'
        
        # Construct the output filename. Name will be the same as you‘ve changed    the text into.
        filename = folder + skText.text + '.stl'

        # Save the file as STL.
        exportMgr = adsk.fusion.ExportManager.cast(design.exportManager)
        stlOptions = exportMgr.createSTLExportOptions(rootComp)
        stlOptions.meshRefinement = adsk.fusion.MeshRefinementSettings.MeshRefinementMedium
        stlOptions.filename = filename
        exportMgr.execute(stlOptions)

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

 

You need to create design and add new sketch where the text that you want to change will be.

IMPORTANT: name that sketch „ChangeText“ so that script could grab it and work on.

 

Next thing that was very important for me was to find a solution to align text so that when you change it it still stays aligned. It is done by a little trick as Fusion doesn‘t have much text options. It is really simple when you find it.

 

I‘ve made a screencast how everything works and how to align text so it stays „parametric“. Attached below.

 

Note that when you choose coincident constraint for the text you should hold SHIFT+find center of the line and click it.

 

Hope that will help as it helped me a lot 🙂 

 

Happy 3D printing!

 

P.S. Maybe someone could help me to add some code so that if you change the text into the same one that is already in the STL export folder, it automatically makes file name "filename+2"?

 

Message 4 of 11
vicente.villegas1204
in reply to: Anonymous

Good day to you!

I came across this and found it to be an amazing little script for my purpose.

I got it to work by following your instructions, however after I input the text on the dialogue box, the newly written text comes out with a lot of space in between letters. Any idea how to fix this? thank you

Message 5 of 11

Hi,

check out the new text function on the path.
Use a simple line as the path and play with the options (lenght of path included). It is also possible to change the spacing afterwards.

 

günther

Message 6 of 11

Hello,

Thank you for trying this out.
I think this may be related to constraints on the text box itself. Try to play around a little bit with different constraints. Hope that you will figure it out. I don't know if I fully understand your problem so if nothing will help out please send the screen-cast to check the problem:)
Cheers
Message 7 of 11

Thank you for your reply!

 

It's a real nice script! Thank you

I've tried different types of constraints and the issue seems to be the same. Will attach photos

I wrote "Test" manually, then booted up the script and wrote "HI" It came out the way it did on the second photo

test.png

TEST2.png

 

Cheers!

Message 8 of 11

Hello,

 

I was able to reproduce your described problem but couldn't figure out how to solve it though.
As I'm not that great at programming maybe someone could help us?:)

 

Maybe the script command which changes the text interferes with some kind of values of different lengths of texts. Are there any other commands to change text (different than: skText = sk.sketchTexts.item(0)   )?

 

Thank you

Message 9 of 11

Hi All,

 

I was having the spacing issue and was able to solve the problem by choosing the "Text on Path" option to create the text, then selecting the "Fit to path" checkbox. 

Message 10 of 11

Thank you very much, I will give it a try!!:)
Message 11 of 11
David_Ewen
in reply to: l_kesiunas

I've been trying to incorporate the file name in the export stl 

 

Does anyone have any ideas how to do that?

 

# Construct the output filename. Name will be the same as you‘ve changed the text into.
filename = folder + skText.text + '.stl'
I've tried changing this line to;
filename = folder + filename + skText.text + '.stl'
filename = folder + rootComp + skText.text + '.stl'
and a couple other variants, but I always get an error.
 
David Ewen

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

Post to forums  

Autodesk Design & Make Report