[Bf-committers] Calling operators when drawing a panel
Lionel Zamouth - BE
lionel at zamouth.be
Sat Feb 5 14:25:37 CET 2011
Hi,
I'm writing here following a chat I had with Campbell about recent
changes that made impossible to call operators from the 'draw' section
of custom panels. He suggested I submit here my problems with this
behaviour.
This technique is used since a previous change where directly writing
into properties has been forbidden. I understand that bad coding could
lead to some deadlocks or infinite loops but having the ability for a
script to react to property changes is quite important and not
achievable otherwise due to the lack of callbacks (so far I know).
Here's the situation I'm facing: I've written an unofficial (both from
Blender and Refractive Software point of view) addon to allow smooth
export of blender scene/anim to the unbiased render Octane. From the
user perspective it consists of 3 custom panels, replacing the default
'render', 'material' and 'texture' ones. I'm proud to say it has became
quite popular and allows a nice workflow to happen.
The need for tracking properties is due to my wish to prevent the user
accessing or modifying values that can't be taken in account by Octane.
For instance the custom texture panel forces the type to 'Image',
coordinates to 'UV' and the Projection to 'Flat', as these are the only
values that can work with Octane (and are hidden by the custom panel).
Another example is the main 'render' panel automatically resetting the x
and y aspect ratio to 1 as Octane only renders square pixels. This last
one is very important for the camera view in Blender to match final
result in Octane.
Doing those operations in the 'draw' section may have some limitations
but seems to properly make the job (for instance I don't care if a user
loads an old scene with non proper values, I only expect my script to
fix these once they're presented to the panel - good enough for me).
According to Campbell it's seems there's no suitable workaround, so I'm
asking you don't prevent anymore operators to be called from the 'draw'
section of panels until callbacks are available (or may be you have a
working workaround available).
Cheers,
Lionel
More information about the Bf-committers
mailing list