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

 Thread Tools Search this Thread Display Modes
 11 November 2017 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
 11 November 2017 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
 11 November 2017 mranim8or portfolio That works perfect thank you so much!! share quote
 reply share thread

 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.
Minimize Ads
Forum Jump
 Please select one User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home -------------------- Gallery     Community Awards     Featured 2D     Featured 3D     Latest Entries     CG Awards Main     News     General Discussion     Featured Videos     Education     Off Topic     Recruitment         Temp Job Board Challenges     The Next Challenge     Lighting Challenges     Professional Feedback GROUPS WIP ADVICE     New 2D/3D Sketchbooks 2018     Art Direction and Interviews     WIP 2D/3D & Animation         WIP/Critique: 3D         WIP/Critique: 2D             Speedpaints & Sketchbooks         WIP/Critique: Animation     Kitbash 3D Thunderdome     Collaborative Projects Autodesk     Autodesk Maya         Maya Dynamics         Maya Rendering         Maya Character Setup         Maya Programming     Autodesk Miscellaneous         Autodesk MotionBuilder         Autodesk Mudbox         Autodesk Softimage             XSI: Programming             ICE: Interactive Creative Environment     Autodesk 3ds max         3dsMax Tutorials & Tips         3dsMax Resources         3dsMax SDK and MaxScript         Plugins & Add-ons         Particle Flow     Mudbox Featured Gallery ZBrush     Featured Zbrush Gallery     Pixologic ZBrush     Keyshot     Marvelous Designer Texturing     Mari     Texturing XYZ     Marmoset Toolbag     3DCoat     Allegorithmic Substance         Substance Designer         Substance Painter         Substance Featured Gallery Software     Maxon Cinema 4D         Cinema 4D Resources     The Foundry Modo         The Foundry Time Travel Challenge     Side Effects Houdini     Lightwave 3D         LW Resources         LW Tutorials     Blender     Photoshop / Painter     E-on Software Vue     Compositing Software         The Foundry Nuke         Adobe After Effects         Autodesk Effects and Compositing         Eyeon Software Digital Fusion Techniques     Art Techniques and Theories     Digital Matte Painting         Digital Matte Painting Mini-Challenge     Modeling         Modeling Challenge             Member Model Collection     Texturing and Surfacing     Character Rigging     Animation     Lighting and Shaders     Compositing and Editing     Anatomy and Figurative Art         SPOTLIGHT: Best of the Artistic Anatomy and Figurative Art Forum         Tutorials and Workshops         Personal Anatomy & Sketchbook Threads         References, Resources, and Supplies Technical     VR/AR     Master Virtual Reality with BrioVR     Game Engine     Graphics Programming     Technical and Hardware
Miscellaneous

All times are GMT. The time now is 08:22 AM.

Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.