Jump to content

[SOLVED] [Python] Get Manipulator Handles Coordinates?


bentraje

Recommended Posts

Hi,

Is there a way I can get the manipulator handles coordinates? (i.e. world space position)?
My use case for this is to create joints in the center of my selection. That's why I need the world space position.

The closest documentation I retrieved is this one:
https://www.sidefx.com/docs/houdini/hom/state_handles.html

But AFAIK, it is referring to binding manipulator handles to custom tools.

manipulator_handle.JPG

Edited by bentraje
Link to comment
Share on other sites

Oh, after rummaging through the documentation, there is no one method that does it.

So I got the manipulator handles by simply
1) Getting the selected points
2) Getting their position coordinates and dividing them by the total number of selected points.

You can check the sample script here:
 

import toolutils
selection = toolutils
selection = selection.sceneViewer().selectGeometry()

node = selection.nodes()[0]
geo = node.geometry()
points_patt = selection.selectionStrings(False)[-1]
geo.globPoints(points_patt)
pt_list = geo.globPoints(points_patt)

center_pos = [0,0,0]

idx = 0

for pt in pt_list:
    pos = pt.attribValue("P")

    center_pos[0] += pos[0]
    center_pos[1] += pos[1]
    center_pos[2] += pos[2]

    idx += 1

center_pos[0] = center_pos[0] /idx
center_pos[1] = center_pos[1] /idx
center_pos[2] = center_pos[2] /idx

print (center_pos)


 

Edited by bentraje
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...