Jump to content
berkhak

Python 17.0 vs 17.5 'destroy' and deleteItems' error

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

Share this post


Link to post
Share on other sites

I happen to have the same issue.

Did your eventually find a fix?

 

cheers

Share this post


Link to post
Share on other sites
Posted (edited)

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

Share this post


Link to post
Share on other sites

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

 

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×