[Tutor] Difficulty Understanding Example Code for Blender Script
Marc Tompkins
marc.tompkins at gmail.com
Thu Jul 22 08:47:57 CEST 2010
On Wed, Jul 21, 2010 at 9:48 PM, Andrew Martin <amartin7211 at gmail.com>wrote:
> This code was part of a Blender script to build a 3d bar graph, so I don't
> know if understanding Blender is a prereq for understanding this code. The
> function is for the axis labels.
>
> def label(text,position,orientation='z'):
> txt=Text3d.New('label')
> txt.setText(text)
> ob=Scene.GetCurrent().objects.new(txt)
> ob.setLocation(*position)
> if orientation=='x':
> ob.setEuler(-pi/2.0,0,0)
> elif orientation=='z':
> ob.setEuler(0,0,pi/2.0)
> print 'label %s at %s along %s' %(text,position,orientation)
>
> I understand it for the most part except for the orientation part. I
> assume orientation is for the 3d text object, but how is it determined
> whether it is x or z?
I don't use Blender myself, so this will be a more generic, high-level
answer...
> def label(text,position,orientation='z'):
>
This definition specifies that label() takes two mandatory parameters - text
and position - and one optional parameter, orientation. What makes
"orientation" optional is the fact that a default value is supplied:
"orientation='z'". In other words, "orientation" is equal to "z" unless you
specify otherwise in your call to label().
Take a look at this section of the Python docs:
http://docs.python.org/tutorial/controlflow.html#more-on-defining-functions
Hope that helps...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100721/b69d4aad/attachment.html>
More information about the Tutor
mailing list