Get one objects position in another object's coordinate system?

 5 Days Ago mranim8or portfolio Get one objects position in another object's coordinate system? Is there a way in mel or python in maya to get one object's position in the coordinate system of another object?   I have a camera in a scene that may be rotated in any direction and am trying to measure the distance in its local Z axis to the vertexes of  various objects in the scene.  This obviously needs to be fast, since it will likely be run thousands of times across the scene. In Maxscript the command would be  something like   " in coordsys \$camera (" , but I have yet to find something like this in Maya.   If there's no direct command to do this, does anyone have a way to calculate it using matrix math? share quote
 4 Days Ago mlefevre Expert   ... United Kingdom I'm not aware of anything as succint as your maxScript example, but something like this might do the trick! `````` import maya.OpenMaya as om mSel = om.MSelectionList() mSel.add('myCam') dagPath = om.MDagPath() mSel.getDagPath(0, dagPath) invMatrix = dagPath.inclusiveMatrixInverse() mSel.add('myMesh') mSel.getDagPath(1, dagPath) iter = om.MItMeshVertex(dagPath) # Storage for positions points = om.MPointArray() points.setLength(iter.count()) while not iter.isDone(): # Multiply each vertex world position by cam inverse matrix points.set( iter.position(om.MSpace.kWorld) * invMatrix, iter.index()) iter.next() # Check points for i in range(points.length()): p = points[i] print p.x, p.y, p.z `````` __________________ vimeo blog share quote
 3 Days Ago mranim8or portfolio That works perfect thank you so much!! share quote

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts vB code is On Smilies are On [IMG] code is On HTML code is Off CGSociety Society of Digital Artists www.cgsociety.org Powered by vBulletinCopyright ©2000 - 2006, Jelsoft Enterprises Ltd.