Page 1 of 1

scripting "fit to object" connection?

Posted: Fri Sep 09, 2011 1:02 am
by redpawfx
How if at all can you do this?

an example would be the k_volume daemon has a button to "fit to object"
but there doesent seem to be a way to script that since the connection to the "object" seems to
not be something we have access to?

any ideas or are we out of luck?
thanks
Johnc

Re: scripting "fit to object" connection?

Posted: Tue Nov 22, 2011 11:52 am
by Alex
Hi Johnc,

for RealFlow objects there is a getBoundingBox() function that returns the minimum and maximum corner positions of the object bounding box.

From that point, making the k_volume (or whatever) transformation fit that box shouldn't be a big deal.

Code: Select all

(mincorner,maxcorner) = Cube01.getBoundingBox()

obj_scale = (maxcorner-mincorner)
obj_center = Vector.new()
obj_center += obj_scale
obj_center.scale( .5 )
obj_center += mincorner

k_Volume01.setParameter( "Position", obj_center )
k_Volume01.setParameter( "Scale", obj_scale )