View Full Version : finde the center of and edge loop
11-13-2010, 11:31 AM
Im having problems on writing a simple script in Python to create a locator on the center of a given edge loop.
Can someone help me?
If you know the MEL solution no problem, it will so much apreciated :)
Im trying to get the vertices info and then... im not sure where to go..
Thanks in advance!
11-13-2010, 01:39 PM
one simple way to do this would be to use polyEvaluate to get the bounding box of the given selection (your edge loop). You can then easily get the BB center by adding it's extends up and dividing by 2.
another very quick and simple method would be to switch to the move tool then just query the manip position (which will always be the center of selection by default).
I can post some example code if you really need any more, or do a seach here, as these have come up before I'm sure (certainly the manip one)
11-13-2010, 02:47 PM
Thanks for the hints Nathan :)
With your help I'll try to figer it out myself..! Hope I manage to do that, if not.. well, I'll post my doubts here.. :P
11-13-2010, 04:23 PM
you can query the manipMoveContect to get the centroid of your selection.
select a bunch of edges or vertices and run
vector $v = `manipMoveContext -q -p Move`;
spaceLocator -a -p ($v.x) ($v.y) ($v.z);
from maya import cmds as mc
mc.spaceLocator(p=mc.manipMoveContext('Move', q=True, p=True), a=True)
11-13-2010, 06:31 PM
Thank you mduvekot! :D
Following Nathan advice, I did made it to work on MEL..
setToolTo moveSuperContext; float $maninPos;
float $maninPos = `manipMoveContext -q -position Move`;
spaceLocator -p $maninPos $maninPos $maninPos;
but when tryed in python I was having an error, that "No move manipulator found"... but reading your script I think I was calling the command in the wrong way..
Many thanks to you both :D I will certainly win time and paticience with this few lines ;)
PD: python version, just missing "mc." in front of "xfom(cp=True)"), so last line would be : mc.xform(cp=True))
11-13-2010, 06:31 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.