Jump to content

Python drag and drop


eunchae

Recommended Posts

 

Hi.

I would like to know the difference between using Python in the Python panel and the Houdini shelf tool.

For example, I'm trying to use the drag and drop feature, but it doesn't work with the Houdini shelf tool.

However, it is used in the Python panel.

Is there a way to use drag and drop in the Houdini shelf tool?

What I want is to drag and drop the node and enter the path in the blank.

 

Thank you.

Link to comment
Share on other sites

Do you mean the Python sop node by saying "Houdini shelf tool" ? 

If yes, this node is more likely to operate on geo by using the python api made to process geometry (https://www.sidefx.com/docs/houdini/hom/hou/Geometry.html). The python panel is made to use python for both geometry manipulation and nodes manipulation (basically all python ops in Houdini) but the python sop can't, it evaluates on geometry only.

 

If you want to create your own python to manipulate nodes, you can by following these steps :

- drag down a null

- add a string parameter named "code" and set it multiline/python

- add a button labelled "Run" and set its callback to python (dropdown menu at the end of the line) and type : exec(kwargs["node"].parm("code").eval())  

And you have your python code to execute code that manipulates nodes. I'm not sure if you can drag n drop a node path but you can do it in the python shell and then copy paste it into your python node.

 

Cheers,

Link to comment
Share on other sites

20 hours ago, DonRomano said:

Do you mean the Python sop node by saying "Houdini shelf tool" ? 

If yes, this node is more likely to operate on geo by using the python api made to process geometry (https://www.sidefx.com/docs/houdini/hom/hou/Geometry.html). The python panel is made to use python for both geometry manipulation and nodes manipulation (basically all python ops in Houdini) but the python sop can't, it evaluates on geometry only.

 

If you want to create your own python to manipulate nodes, you can by following these steps :

- drag down a null

- add a string parameter named "code" and set it multiline/python

- add a button labelled "Run" and set its callback to python (dropdown menu at the end of the line) and type : exec(kwargs["node"].parm("code").eval())  

And you have your python code to execute code that manipulates nodes. I'm not sure if you can drag n drop a node path but you can do it in the python shell and then copy paste it into your python node.

 

Cheers,

 

Thanks for your answer.

But I don't think that's what I want. It is not the Python sop node.

I want to use the drag and drop function That doesn't work.

I want to do it like the one at the address below.

But when I load that, it works only in the "python panel" If I copy and paste that into the shelf tool, it does not work.

-> https://www.sidefx.com/docs/houdini/examples/python_panels/dragdrop.html

(The shelf tool I'm talking about is at the top of Houdini.)

Link to comment
Share on other sites

45 minutes ago, DonRomano said:

I don't understand what you're trying to do. You want to create a shelf tool to drag and drop a node, but where ? And what's the purpose of doing that ?

Have a look here it may help : https://www.sidefx.com/docs/houdini/hom/state_dragdrop.html

Sorry for the lack of explanation.

I want to drag the node to the UI I created. (Path will go in.. ex- /obj/phantom )

Thanks for the answer.

1500_getImage.png

Link to comment
Share on other sites

I'm pretty sure it's not possible to do this for now, you have to create your ui into a python panel to be able to use the drag n drop feature. What you may do to solve this is to create a button where you can call the selected node and add it into your line parameter.

You can get the current selected node path with :

nodes = hou.selectedNodes()
selected_node = nodes[0].path()

 

Cheers, 

Link to comment
Share on other sites

  • 3 weeks later...
On 2020. 4. 3. at 6:38 PM, DonRomano said:

I'm pretty sure it's not possible to do this for now, you have to create your ui into a python panel to be able to use the drag n drop feature. What you may do to solve this is to create a button where you can call the selected node and add it into your line parameter.

You can get the current selected node path with :


nodes = hou.selectedNodes()
selected_node = nodes[0].path()

 

Cheers, 

Thank you!

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