Hi, Christian: The first question is ( ironically ) easiest. Here's an example:
def readSTLShape(fileName): ts = TopoDS.TopoDS(); logging.info("Reading STL:'" + fileName + "'..."); #read stl file shape = TopoDS.TopoDS_Shape() stl_reader = StlAPI.StlAPI_Reader() stl_reader.Read(shape,fileName) logging.info("Fixing holes and degenerated Meshes..."); sf = ShapeFix.ShapeFix_Shape(shape); sf.Perform(); fixedShape = sf.Shape(); logging.info("Making Solid from the Shell..."); #bb = BRepBuilderAPI.BRepBuilderAPI_MakeSolid(ts.Shell(fixedShape)); #bb.Build(); bb = ShapeFix.ShapeFix_Solid(); return bb.SolidFromShell(ts.Shell(fixedShape)); logging.info("Done."); return bb.Solid(); This code includes reading the stl file as well as fixing problems with it using Shapefix. It works well for me. Now, on the second part, I'm not sure I understand completely. I think what you would want to do is something like this: (1) create a line ( gp_Lin ) going in the z direction at the coordinate you specify. Then, find the intersections with the surfaces of all the solids. I think there are some tools that are designed to help find intersections. gp_Lin ( a line : in the gp package ) Check out IntCurvesFace.IntCurvesFace_ShapeIntersector or similar, it has some tools that might help. Pythonocc is definitely up to the task though-- I don't think you'll find a more capable product for the price ;) One other helpful tip, dealing with the API: I use the following approach: (1) go to www.opencascade.org, and search the forum. If you can find a clue there for what you want to do, then you can convert those samples fairly quickly to the pythonOCC docs for more details. Also, make sure to check out the svn trunk of pythonOCC so you can see the tools and samples-- there is a lot of good code there. I hope this helps! Dave -----Original Message----- From: pythonocc-users-boun...@gna.org [mailto:pythonocc-users-boun...@gna.org] On Behalf Of Christian Siefkes Sent: Tuesday, February 16, 2010 1:49 PM To: PythonOCC users Subject: [Pythonocc-users] Newbie question: getting coordinates of objects Hi all, I'm new to PythonOCC and I bit overwhelmed by the API. What I would like to do is this: (1) Read a STL file. (2) Determine for a specific x,y coordinate where on the z axis are object borders for that specific coordinate (which points on the z axis are "inside" and which are "outside" objects for that coordinate). Samples for (2): >>> checkCoordinate(1,2) [(500,1000),(1250,1600)] # there are two objects at the specified coordinate, one extending from # z=500 to =z1000, the other from z=1250 to z=1600 >>> checkCoordinate(500,-25) [] # No objects at this coordinate Can anybody give me some hints whether PythonOCC is the right tool for the job (I would presume so) and what I have to do? Thanks Christian -- |------- Dr. Christian Siefkes ------- christ...@siefkes.net ------- | Homepage: http://www.siefkes.net/ | Blog: http://www.keimform.de/ | Peer Production Everywhere: http://peerconomy.org/wiki/ |---------------------------------- OpenPGP Key ID: 0x346452D8 -- Freedom is being able to make decisions that affect mainly you. Power is being able to make decisions that affect others more than you. If we confuse power with freedom, we will fail to uphold real freedom. -- Bradley M. Kuhn and Richard M. Stallman, Freedom Or Power? _______________________________________________ Pythonocc-users mailing list Pythonocc-users@gna.org https://mail.gna.org/listinfo/pythonocc-users