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.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Edit text value in API

Message 1 of 6
847 Views, 5 Replies

Edit text value in API

I have a simple model - basically a square with 9 holes in it and text at the bottom. I need to change the hole diameter and text based on a table of values. The hole diameter is easy to change base on a parametric value, but I can't seem to edit the text value with the API.


This returns the current text value, but errors when setting the text value to a new string (textinputitem.text = "booyah")



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


        design = app.activeProduct

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

        textsketch = sketches.itemByName("Sketch1")
        textsketchtexts = textsketch.sketchTexts
        textinputitem = textsketchtexts.item(0)
        actualwords = textinputitem.text

        textinputitem.text = "booyah"
Tags (3)
Labels (1)
Message 2 of 6
in reply to: RobotBee
Message 3 of 6
in reply to: kandennti

I restarted computer and Fusion360 this is the error that I'm getting. Since you say that its working for you I'll make another model and see if I'm getting something odd going on.





Message 4 of 6
in reply to: RobotBee
Message 5 of 6
in reply to: RobotBee

I tried it with the attached data, but there was no problem.
I don't know the cause of the error.

Message 6 of 6
in reply to: RobotBee

Ok so I think it is a bug.

Due to the way that I modeled the text it applied upside down so I used a -180deg angle to get it flipped over. Fusion360 is fine with the -180 but the API doesn't like the negative 180, when that is changed to +180 it works fine.


Thanks for the help get it sorted out!


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