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!
_______________________________________________
Pythonocc-users mailing list
Pythonocc-users@gna.org
https://mail.gna.org/listinfo/pythonocc-users

Reply via email to