[Bf-python] Some Recent Patches to BPython

Campbell Barton cbarton at metavr.com
Sat May 7 00:52:22 CEST 2005



Joseph Gilbert wrote:
> All the NMesh 'New' methods call new_NMesh_internal() which creates a 
> python representation of the C struct. I don't know how memory intenisve 
> this is, but it's prob not good for a large number of meshes. It's also 
> better to get the object instead of a list of names because of of the 
> getObject().setProperty() nature of python - OO is better imho. Of 
> course the way to solve that would be to get a pointer to Mesh* rather 
> than create the python mimic of the C data - which would require no huge 
> memory gobbling by python. There was a reason for doing it this way 
> though - (*cough* willian), I thought it was for speed in updating a mesh.
> This however is not the case with scene data. Scene data is represented 
> by a pointer to Scene*. Getting the pointer is trivial and should not 
> prevent people from getting a list of scene objects.
> Calling Scene.getActive().name is not a problem....
> 
> PS we should migrate away from using 1/0 or some other numeric as a 
> flag. This is bad form an hard to read. If we want to set properties 
> they should be done with module level constants.  getRaw(1) is alot less 
> descriptive then getRaw(NAMES).


Agree, about the GetRaw(Names) However I dont thing anyone understood 
the getActive function. It was a bit unclear but I did describe it.

scn = Scene.GetCurrent()
acrObject = scn.getActive() # gets active object. needed for knowing 
what object will go into edit mode.

- Cam













> 
> 
> Campbell Barton wrote:
> 
>>
>>
>> Stephen Swaney wrote:
>>
>>> On Fri, May 06, 2005 at 07:01:07PM +1000, Campbell Barton wrote:
>>>
>>>> Hi, Recently  have added some small usefull patches to the patch 
>>>> tracker.
>>>>
>>>> Heres a list
>>>>
>>>>
>>>> *** NMesh.GetNames()
>>>> https://projects.blender.org/tracker/index.php?func=detail&aid=2523&group_id=9&atid=127 
>>>>
>>>> - Solves the problem where it is impossible to get mesh objects with 
>>>> a fake user/no users. Unless you alredy knew the name.
>>>> - Provides a much faster and simpler method the the current Python
>>>> # Gets a list of unique nmesh names
>>>> nmesh_names = []
>>>> for ob in Objects.Get():
>>>> ____if ob.getType() == 'Mesh':
>>>> ________if ob.getData(name_only=1) not in nmesh_names:
>>>> ____________nmesh_names.append( ob.getData(name_only=1) )
>>>>
>>>> # Now we have a list.
>>>
>>>
>>>
>>>
>>> I was not aware this was a problem.
>>>
>>> Based on the rest of the Bpy API, I would expect NMesh to have
>>> a Get() method that either returns the named object or a list
>>> of all the Nmeshes.  To just get the names and not the entire
>>> object, we could apply the name_only=1 metaphor we used in
>>> Object.getData().
>>>
>>>
>>>> *** Scene.getActive()
>>>> https://projects.blender.org/tracker/index.php?func=detail&aid=2521&group_id=9&atid=127 
>>>>
>>>> - Solves the problem where Object.GetSelected()[0] was assumed to be 
>>>> the active object, which is not always true since the active object 
>>>> for a scene does not have to be selected.
>>>
>>>
>>>
>>>
>>> Is this different than Scene.GetCurrent() ?
>>
>>
>>
>> Hi, the resion not to get the nmesh data is that this can be very 
>> CPU/Memory Intensive. Keep in mind that some people use Meshes that 
>> just about fill there entire system Ram, so making a copy of ALL NMesh 
>> data at once could even crash blender- and is not very efficient.
>>
>> - Cam
>>
>>
>>
>> _______________________________________________
>> Bf-python mailing list
>> Bf-python at projects.blender.org
>> http://projects.blender.org/mailman/listinfo/bf-python
> 
> 
> 
> _______________________________________________
> Bf-python mailing list
> Bf-python at projects.blender.org
> http://projects.blender.org/mailman/listinfo/bf-python
> 
> 

-- 
Campbell J Barton

133 Hope Street
Geelong West, Victoria 3218 Australia

URL:    http://www.metavr.com
e-mail: cbarton at metavr.com
phone: AU (03) 5229 0241



More information about the Bf-python mailing list