Jump to content
Sign in to follow this  

[SOLVED] [Python] Get Manipulator Handles Coordinates?

Recommended Posts


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:

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


Edited by bentraje

Share this post

Link to post
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]
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

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this