Forloop when creating add-in's inputs

Forloop when creating add-in's inputs

casey.rogers
Alumni Alumni
689 Views
1 Reply
Message 1 of 2

Forloop when creating add-in's inputs

casey.rogers
Alumni
Alumni

I have the following code (nonreelevant parts cut):

 

 

        class mmCommandCreatedEventHandler(adsk.core.CommandCreatedEventHandler):
            def __init__(self):
                super().__init__()
            def notify(self, args):
                cmd = args.command
                inputs = cmd.commandInputs

                for body in rootComp.bRepBodies:
                    if body.name[0:len(coreStr)] == coreStr:
                            selInput = inputs.addSelectionInput(body.name, 'Faces with alternate center \'%s\'' % body.name, 'Select faces to receive alternate center')
                            selInput.addSelectionFilter('Faces')
                            selInput.addSelectionLimits(0, 0)        

                # Connect up to command related events.
                onExecute = CommandExecutedHandler()
                cmd.execute.add(onExecute)
                handlers.append(onExecute)

For reasons I can't identify, if the body of the if loop is executed (string comparison returns true), the for loop is immediately exited and the lines starting with "# Connect up to command related eventss." are not executed. If the if loop isn't executed, the foor loop properly finishes and the final lines properly execute. I'm assuming that I'm missing something really silly, but I seriously can't figure out why this is happening. Does anyone else see what's going on?

 

0 Likes
Accepted solutions (1)
690 Views
1 Reply
Reply (1)
Message 2 of 2

casey.rogers
Alumni
Alumni
Accepted solution

Ugh, sorry for the stupid thread. I accidentally wrote "addSelectionLimits" instead of set, and I think I had some weird setup with a try except block that was unintentionally catching the error so I didn't notice it was happening....

0 Likes