[Bf-committers] PyRNA type definition changes (postpone beta until end of week)

Campbell Barton ideasman42 at gmail.com
Thu Sep 9 07:52:49 CEST 2010

On Thu, Sep 9, 2010 at 2:41 AM, Bassam Kurdali <bkurdali at freefactory.org> wrote:
> Hi Campbell
> <--snip>
>> Another change to help our api be less confusing is to have operator
>> properties directly accessible.
>> class Operator(bpy.types.Operator):
>>     myprop = bpy.props.BoolProperty()
>>    def execute(self, context):
>> ... this line
>>         print(self.properties.myprop)
>> ...could be written as
>>         print(self.myprop)
>> At the moment print(self.myprop) will print the property definition,
>> but not the property (which is what you want!)
>> I'd like to keep self.properties available since its how operators
>> work internally and can be passed as keyword arguments, so this change
>> is mostly for convent access.
> The question that came to mind here (as I mentioned on irc) is that if
> you *did* want to print/access the property definition, how would you do
> so if self.myprop just returns the value?
> cheers
> Bassam
> PS- thanks for the mail, it cleared up some things that had been long
> confusing me re. the api.

operators define StructRNA types once registered so you can do...

>>> bpy.types.IMPORT_SCENE_OT_obj.bl_rna.properties["ROTATE_X90"]
<bpy_struct, BooleanProperty("ROTATE_X90")>

just like...
>>> bpy.types.Scene.bl_rna.properties["frame_start"]
<bpy_struct, IntProperty("frame_start")>

having bl_rna is ugly but needed ATM since the python class and the
rna type a different (perhaps they could be made into the same type
but its not trivial).

More information about the Bf-committers mailing list