[Bf-python] obj.setLocation(x, y, z) and obj.LocX=x don't seem to work

andrew2006 at flight.us andrew2006 at flight.us
Mon Oct 11 03:11:30 CEST 2010


 

On October 6, 2010 at 1:40 AM Goat Man <goatman.py at gmail.com> wrote:

> if the mesh is dynamic you need to call update.
> ob.getData().update()
> and its not a bad idea to remake the display lists
> ob.makeDisplayList()
> 
i discovered that bp appends a suffix to the base name you declare in
"current_scene.objects.new(mesh_name, 'mynewobjectname')"
 
where 'mynewobjectname' acquires a three-digit suffix (starting with ".001")
 
And to refer to the newly created object one must include the auto-assigned
prefix, like so:
 
Blender.Object.Get('mynewobjectname.001')
 
That is where my failure was, apparently, when trying to create the object
variable "obj": obj=Blender.Object.Get('cylmesh')
 
The correction, it seems, is obj=Blender.Object.Get('cylmesh.001')
 
1) Am I correct here?  (referring to the object with the ".001" appears to
target the object I want.
2) Is there a better way to refer to the new object?
3) Is there a way to find out what the autogenerated suffix is?  I don't want to
depend on some concurrent loop-incremented variable (independently/redundantly
created suffix), where, at some 23rd iteration, the creation of the mesh object
fails and my own suffixes no longer align with those created by the Object.Get
method. How can I capture/see what the new suffix is, explicitly?
 
thanks
 
a.
 
 
 

>
> On Wed, Oct 6, 2010 at 12:27 AM, Glen Pike <glen at engineeredarts.co.uk>wrote:
>
> >  Hmm,
> >
> >     Okay...
> >
> >     Not sure about dynamic meshes - check you are not still in Editing mode
> >
> > http://www.blender.org/documentation/249PythonDoc/Window-module.html#EditMode
> >
> >     1.    Try moving an object you have not created with a script - you
> > probably did that already.
> >     2.    Try placing your mesh at a non-zero location - might be a problem
> > when creating it.
> >     3.    When you get your mesh, can you see the location from
> > getLocation()?
> >
> >     Apart from that I can't really help much, sorry.
> >
> >     Glen
> >
> >
> >
> >
> > On 05/10/2010 17:09, andrew2006 at flight.us wrote:
> >
> >
> >  On October 5, 2010 at 3:38 PM Glen Pike
> ><glen at engineeredarts.co.uk><glen at engineeredarts.co.uk>wrote:
> >
> > >   You might need to call Blender.Redraw(-1)
> >
> >
> >
> > Tried Redraw(-1) -- no difference
> >
> >
> >
> >
> >  >
> > > http://www.blender.org/documentation/249PythonDoc/frames.html
> > >
> > >
> > >
> > > On 05/10/2010 16:27, andrew2006 at flight.us wrote:
> > > >
> > > > hi, all
> > > >
> > > > i am very new to both blender, python and blender python.
> > > >
> > > > I have a rudimentary script creating a mesh primitive (cylinder)
> > > >
> > > > I get the object handle like so: obj=Blender.Object.Get('cylmesh')
> > > >
> > > > then I do
> > > >
> > > > obj.setLocation(x,y,0.5)
> > > >
> > > > -- or, alternatively ---
> > > >
> > > > obj.LocX=x
> > > > obj.LocY=y
> > > >
> > > > (my "x" and "y" are non-zero)
> > > >
> > > > but the mesh stays at the origin
> > > >
> > > > the "setLocation()" call doesn't seem to have an effect, nor do the
> > > > "Loc[X,Y,Z]" assignments
> > > >
> > > > yet, there are no errors reported
> > > >
> > > > blender version: 2.49b
> > > >
> > > > tia
> > > >
> > > > andrew
> > > >
> > > >
> > > > _______________________________________________
> > > > Bf-python mailing list
> > > > Bf-python at blender.org
> > > > http://lists.blender.org/mailman/listinfo/bf-python
> > >
> >
> >
> > _______________________________________________
> > Bf-python mailing
> > listBf-python at blender.orghttp://lists.blender.org/mailman/listinfo/bf-python
> >
> >
> >
> > _______________________________________________
> > Bf-python mailing list
> > Bf-python at blender.org
> > http://lists.blender.org/mailman/listinfo/bf-python
> >
> >
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.blender.org/pipermail/bf-python/attachments/20101010/7c01f329/attachment.html>


More information about the Bf-python mailing list