Button Toggle ON/OFF Display Face Center Point

   2428   4   0
User Avatar
Member
41 posts
Joined: Dec. 2019
Offline
I use Attribute Wrangle for add point on primitive centers ,But the problems When I select components point,the center point turn Integer in selection,I want just display face center only for snaping.


Like Ex Maya Display face centers


Is there A Python to create to shelf,To Display global display face center in scene not Usign each Attribute wrangle.
User Avatar
Member
387 posts
Joined: Nov. 2008
Offline
There isn't a feature for snapping to primitive centers in Houdini 18.0 afaik. But you can request it: https://www.sidefx.com/bugs/submit/ [www.sidefx.com]


To create a temporary node and then remove it you can use python for creating template node and then bind createCenterPointsNode() and removeHelperNode() function calls to shortcuts.

This is very simple example that selects first selected node (it expects SOP node selection) and creates a templated wrangle node and stores its path in the context (parent) node.
Then calling removeHelperNode() with selection in the same context will try to delete the node at the stored path.
It remembers only single node for the context.

This is just a very simple example of one way how you can do it. Another way could be viewport states.

import hou

TEMP_NODE = "temp_wrangle_path"

def getCurrentNode(selected):
    selected = selected if selected else hou.selectedNodes()
    if not selected:
        print("Nothing selected!")
        return None

    input = selected[0].inputs()
    if not input:
        current = selected[0]
    else:
        current = input[0]
    return current

def createCenterPointsNode(selected=None):
    current = getCurrentNode(selected)
    if not current:
        return None

    aw = current.createOutputNode("attribwrangle", "__temp_prim_center_snap_helper__")
    aw.setTemplateFlag(1)   # tempalte flag for snapping
    aw.parm("class").set(1)
    aw.parm("snippet").set("addpoint(0, v@P);") # create center points
    aw.setComment("helper node for snapping to primitive centers")
    aw.setGenericFlag(hou.nodeFlag.DisplayComment, 1)
    
    context = current.parent()  # context
    context.setUserData(TEMP_NODE, aw.path())  # store path to the temporary wrangle
    return aw

def removeHelperNode(selected=None):
    current = getCurrentNode(selected)
    if not current:
        return

    context = current.parent()  # context
    aw = hou.node(context.userData(TEMP_NODE))
    aw.destroy()    # delete node
    context.destroyUserData(TEMP_NODE)

# usage:
createCenterPointsNode() # create helper
removeHelperNode() # remove helper
Edited by pezetko - Aug. 16, 2020 18:17:15

Attachments:
snap_prim_centers.gif (2.6 MB)

User Avatar
Member
41 posts
Joined: Dec. 2019
Offline
Thanks @pezetko,It's work,But if there A Button Toggle ON/OFF Display Face Center.
User Avatar
Member
679 posts
Joined: Feb. 2017
Offline
Hey snapag,

have you tried the shortcut : or Ctrl+; or Ctrl+:
It starts the orientation picking mode for transforms. It lets you snap to face centers.

Snapping Documentation [www.sidefx.com]

Cheers
CYTE
User Avatar
Member
41 posts
Joined: Dec. 2019
Offline
Already,I have idea How to snap in Houdini,I'm not Talking exactly snap to center,Ex:I want display center faces for A simple move object single Axis To middle face ,There Are snap middle edge in Houdini,For Me Turn snap point Work,And give idea display divide very quickly to move object,For snap middle edge work for something else.
  • Quick Links