Personal tools
You are here: Home Forum Use Scripting 2D cuts of a 3D geometry

Scripting 2D cuts of a 3D geometry

Up to Use

Scripting 2D cuts of a 3D geometry

Posted by Andreas Kopf at April 23. 2013

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

Re: Scripting 2D cuts of a 3D geometry

Posted by Saint Michael at April 23. 2013

Hi Andreas

Look at the attached script, does it do what you need?

St.Michael

Attachments

Re: Scripting 2D cuts of a 3D geometry

Posted by Andreas Kopf at April 24. 2013

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

Re: Scripting 2D cuts of a 3D geometry

Posted by Saint Michael at April 24. 2013

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

Re: Scripting 2D cuts of a 3D geometry

Posted by Andreas Kopf at April 24. 2013

thanks for the hint!

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

Re: Scripting 2D cuts of a 3D geometry

Posted by Saint Michael at April 24. 2013

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

 

Re: Scripting 2D cuts of a 3D geometry

Posted by Andreas Kopf at April 24. 2013

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

Re: Scripting 2D cuts of a 3D geometry

Posted by Saint Michael at April 24. 2013
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

Re: Scripting 2D cuts of a 3D geometry

Posted by Andreas Kopf at April 24. 2013

The exported files are empty  - i put in several different geometries, but every time the same.

Re: Scripting 2D cuts of a 3D geometry

Posted by Saint Michael at April 24. 2013

Maybe export goes to a file different than the file you check? :)

St.Michael

Re: Scripting 2D cuts of a 3D geometry

Posted by Andreas Kopf at April 24. 2013

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 

Re: Scripting 2D cuts of a 3D geometry

Posted by Saint Michael at April 24. 2013

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

Re: Scripting 2D cuts of a 3D geometry

Posted by Andreas Kopf at April 24. 2013

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?

Re: Scripting 2D cuts of a 3D geometry

Posted by Saint Michael at April 24. 2013

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

The same way:

cuts = geompy.MakeCommon( geomObj,  cutPlane )

Re: Scripting 2D cuts of a 3D geometry

Posted by Andreas Kopf at April 24. 2013

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

Re: Scripting 2D cuts of a 3D geometry

Posted by Saint Michael at April 24. 2013

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

Re: Scripting 2D cuts of a 3D geometry

Posted by Andreas Kopf at April 24. 2013

ok -thanks a lot ... it's working (when i only do one cut).

Now i try to understand to make several of this cuts in a loop ...

Powered by Ploneboard
Document Actions