CGTalk how to get local bounding box values?
 12-16-2012, 06:12 PM #1 cgbeige Expert   portfolio Dave Girard Opinions are mine. You can't have them. San_Francisrococo, USA   Join Date: Jul 2005 Posts: 7,001 how to get local bounding box values? I'm making a simple pivot toolbox and have it set up for world space bbox coordinates but I'm wondering how to get these values as something that can be input into the xform -piv command: That's an arbitrarily rotated object so world space doesn't work and querying/setting object space sets the pivot in the wrong spot. I want to be able to set the pivot to any point on the local bounding box (mid, min, max). I realize Local Tools does this but I just want to know for myself __________________ blog | Twitter | www.can-con.ca | 101 Autodesk Maya Tips for Kindle, EPUB/PDF or iPad edition share quote
 12-16-2012, 08:26 PM #2 zaskar Expert portfolio franky****inFourFingaz - Dresden, Germany   Join Date: Dec 2010 Posts: 321 Now you have the shape node with its local bounding box information and the transformation matrix of the parent transform. With both you can calculate the world space points of the local bbox midpoints as you sketched. Either use some python api or faster, use mel: Code: ```{ string \$sel[] = `ls -sl`; string \$shape[] = `ls -dag -shapes \$sel[0]`; string \$mat = `createNode pointMatrixMult`; connectAttr (\$sel[0] + ".worldMatrix") (\$mat + ".inMatrix"); float \$bbOSMin[] = `getAttr (\$shape[0] + ".boundingBoxMin")`; float \$bbOSMax[] = `getAttr (\$shape[0] + ".boundingBoxMax")`; //midPoint of +z float \$zPositive[] = {((\$bbOSMin[0] + \$bbOSMax[0]) * .5),((\$bbOSMin[1] + \$bbOSMax[1]) * .5),\$bbOSMax[2]}; setAttr (\$mat + ".inPoint") \$zPositive[0] \$zPositive[1] \$zPositive[2]; float \$result[] = `getAttr (\$mat + ".output")`; print \$result; delete \$mat; }``` share quote
 12-17-2012, 03:26 PM #3 cgbeige Expert   portfolio Dave Girard Opinions are mine. You can't have them. San_Francisrococo, USA   Join Date: Jul 2005 Posts: 7,001 thanks - it was more work than I thought it would be so this is a big help. __________________ blog | Twitter | www.can-con.ca | 101 Autodesk Maya Tips for Kindle, EPUB/PDF or iPad edition share quote
 12-17-2012, 05:35 PM #4 cgbeige Expert   portfolio Dave Girard Opinions are mine. You can't have them. San_Francisrococo, USA   Join Date: Jul 2005 Posts: 7,001 ok - I seem to be almost there but these min/max values aren't correct for some reason - the mid ones work fine. If you can figure out where I'm wrong, it would be great. This is the first time I'm dealing with matrixes for stuff like this. Code: ``` //START LOCATION BBOX proc string \$sel[] = `ls -sl`; //do the X coords switch(\$currentXPivotMenuSelection) { case "min": for (\$n=0 ; \$n
 12-17-2012, 08:38 PM #5 zaskar Expert portfolio franky****inFourFingaz - Dresden, Germany   Join Date: Dec 2010 Posts: 321 Hard to explain what the failure in your code above is, english isnt my favourite language. So here is a simplified but fully working version of your code: Code: ```string \$sel[] = `ls -sl`; for (\$n=0 ; \$n
 12-17-2012, 09:03 PM #6 cgbeige Expert   portfolio Dave Girard Opinions are mine. You can't have them. San_Francisrococo, USA   Join Date: Jul 2005 Posts: 7,001 awesome - thanks. This works great. __________________ blog | Twitter | www.can-con.ca | 101 Autodesk Maya Tips for Kindle, EPUB/PDF or iPad edition share quote
 12-17-2012, 09:03 PM #7 CGTalk Moderation Lord of the posts   Join Date: Sep 2003 Posts: 1,066,481 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