Ok thanks. Unfortunately both simple examples I tried didn't repro the
problem. It might be that the garbage collector has to run for the
problem to happen. I only experience the issue when a lot of work has
been done between creating and using the list.

On 5/4/10, Thomas Paviot <tpav...@gmail.com> wrote:
> 2010/5/4 Dave Cowden <dave.cow...@gmail.com>
>
>> Hey, all:
>>
>> I have had a strange problem occur a couple of times, wondering if anyone
>> recognizes it.
>>
>> The behavior occurs when looping over shapes and dealing with them in
>> python lists. During the iteration,
>> all of the objects appear normal and correct. But later when they are
>> accessed in the list, all of the references in the list appear to be the
>> last object written into the list.
>>
>>
>> For example, I had code like the below, which was transforming a list of
>> shapes:
>>
>> wireList = []; #this is a list of wires that are all ok
>>
>>
>> #make transformation
>> p1 = gp.gp_Pnt(0,0,0);
>> p2 = gp.gp_Pnt(0,0,z);
>> xform = gp.gp_Trsf();
>> xform.SetTranslation(p1,p2);
>> bt = BRepBuilderAPI.BRepBuilderAPI_Transform(xform);
>>
>> newList = [];
>>
>> for w in wireList:
>>     bt.Perform(w,True);
>>     newList.append(bt.Shape() );
>>     TestDisplay.display.showShape(bt.Shape() );
>>
>>
>>
>> When this code runs, the shapes displayed are correct. But later when they
>> are accessed, what i get is a bunch of copies of the last one added.
>>
>>
>> I have also seen this behavior before iterating over wires using a
>> wireExplorer-- in that case, it was resolved by using the super-ugly and
>> annoying TopTools.TopTools_HSequenceOfShape() object instead of a python
>> list.
>>
>> Should I use HSequnceOfShape instead of python lists, or is there a trick
>> that I can use to let me use lists?
>>
>> thanks!
>>
>>
>
> Hi Dave,
>
> I have to reproduce this issue from a simple example, and create a unittest.
>
> In the meantime, you may have to use the HSequnceOfShape. Although it's not
> pythonic, it's more safe to use builtin OCC list manager rather than python
> list. The mapping between python lists and OCC lists have to be performed at
> the SWIG level.
>
> Best Regards,
>
> Thomas
>

_______________________________________________
Pythonocc-users mailing list
Pythonocc-users@gna.org
https://mail.gna.org/listinfo/pythonocc-users

Reply via email to