Jump to content

Python 17.0 vs 17.5 'destroy' and deleteItems' error


berkhak

Recommended Posts

Hi gents, 

I have been having trouble figuring this out; so I have 2 ways of deleting children of a subnet/object network with python and they both work in H17.0.352 but I am getting the following errors in H17.5.285:

 

For 'destroy' within a loop:


Error 
Python error: Traceback (most recent call last):
File "", line 17, in 
File "", line 14, in destroy_geo
File "C:/PROGRA~1/SIDEEF~1/HOUDIN~1.285/houdini/python2.7libs\houpythonportion\ui.py", line 850, in decorator
return func(*args, **kwargs)
File "C:/PROGRA~1/SIDEEF~1/HOUDIN~1.285/houdini/python2.7libs\hou.py", line 9715, in destroy
return _hou.Node_destroy(*args)
OperationFailed: The attempted operation failed.
Cannot delete nodes while cooking

For 'deleteItems':

Python error: Traceback (most recent call last):
File "", line 13, in 
File "", line 8, in clean_stale_geometry
File "C:/PROGRA~1/SIDEEF~1/HOUDIN~1.285/houdini/python2.7libs\hou.py", line 9125, in deleteItems
return _hou.Node_deleteItems(*args)
OperationFailed: The attempted operation failed.
Cannot delete nodes while cooking

 

 

Here is the script and the hip folder: 

#Destroy
node = hou.pwd()
geo = hou.node('/obj/' + str(node.parent()))
objimport = hou.node('/obj/' + str(node.parent()) + '/IMPORT_GLTF')


def list_geometry_imports( subnet ):
    list = []
    for n in subnet.allSubChildren():         
        list.append(n)
    return list
    
def destroy_geo(list):
    for n in list:
        n.destroy()
    
    
destroy_geo(list_geometry_imports(objimport))


#DeleteItems
node = hou.pwd()
geo = hou.node('/obj/' + str(node.parent()))
objimport = hou.node('/obj/' + str(node.parent()) + '/IMPORT_GLTF')


def clean_stale_geometry( subnet ):
    #print '\t' + str(subnet.children())
    subnet.deleteItems( subnet.children() )
    
    
    
    
clean_stale_geometry(objimport)

 

I need a fresh pair of eyes; please let me know if you have any ideas about why this is not working in 17.5. I didn't had much luck with the interweb...

Thank you,

Berk.

 

 

 

 

 

 

 

python_deleteItems_test.hip

Link to comment
Share on other sites

I found a solution for my case: I wanted a python node to destroy a specific node.
I created a parameter button on another node, with a callback script that would destroy the node on button press.
Then I called the parm button inside the python node and invoked .pressButton()

Every time the python cook it will try to press the button.
It seems to be important to have both nodes (python and button node) disconnected from each other, otherwise it would trigger again the same error.

See attached file, maybe can help you

Cheers

python_destroyItem.hiplc

Edited by Andr1
Link to comment
Share on other sites

  • 1 month later...

Yes, I happen to separate the actions as well. It does seem like Side Effects tag this behavior to a illegal operation. 

This env variable will stop the error from popping up but I dont think it is recommended: 

HOUDINI_ERROR_ON_ILLEGAL_NODE_EDITS := 1

 

 

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...