MatDuf Posted May 7, 2015 Share Posted May 7, 2015 (edited) Hi! I have a problem with what strikes me as a simple task. I made this simplified test setup (see image): 4 boxes in a geometry node all going into a merge node. I select the merge node and run the following python script from a shelf tool (Don't bother about the purpose of this... This is only to show my problem): myMerge=hou.selectedNodes()[0] toDel = [] myBoxes=list(myMerge.inputs()) print(myBoxes[0]) toDel.extend(myBoxes[0]) This will fail at the last line that is supposed to add a single member of the myBoxes list to the toDel list. It throws the error in the second image. What bothers me is that the print statement works appropriately but for some reason, the same structure doesn't work to add the item to the list. Am I just missing something?? Thanks! Edited May 7, 2015 by MatDuf Quote Link to comment Share on other sites More sharing options...
DannioMaundinio Posted May 7, 2015 Share Posted May 7, 2015 The extend function expects an iterable as it's argument. myBoxes[0] returns the SopNode object, rather than an iterable. You either need to change it to something like this: toDel.extend([myBoxes[0]]) or probably better to use this: toDel.append(myBoxes[0]) https://docs.python.org/2/tutorial/datastructures.html Quote Link to comment Share on other sites More sharing options...
MatDuf Posted May 8, 2015 Author Share Posted May 8, 2015 My mistake...! Thanks Dannio! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.