# -------------------------
# Resize according to the distance
# between the'object named : "_resize" and the 'object
# "_master" .
# leThe script must belinked to teh obect resize in
# redraw mode.
#
# (c) jm soler, 09/2005
# ------------------------
import Blender
# ------------------------
# To reverseteh effect
# ------------------------
DIM=0
# ------------------------
# To preserve the original size
# ------------------------
ORIGINE=1
# ------------------------
# pick up the reciprocal locations
# ------------------------
[[x,y,z]]=[o.getLocation() for o in Blender.Object.Get() if o.name.find('resize')!=-1]
[[x1,y1,z1]]=[o.getLocation() for o in Blender.Object.Get() if o.name.find('master')!=-1]
distance=abs((x1-x)**2+(y1-y)**2+(z1-z)**2)**0.5
# ------------------------
# Allow to update values .
#
# Modify temporarily the value for 1
# When the modification is satisfactory
# We have to modify by hand
# to activate the automatic display of the size
# variation
# ------------------------
RENEW=0
try :
# ------------------------
# renew with an error
# error to oblige to passer by
# the except bloc
# ------------------------
if RENEW==1 :
error="renew"
raise error
# ------------------------
# value calculus
# ------------------------
if DIM: Size=distance/Blender.D
else: Size=Blender.D/distance
# ------------------------
# variable shortcut
# ------------------------
if ORIGINE: BS=Blender.Size[0]
else: BS=[0.0,0.0,0.0]
# ------------------------
# update of the values in the objects themselves
# ------------------------
[o.setSize(Size+BS[0],Size+BS[1],Size+BS[2]) for o in Blender.Object.Get()
if o.name.find('resize')!=-1]
# ------------------------
# end
# ------------------------
except:
# ------------------------
# values are reserved
# in the name space of the Blender module
# Not a good habit
# but framaticaly faster
# than the register module
# or to record on the disc
# We could use the space data of a neutral object like an
# empty
# ------------------------
Blender.D=distance
Blender.Size=[o.getSize() for o in Blender.Object.Get() if o.name.find('resize')!=-1] |