Jump to content

help with Custom shelf tool


McNistor

Recommended Posts

Hi guys,

I need a bit of help from someone python knowledgeable and willing, with a custom shelf tool that when clicked or called via a hotkey does the following:

creates two fuse SOP nodes from the current selection, the 1st one set on "snap" and the other on "consolidate". Other settings also modified, but unimportant right now.

I'd do it myself, but this is way too simple for my guru level of python and I don't have the time :)

Cheers!

Link to comment
Share on other sites

This is the best opportunity to start doing coding when you have a small particular task! Very different from following abstract programming tutorials.
Try to begin with creating of node — one Fuse SOP, then it would be easy to create 2, set their parameters and connections. Then you will wrap it in the shelf tool.

This code will create a Geometry node in scene root and then create a Fuse SOP inside Geometry node:

import hou

OBJ = hou.node('/obj/')
geometry = OBJ.createNode('geo')
fuse = geometry.createNode('fuse')

 

Edited by kiryha
Link to comment
Share on other sites

The opportunity to start doing coding (or anything else for that matter) is indeed by trying to complete a very small project. However there's one constant - time. Apart from the fact that I need this custom tool right now, there's the matter, in my case at least of resource management. See, I'm on a quest since a few yrs to become a very good creature/character artist (via sculpting as well as Sub-D), but I have roots in generalist 3d which I cannot cut loose apparently. The thing with knowledge in general is that if you don't use it, you lose it. At one point in my life, I was half-decent in c++, but almost everything about its syntax, quirks, tips, etc. went away because I stopped using it. Right now, I figured that learning Python would be a too big investment with possibly a too small ROI. Besides, right now I'm slowly but surely dipping myself in VEX. And I don't know lots of sculptors that can't sleep at night because they don't know VEX so adding python too right about now is a bit much for me :)

I'm laying down all this info, just in case someone's willing to help but is being put off by my apparent unwillingness to learn, which is and should be off-putting if no justified reasons are given.

Cheers!

Link to comment
Share on other sites

Create a Grid from the shelf, dive inside, select Grid SOP, run from Python Source Editor:

import hou

sel = hou.selectedNodes()[0]
parent =  sel.parent()
fuse_snap = parent.createNode('fuse', 'snap')
fuse_snap.moveToGoodPosition()
snap = fuse_snap.parm('switcher1')
snap.set(2)
fuse_consolidate = parent.createNode('fuse', 'consolidate')
fuse_consolidate.moveToGoodPosition()

fuse_snap.setInput(0, sel)
fuse_consolidate.setInput(0, sel)

 

Edited by kiryha
  • Thanks 1
Link to comment
Share on other sites

@kiryha It's not exactly what I need, but you've given me a good starting point. I guess it's time to dip my tows in Python and modify it to fit my needs. Don't know where I'll get this time from, but I'll try to squeeze it in somewhere.

Thanks.

Edit: no block comments in Python? Ay ayay, LOL

Edited by McNistor
Link to comment
Share on other sites

create a shelf tool with following python code

then click it, select the points and hit enter or select the points and then click it

import toolutils

def fuse_consolidate():

    selection = toolutils
    selection = selection.sceneViewer().selectGeometry()
    node = selection.nodes()[0]
    selection = selection.selectionStrings()
  
    
    selection = list(selection)
    string = " ".join(selection)
   
    #create fuse SOPs
    parent =  node.parent()
    snap = parent.createNode('fuse', 'snap')
    
    snap.setParms({'group': string, 'switcher1': 2, 'tol3d': 10})
    snap.setInput(0, node)
    
    fuse = parent.createNode('fuse', 'consolidate')
    fuse.parm('group').set(string)
    fuse.setInput(0, snap)
    
    snap.moveToGoodPosition()
    fuse.moveToGoodPosition()
    
    #set flags
    fuse.setSelected(1)
    fuse.setDisplayFlag(1)
    fuse.setRenderFlag(1)

fuse_consolidate()

 

Edited by 3dome
  • Thanks 2
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...