# Scripting 2D cuts of a 3D geometry

Hello everybody,

i've just started to use salome and want to built a script which cuts an imported 3D geometry in 2D planes.

At the moment i define 3 points, built a plane out of them and cut the whole geometry with this plane.

Is there a better way, cause i need several hundreds of cuts . I don't need the cuts in the program - i need the cuts as separate files (as 2D geometry).

Thanks in advance,

Andreas

Hi St. Micheal,

it works amazing fast - BUT i only get empty cutplanes.

I've adapted the script that the size of the box is as big as the geometry (*.stp) and the planes really cut the geometry, but when i import the planes they are empty.

Btw. is there a command giving the max. size of an imported geometry - like a covering box?

Thanks !

Andrea

Btw. is there a command giving the max. size of an imported geometry - like a covering box?

geompy.BoundingBox() return extents of the bounding box.

St.Michael

thanks for the hint!

Do you have any idea, why the cuts are empty? it doesn't depend on the geometry import...

Do you have any idea, why the cuts are empty?

Maybe your 3D model is not a solid one? Use "Measures / What is" command to see what your model is.

St.Michael

Original i have 30 Solids, but by loading it in salome there is only one compound displayed:

Number of sub-shapes :

VERTEX : 680

EDGE : 992

WIRE : 418

FACE : 388

SHELL : 44

SOLID : 30

COMPSOLID : 0

COMPOUND : 1

SHAPE : 2553

Do you have any idea, why the cuts are empty?

What is actually a problem? Result of the boolean operation is empty or the exported file is empty?

St.Michael

this was not the problem ... ^ ^

> Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)

I thought this is a kind of bounding box - now i changed it to my imported geometry and i get files WITH geometry inside

But - by cutting 30 objects i get 30 files for one plane - any idea who i get only one file for each cut?

Andreas

I think the simplest solution would be not to use all cut-planes at once but rather to iterate over the cut-planes and cut all solids by one plane at a time.

St.Michael

I use

"geomObj = geompy.ImportSTEP(xxx)"

for importing one geometry with several solids - but how can i cut all solids out of this geometry by one plane?

how can i cut all solids out of this geometry by one plane?

The same way:

cuts = geompy.MakeCommon( geomObj, cutPlane )

sure... but resulting in 30 separate faces and consequently in 30 separate .stp-files

Not a problem. Just remove a loop on sub-faces of the result of geompy.MakeCommon(), so all faces relating to one cut-plane will be in one file.

St.Michael