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: 

Trying to pause 'for' loop

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
brad.bylls
279 Views, 6 Replies

Trying to pause 'for' loop

Going through a for loop and wanting to pause for user input.

for plate in range(1, len(plates)):
    tablePlate = inputs.addStringValueInput('tablePlate', '', plates[plate])
    tablePlate.isReadOnly = True
    table.addCommandInput(tablePlate, plate + 1, 0, 0, 0)

    tableInput = inputs.addStringValueInput('partNum', 'Part Number', '')
    table.addCommandInput(tableInput, plate + 1, 2, 0, 0)
    tableInput = inputs.addStringValueInput('partName', 'Part Name', '')
    table.addCommandInput(tableInput, plate + 1, 3, 0, 0)

    waitBox = input("Fill in the " + tablePlate.value + " info, then press ENTER")

When I get to the end I get this error message.

tablePlate.value is string.

bradbylls_0-1683826942079.png

 

 

Brad Bylls
6 REPLIES 6
Message 2 of 7
jeff.pek
in reply to: brad.bylls

Hi Brad -

 

The input method will return what the user entered. It will not fill in the value you placed into the string. So, I think you'd want to do:

 

userResponse = input("...")

# Do something with response

 

Jeff

Message 3 of 7
brad.bylls
in reply to: jeff.pek

That does not work'

waitBox = input("Fill in the " + tablePlate.value + " info, then press ENTER")

tablePlate.value would be "CP Plate"

waitBox then equals "Fill in the CP Plate info, then press ENTER" if my syntax is correct.

There are input boxes in a dialog box on the screen that I want the user to fill in before continuing.

That is why I am trying to pause the 'for' loop.

Brad Bylls
Message 4 of 7

Hi,

 

You can not use input() function to request data to the user inside Fusion360.

input() is used in scripts that don't have an user interface like in the following screen cast:

wtallerdemadera_0-1683832121126.png

 

In the case of Fusion360, you might want to use the GUI for user input with the set of command objects, like the ones you have in your script.

 

An additional topic in your script:

wtallerdemadera_1-1683832397180.png

start the for loop with the range() call with initial value 0 instead of 1.

 

Hope this could help.

 

Regards,

Jorge Jaramillo

 

Message 5 of 7

So there is no way to pause a script inside of Fusion?

As for starting at 0, that data is used elsewhere and not needed on this loop.

Thanks for the input.

Brad Bylls
Message 6 of 7

Hi,

 

Yes, you have to set the right command to request input to the user one set of items at a time.

It is tricky since you cannot start a new command inside the on_input_changed(), because the input event has not completed at that moment; you have to use an user event to be fired after it, which will start the new command to request the following set of information.

 

I'd suggest to make a single command input with all the data you require the user to provide.  This way is easier and straightforward.

 

Regards,

Jorge Jaramillo

 

Message 7 of 7

Thanks.

I'll try something with that.

Brad Bylls

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