[Bf-committers] proposal: python interface for object statistics ...

Campbell Barton ideasman42 at gmail.com
Thu Mar 8 16:57:45 CET 2012


Why do you want this?

The problem with API functions is, inlike the text display which is
more of a `Useful Hint on Scene info` API calls are expected to be
exact data - eg - you can allocate memory based on this info and know
your arrays will hold the data - this makes me cautious to add in such
functionality since you cant always reliably know this info ahead of
time.

Adding an rna function say ob.display_statistics() isnt especially
hard - it can return array sizes from C's ob->derivedFinal
DerivedMesh.

What I find a bit of a worry is that once added you run into some
cases that might mean display_statistics() has to include annoying
exceptions.

---

* ob->derivedFinal isnt _always_ used. not in weight paint for
example, should the function be aware of modes and when to use
ob->derivedFinal or ob->derivedDeform?

* If this number becomes used in areas where its really important to
be accurate - eg - if the object is exported this has exactly the same
number of faces. This might not always work as the script author
expects. then we get complaints that blender tells lies.

* Objects may not always have tesselated geometry, objects may not
always have valid derived mesh - some of this stuff is lazy
initialized.

* Once added scripters may want this for curves, meta-balls - text
etc. can be done, just more code to support an obscure function?

On Fri, Mar 9, 2012 at 2:26 AM, Gaia Clary <gaia.clary at machinimatrix.org> wrote:
> hi.
>
> Blender currently exposes the number of vertices/edges/faces
> of the current visible scene. If i want to know the number
> of faces actually used for a single object (after modifiers
> have been applied!), then currently i have to do this:
>
> - move the object to an empty layer
> - switch to this layer
> - read the face count of the object in the top menu bar
>
> The above procedure could be automated by creating
> a python script which mimics that behaviour.
> But this is an ugly solution because i have to find an empty
> layer first, then move the object around just to get that number.
>
> I know, i could calculate that number by creating a copy of the
> object mesh, apply the modifiers and then examine the resulting
> mesh object. But that sounds like very inefficient to me.
>
> A nice alternative would be to provide the values per Object either
> as object properties or via a python function. I would be interested
> in getting efficient access to:
>
> - number of faces of an object (taking modifiers into account)
> - number of vertices of an object (taking modifiers into account)
>
> It would be nice if these values where available in Edit mode and
> in object mode.
>
> Furthermore i propose to add a function:
>
> bpy.context.scene.statistic_info()
>
> which shall return a dictionary containing the statistics information
> that is currently provided as string by bpy.context.scene.statistics()
>
> Would these features be problematic to implement ?
>
> best wishes
> Gaia
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at blender.org
> http://lists.blender.org/mailman/listinfo/bf-committers



-- 
- Campbell


More information about the Bf-committers mailing list