[Tutor] Difficulty Understanding Example Code for Blender Script

Andrew Martin amartin7211 at gmail.com
Fri Jul 23 19:48:49 CEST 2010


Oh ok. So orientation is an optional parameter. That makes sense. Alright
well thanks for the help

And yeah next time it would probably be better to try the blender forums.
thanks though

On Thu, Jul 22, 2010 at 3:06 AM, David Hutto <smokefloat at gmail.com> wrote:

> On Thu, Jul 22, 2010 at 2:47 AM, Marc Tompkins <marc.tompkins at gmail.com>
> wrote:
> > 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().
>
> Seeing as how blender is 3d graphics, have you tried the 'newbie
> fidget with it', and typed in w(quaternion),x, or y to see what
> occurs. Also, have you looked into the hierarchy to see if z, which
> looks as though it's contained in a string, is an input variable
> declared elsewhere as an integer, or represents something else in it's
> usage. Z can mean global, or object orientation in blender from what I
> see.
>
> >
> > Take a look at this section of the Python docs:
> >
> http://docs.python.org/tutorial/controlflow.html#more-on-defining-functions
> >
> > Hope that helps...
> >
> >
> > _______________________________________________
> > Tutor maillist  -  Tutor at python.org
> > To unsubscribe or change subscription options:
> > http://mail.python.org/mailman/listinfo/tutor
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100723/970b16c1/attachment.html>


More information about the Tutor mailing list