0
$\begingroup$

i want to create a driver that uses an object's volume (not scale) to determine the size of another object.

I know the volume of the object, as i got it from the '3D-Print Toolbox' built-in addon, but when i calculate the volume of the object i can't right-click on it to obtain the data path, so i can't use it for a driver.

if anybody could help me find the right data path or provide a workaround that would be greatly appreciated.

$\endgroup$
3
  • 1
    $\begingroup$ The scale is a property of the object, but there is no volume property and no data path. The 3D Print Toolbox add-on calculates it. If you check the source code you can see that it takes the unit and scale into account, creates a temporary copy with all the modifiers applied, and then uses the bmesh API method bm.calc_volume() to get the final result. I guess you could do something similar with a driver. Just make sure you call bm.free() to prevent memory leaks. (There are a few answers where it's missing.) $\endgroup$
    – Blunder
    Commented Apr 11 at 12:04
  • $\begingroup$ i don't really know enough about python in blender to do that, are than any other ways to find the 'true' size of an object? $\endgroup$
    – Photekh
    Commented Apr 12 at 7:05
  • $\begingroup$ Looks like you cannot run the Python script as a driver expression. But you can make it a custom function and register it (blender.stackexchange.com/q/51530/107598). There are two flaws: 1) bmesh.calc_volume() is a slow function and you get a warning about this. It seems to be stable if you ignore the scale and modifiers, and the mesh is not too complex. 2) you have to run the script and then update the driver each time you open the blend file. Maybe you could create a little add-on that provides the custom driver function. $\endgroup$
    – Blunder
    Commented Apr 12 at 20:06

1 Answer 1

0
$\begingroup$

For a simpler solution, you can obtain the Dimensions of an object from the side bar (accessible through shortcut N).

In a driver, the data path is dimensions[0] for X, dimensions[1] for Y, and dimensions[2] for Z.

Multiplying these together is a good approximation for volume, depending on the complexity of the mesh, and is a good way for determining the 'true' size of an object.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .