# Finding the length of the contents of a group

 02 February 2011 mrp86 New Member portfolio Pete Chapman TD Manchester, United Kingdom Finding the length of the contents of a group I'm trying to work out if there is a better way to get the dimentions of the contents of a group. At the moment I can select the two objects at the extremities, and then assign locators and create a distance dimension node, what I want to be able to do is select the group and return a float value of the total length in the X and Y axis. Kind regards, Pete share quote
 02 February 2011 pixelranger Vertex Pusher   portfolio André Hitsoy London, United Kingdom Try this. Should work on meshes, groups, anything, really, including multiple selections: `````` string \$sel[] = `ls -sl`; string \$evalItems[] = {}; for (\$each in \$sel){ string \$transforms[] = `listRelatives -c -ad -typ "transform" \$each `; if (`nodeType \$each` == "transform"){ \$transforms[size(\$transforms)] = \$each; } for (\$transform in \$transforms){ string \$shapes[] = `listRelatives -s \$transform`; if (`size(\$shapes)`!= 0){ \$evalItems[size(\$evalItems)] = \$transform; } } } // print(\$evalItems) float \$bBminX[] = {}; float \$bBmaxX[] = {}; float \$bBmaxY[] = {}; float \$bBminY[] = {}; float \$bBmaxZ[] = {}; float \$bBminZ[] = {}; for (\$each in \$evalItems){ float \$bB[] = `polyEvaluate -b \$each`; \$bBminX[size(\$bBminX)] = \$bB[0]; \$bBmaxX[size(\$bBmaxX)] = \$bB[1]; \$bBminY[size(\$bBminY)] = \$bB[2]; \$bBmaxY[size(\$bBmaxY)] = \$bB[3]; \$bBminZ[size(\$bBminZ)] = \$bB[4]; \$bBmaxZ[size(\$bBmaxZ)] = \$bB[5]; } float \$bBminXSorted[] = `sort \$bBminX`; float \$bBmaxXSorted[] = `sort \$bBmaxX`; float \$bBminYSorted[] = `sort \$bBminY`; float \$bBmaxYSorted[] = `sort \$bBmaxY`; float \$bBminZSorted[] = `sort \$bBminZ`; float \$bBmaxZSorted[] = `sort \$bBmaxZ`; float \$totalMinX = \$bBminXSorted[0]; float \$totalMaxX = \$bBmaxXSorted[size(\$bBmaxXSorted)-1]; float \$totalMinY = \$bBminYSorted[0]; float \$totalMaxY = \$bBmaxYSorted[size(\$bBmaxYSorted)-1]; float \$totalMinZ = \$bBminZSorted[0]; float \$totalMaxZ = \$bBmaxZSorted[size(\$bBmaxZSorted)-1]; float \$width = abs(\$totalMaxX - \$totalMinX); float \$height = abs(\$totalMaxY - \$totalMinY); float \$length = abs(\$totalMaxZ - \$totalMinZ); float \$diagonalMinMaxXY = sqrt(pow(\$width,2) + pow(\$height,2)); float \$diagonalMinMaxXYZ = sqrt(pow(\$diagonalMinMaxXY,2) + pow(\$length,2)); print ("Width (X) is " + \$width + ".\n"); print ("Height (Y) is " + \$height + ".\n"); print ("Length (Z) is " + \$length + ".\n"); print ("The 2d distance from minX,minY to maxX,maxY is " + \$diagonalMinMaxXY + ".\n"); print ("The 3d distance from minX,minY,minZ to maxX,maxY,maxZ is " + \$diagonalMinMaxXYZ + ".\n");`````` __________________ ------------------------------------------------------ blog ----- portfolio share quote
 02 February 2011 CGTalk Moderation Expert Thread automatically closed 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. __________________ CGTalk Policy/Legalities Note that as CGTalk Members, you agree to the terms and conditions of using this website. 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.
Forum Jump
 Please select one User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home -------------------- Gallery     Latest Entries     Featured 2D     Featured 3D     CG Awards     Community Awards Main     News     General Discussion     Off Topic     Recruitment         Temp Job Board Challenges     Rival Crimson X Chaos     Education     Demo Reel     Portfolio Review GROUPS WIP ADVICE     Pro Select     Art Direction and Interviews     New 2D/3D Sketchbooks 2018     WIP 2D/3D & Animation         WIP/Critique: 3D         WIP/Critique: 2D             Speedpaints & Sketchbooks         WIP/Critique: Animation     Partners and Groups         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     Allegorithmic Substance         Substance Designer         Substance Painter         Substance Featured Gallery     Texturing XYZ     Mari     Marmoset Toolbag Software     Maxon Cinema 4D         Cinema 4D Resources     Side Effects Houdini     Compositing Software         The Foundry Nuke         Adobe After Effects         Autodesk Effects and Compositing         Eyeon Software Digital Fusion     Additional Software         Lightwave 3D             LW Resources             LW Tutorials         The Foundry Modo             The Foundry Time Travel Challenge         E-on Software Vue         Photoshop / Painter         Blender         3DCoat 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         Lighting Challenges     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     Workstation Builds     Game Engine     Graphics Programming     Technical and Hardware CGS Labs     Sketchbooks     Hardcore Crit     Discussions and Meet Ups
Miscellaneous

All times are GMT. The time now is 10:50 PM.