Hi,

I've started experimenting with TopExp_Explorer in order extract
sub-shapes from Shapes. When I try to store the results of the iteration
in a python list, all but the last extracted shapes become invalid. It
seems that TopExp_Explorer is re-using some part of the data structure
it outputs as it iterates, so keeping references to the shapes it
generates doesn't work.

Here's an example:

        from OCC import TopExp, BRepPrimAPI, TopAbs, TopoDS
        
        box = BRepPrimAPI.BRepPrimAPI_MakeBox(10., 20., 30.)
        ex = TopExp.TopExp_Explorer(box.Shape(), TopAbs.TopAbs_EDGE)
        
        results = []
        
        while ex.More():
            edge = TopoDS.TopoDS().Edge(ex.Current())
            print "is null?", bool(edge.IsNull())
            results.append(edge)
            ex.Next()
            
        for edge in results:
            print "null now?", bool(edge.IsNull())
            
Inside the while loop, none of the shapes are Null. Once the iteration
is complete, all the edges become Null.

What's the correct way to store a references to sub-Shapes? I guess I
need a shallow copy of the shape-object returned by Explorer.Current()
but I can't figure how to achieve this.

cheers,

Bryan



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

Reply via email to