Jump to content

Recommended Posts

Hi! :)

Sorry if this is a basic question, I am very new to HDK and Houdini itself, I am starting to get the taste of it but I have some questions:

I want to create a custom SOP with a "built-in" switcher, here is my code:


//I tried to copy from the euclid/SOP_Euclid example, I have this func in my header(this should ask houdini if the checkbox is ticked):

bool SWITCH(fpreal t) { return (bool)evalInt(0, 0, t); }


//Here I set up the Toggle param

static PRM_Name names[] = {

static PRM_Default  elevationDefault(500.0);

PRM_Template MySOP::myTemplateList[] = {
	PRM_Template(PRM_STRING,    1, &PRMgroupName, 0, &SOP_Node::pointGroupMenu,	0, 0, SOP_Node::getGroupSelectButton(GA_GROUP_POINT)),
	PRM_Template(PRM_TOGGLE,	1, &names[1]),


OP_ERROR MySOP::cookMySop(OP_Context& context)
	OP_AutoLockInputs inputs(this);
	if (inputs.lock(context) >= UT_ERROR_ABORT)
		return error();
	fpreal t = context.getTime();

	bool switcher = SWITCH(t);
	//Do something with my object...
	//Then here i want to make the switcher, my first idea was to make a PRM_TOGGLE param, and using it as a bool(like in the Euclid e.g), 
	//so for example if it's ticked, I want to move my object, if it isn't, I want to make it bigger (I know its a bad e.g: but I hope you get it)
		//move my object
		//make it bigger



It compiles, but crashes Houdini with a seg. fault and I don't know what is the problem :(

Also, let me know if there is a better way of making a switcher :)


Share this post

Link to post
Share on other sites

just a quick look:

1 hour ago, daniel.fodor said:

static PRM_Name names[] = { PRM_Name("switch","Switch"), };


PRM_Template(PRM_TOGGLE, 1, &names[1]), // <-- shouldn't  be '0' here?


Share this post

Link to post
Share on other sites

Thank you Symek, that fixed the crash!
Although the checkbox doesn't do anything(I tried to translate some points if it's checked) :(
Any ideas on that?

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