[Bf-python] 3 quick questions

Campbell Barton ideasman42 at gmail.com
Wed May 18 20:08:45 CEST 2011


Nope, selection and active are separate. this is by design & intentional.

obj = bpy.data.objects["Cube"]
bpy.context.scene.objects.active = obj
obj.select = True

As for adding groups, generally when scripting you don't want
functionality to be mixed up with context the way it is with
operators.

You may add 10 groups, then objects to each one, in this case its
annoying to have to worry about what might be selected when your
scripting a setup like this.

In most cases python functions exist to create and remove data - since
its not normally that nice to do this from operators.

On Wed, May 18, 2011 at 4:47 PM, David Silverman
<silvermindyarr at gmail.com> wrote:
> It seems that the active object is set by your example, but it is not
> "selected". Is there a way that can do both?(selecting = set active object?)
>
> On Wed, May 18, 2011 at 7:50 AM, Bassam Kurdali <bkurdali at freefac.org>
> wrote:
>>
>> 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
>>
>>
>> _______________________________________________
>> Bf-python mailing list
>> Bf-python at blender.org
>> http://lists.blender.org/mailman/listinfo/bf-python
>
>
> _______________________________________________
> Bf-python mailing list
> Bf-python at blender.org
> http://lists.blender.org/mailman/listinfo/bf-python
>
>



-- 
- Campbell



More information about the Bf-python mailing list