Discussion:
[Bf-python] displaying current scene fps in addon preference?
flavio soares
2014-02-07 15:58:49 UTC
Permalink
Hello,

In an addon with preferences, is there a way of displaying the project's
current scene fps inside a box as default, instead of some fixed number?

This is the image of the preferences
box<Loading Image...>
.

The current code is this:

prop_fps = FloatProperty(
name="FPS (Beware!)",
description="Transcoded videos will have this FPS - \
this *MUST* be the same as your project",
default=24.00
)


The idea would be to show the result of this:

render = bpy.context.scene.render
fps = round((render.fps / render.fps_base), 3)


Just in case, full code is
here<https://github.com/szaszak/blender_velvets/blob/master/velvet_revolver.py>,
addon is already functional.

thanks for the help!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.blender.org/pipermail/bf-python/attachments/20140207/3b17be3f/attachment.htm
CoDEmanX
2014-02-07 16:29:39 UTC
Permalink
Hi,

if it MUST be the same as in the project, why do you add it as property
to the panel in the first place???

You could simply display it to the user as a note, e.g.

render = context.scene.render
fps = render.fps / render.fps_base
layout.label("FPS: %.3f" % fps)


BTW: to do the rounding on a FloatProperty just for display (value
remains the same internally, it's only a display option up to how many
decimal places shall show), do:

FloatProperty(..., precision=3)


You could also add the fps property/properties of the scene to your
panel, e.g.

layout.prop(context.scene.render, "fps")

Changes here will be the same as to directly in the render settings.


Or set your own FloatProperty to the scene's fps (or whatever) on invoke:

http://www.pasteall.org/49343/python
Post by flavio soares
Hello,
In an addon with preferences, is there a way of displaying the project's
current scene fps inside a box as default, instead of some fixed number?
This is the image of the preferences box
<http://florestavermelha.files.wordpress.com/2014/02/revolver.jpg>.
prop_fps = FloatProperty(
name="FPS (Beware!)",
description="Transcoded videos will have this FPS - \
this *MUST* be the same as your project",
default=24.00
)
render = bpy.context.scene.render
fps = round((render.fps / render.fps_base), 3)
Just in case, full code is here
<https://github.com/szaszak/blender_velvets/blob/master/velvet_revolver.py>,
addon is already functional.
thanks for the help!
_______________________________________________
Bf-python mailing list
Bf-python at blender.org
http://lists.blender.org/mailman/listinfo/bf-python
flavio soares
2014-02-07 17:01:01 UTC
Permalink
Hi, CodemanX,

why do you add it as property to the panel in the first place???
Post by CoDEmanX
layout.prop(context.scene.render, "fps")
Those definitely are great suggestions! And you are right!

I was trying to find this solution you sent but wasn't being able to. So I
decided to finish the addon the way it was before asking. =)

I'll implement it now, thanks a lot for the ideas and explanations! =)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.blender.org/pipermail/bf-python/attachments/20140207/979501b6/attachment.htm
Loading...