[Bf-python] 3 quick questions

Bassam Kurdali bkurdali at freefac.org
Wed May 18 16:50:53 CEST 2011


On Tue, 2011-05-17 at 23:22 -0700, David Silverman wrote:
> *It seems that the active object is read only. Is there a way to
> select an object by name?
context is read only, but you can both change the active object and
select by name:
change active:
bpy.context.scene.objects.active = bpy.data.objects["Cube"]
by name:
myobj = bpy.data.objects["Cube"]
> 
> *What is the difference between:
>     bpy.ops.group.create(name= group_name)
> and
>     group = bpy.data.groups.new(group_name)
> (only the data one works...)
The first is an operator, i.e. a tool for users; it works on context
(you can create your own from inheriting from the operator class).
Context includes selection, which mode/space you are in, etc.
The operator works for me too, don't know the problem there.
> 
> *I have trouble exploring everything in the API using the console. Is
> there a good resource to browse that has all that help info with each
> item?
Yes:
1- console: command completion , python introspection 
2- Help->Python API Reference
3- Tooltips
4- right click on buttons -> copy data path
5- pull down the info window and wach/copy the operators that are echoed
there when you use the ui
6- Help-> Operator Cheat sheet
7- Text Editor, Text->Script Templates (lots of useful examples to start
from)
I may have missed some... maybe the #blenderpython irc channel on
freenode.
> 
> 
> Thanks in advance!
> David
> _______________________________________________
> Bf-python mailing list
> Bf-python at blender.org
> http://lists.blender.org/mailman/listinfo/bf-python





More information about the Bf-python mailing list