Jump to content
Sign in to follow this  
yongbin

Delete DOP object with python

Recommended Posts

kare    2

node = hou.node("your_node_path")

node.destroy()

This snippet will delete your dop objects and any other network objects

Edited by kare

Share this post


Link to post
Share on other sites
graham    135

Unfortunately it would seem HOM does not have the ability to destroy simulation objects. You might be able to write an inlinecpp function that does this, but I haven't verified that such a thing is possible.

Share this post


Link to post
Share on other sites
graham    135

This inlinecpp function seems to work where you pass in your hou.DopNode and hou.DopObject:

bool
deleteDopObject(DOP_Node *node, SIM_Data *data)
{
    DOP_Parent *parent = node->castToDOPParent();

    if (!parent)
    {
        return false
    }

    SIM_Engine  &engine = parent->getNonConstEngine();

    if (data->getDataType() == "SIM_Object")
    {
        SIM_Object *obj = (SIM_Object *)data;

        engine.removeSimulationObject(obj);

        return true;
    }

    return false;
}

  • Like 1

Share this post


Link to post
Share on other sites
yongbin    20

Hi, graham. Thank you for sharing your knowledge!

I've tried import inlinecpp module and inlinecpp.createLibrary, but didn't success. Here is the code I tried.


deleteDopObject = inlinecpp.createLibrary(
name="cpp_del_dopobj",
includes="", # WHAT SHOULD I INCLUDE??
function_sources=["""
bool
deleteDopObject(DOP_Node *node, SIM_Data *data)
{
DOP_Parent *parent = node->castToDOPParent();
if (!parent)
{
return false
}
SIM_Engine &engine = parent->getNonConstEngine();
if (data->getDataType() == "SIM_Object")
{
SIM_Object *obj = (SIM_Object *)data;
engine.removeSimulationObject(obj);
return true;
}
return false;
}"""]
)
[/CODE]

I don't know what module should I include here. Maybe another problem could be also exist. What should I fix here?

Thank you. :)

Share this post


Link to post
Share on other sites
graham    135

You basically need to set the includes to include the headers for all the objects that need to be used. Something like this should probably work:

"""#include <DOP/DOP_Parent.h>
#include <DOP/DOP_Node.h>
#include <SIM/SIM_Data.h>
#include <SIM/SIM_Engine.h>
#include <SIM/SIM_Object.h>
"""

  • Like 1

Share this post


Link to post
Share on other sites
yongbin    20

I get it. Thank you graham. :lol:

Here is another question. What is different between SIM_Object and SIM_Data?

Because you converted it from object to data. I roughly guessing that it is same (almost?). Is it true?

Share this post


Link to post
Share on other sites
yongbin    20

Good news with this 13.0.268 release! I checked houdini journal and found this.

 

 

Houdini 13.0.268: Added hou.DopSimulation.removeObject and hou.DopRelationship.removeRelationship to remove objects or relationships from a DOP simulation.

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
Sign in to follow this  

×