Edit text value in API

Edit text value in API

RobotBee
Participant Participant
1,374 Views
5 Replies
Message 1 of 6

Edit text value in API

RobotBee
Participant
Participant

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
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface

        ui.messageBox("Running")

        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

        ui.messageBox(str(actualwords))
        textinputitem.text = "booyah"
 
 
0 Likes
1,375 Views
5 Replies
Replies (5)
Message 2 of 6

kandennti
Mentor
Mentor
0 Likes
Message 3 of 6

RobotBee
Participant
Participant

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.

 

 

RobotBee_0-1601524499974.png

 

0 Likes
Message 5 of 6

kandennti
Mentor
Mentor

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

0 Likes
Message 6 of 6

RobotBee
Participant
Participant

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!

 

0 Likes