Saturday, 2 March 2013

Bounding Box Dimensions

Scenario
  • you want to measure an object's dimensions
  • the object is rotated
  • the Measure utility does not provide consistent dimensions for rotated objects :(
Usage
  • select an object
  • run script
  • message box is shown, displaying dimensions
  
  
-- MixeScript snippet: bounding box dimensions
-- displays a message box giving the selected object(s) dimensions

--USAGE
-- select an object
-- run script
-- message box is shown, displaying dimensions

if selection.count == 1 then 
(
 originalrotation = $.rotation
 originalposition = $.position
 $.rotation = (quat 0 0 0 0)
)

XDimension = ($.max.x - $.min.x)
YDimension = ($.max.y - $.min.y)
ZDimension = ($.max.z - $.min.z)
XYDimension = ((XDimension * XDimension) + (YDimension * YDimension)) ^ 0.5
XYZDimension = ((XYDimension * XYDimension) + (ZDimension * ZDimension)) ^ 0.5
XYArea = XDimension * YDimension
Volume = XDimension * YDimension * ZDimension

XString = "X = " + (XDimension as string)
YString = "Y = " + (YDimension as string)
ZString = "Z = " + (ZDimension as string)
XYString = "XY = " + (XYDimension as string)
XYZString = "XYZ = " + (XYZDimension as string)
XYAreaString = "XY Area = " + (XYArea as string)
VolumeString = "Volume = " + (Volume as string)

messagestring = "Bounding Box Dimensions: \n \n" + XString +  "\n" + YString +  "\n" + ZString +  "\n \n" + XYString +  "\n" + XYZString + "\n \n" + XYAreaString + "\n" + VolumeString

if selection.count == 1 then 
(
 $.rotation = originalrotation
 $.position = originalposition
)

messagebox(messagestring)
  

No comments:

Post a Comment