Trying to pause 'for' loop

Trying to pause 'for' loop

brad.bylls
Collaborator Collaborator
1,217 Views
6 Replies
Message 1 of 7

Trying to pause 'for' loop

brad.bylls
Collaborator
Collaborator

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
0 Likes
Accepted solutions (2)
1,218 Views
6 Replies
Replies (6)
Message 2 of 7

jeff.pek
Community Manager
Community Manager

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

0 Likes
Message 3 of 7

brad.bylls
Collaborator
Collaborator

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
0 Likes
Message 4 of 7

Jorge_Jaramillo
Collaborator
Collaborator

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

 

0 Likes
Message 5 of 7

brad.bylls
Collaborator
Collaborator

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
0 Likes
Message 6 of 7

Jorge_Jaramillo
Collaborator
Collaborator
Accepted solution

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

 

0 Likes
Message 7 of 7

brad.bylls
Collaborator
Collaborator
Accepted solution

Thanks.

I'll try something with that.

Brad Bylls
0 Likes