alexxbb / hapi-rs

Idiomatic Rust bindings to Houdini Engine C API
MIT License
65 stars 7 forks source link

Question: How to render a ROP node? #13

Closed aryan-mann closed 1 year ago

aryan-mann commented 1 year ago

Hey @alexxbb, thanks a lot for working on this 🎉 ! Would you know if there's currently a way to send a render command to a ROP node (/out)? For context, I'm trying to output a GLTF file from a HIP. I've seen that it's possible via the Python API here: hou – RopNode but I couldn't figure out how to do it via Rust/the Houdini C Engine API.

Let me know if you have any ideas if this is possible. Cheers!

alexxbb commented 1 year ago

Hey Aryan, If by "send a render command to a ROP node" you mean pressing the Render button on it, then it's super easy. One simple way is if you export that button to your HDA parameters, then you can do:

if let Parameter:Button(parm) = node.parameter("render")? {
    parm.press_button()?
}

If you however build the nodes dynamically or have the ROP node somewhere inside you HDA, you can always find the node using the find methods. For example:

let handles = asset.find_children_by_type(NodeType::Rop, NodeFlags::Any, true).expect("List of nodes");
// assume we found one node 
let node = handles[0].to_node(session).unwrap();
if let Parameter:Button(parm) = node.parameter("render")? {
    parm.press_button()?
}

Let me know if that works. Cheers.

aryan-mann commented 1 year ago

🥇 That indeed did work @alexxbb, thanks for the detailed response.