Jump to content

Delete DOP object with python


yongbin

Recommended Posts

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
Link to comment
Share on other sites

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. :)

Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • 1 month later...

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.

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...