Python: How to get object's true length? I need to calculate object's 'length factor', for example:




... To achieve this, I need to get object's true length:



... But the 'dimensions' vector contains dimensions of bounding box, so it's different when we e.g. rotate the object.
I have a code that will calculate the 'length factor' value, the only problem is that the 'dimensions' values are from bounding box, not from the object itself. Here's the code:

dimensions = list(ob.dimensions) 
maxDimension1 = max(dimensions)
dimensions.remove(maxDimension1)
maxDimension2 = max(dimensions)
lengthFactor = (maxDimension1/maxDimension2) - 1


I'd be grateful for some help.
You can use the below script to get the dimensions of the selected object:

x = bpy.context.object.dimensions[0]
y = bpy.context.object.dimensions[1]
z = bpy.context.object.dimensions[2]


which is controlled from the 3d view as shown below: