For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings

 

Need to speed up your development?
Have a look at our:

Samples & Tools

 

Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

making a solid out of a shell with PythonOCC

adrenalin123's picture
Forums: 

Hello Together!
I am using PythonOCC with my modelling an I try to make a Solid out of a Shell.
Here a fragment of my code:

sewing = BRepBuilderAPI_Sewing()

for i in range(14):
sewing.Add(faces[i])

sewing.Perform()
sewed_shape = sewing.SewedShape()
# It works fine until here, and I can display the shell

solid = BRepBuilderAPI_MakeSolid(sewing)

I tried to make the solid out of the original sewing and out of the sewed shape.
Neither works. Can anybody help me, please?

Bye, Martin

adrenalin123's picture

I get following error:

TypeError: in method 'new_BRepBuilderAPI_MakeSolid', argument 1 of type 'TopoDS_Solid const &'

Thomas Paviot's picture

adrenalin123,

The prototype for the BRepBuilderAPI_MakeSolid method is (just type help(BRepBuilderAPI_MakeSolid)):
__init__(self, TopoDS_CompSolid S) -> BRepBuilderAPI_MakeSolid
__init__(self, TopoDS_Shell S) -> BRepBuilderAPI_MakeSolid
__init__(self, TopoDS_Shell S1, TopoDS_Shell S2) -> BRepBuilderAPI_MakeSolid
__init__(self, TopoDS_Shell S1, TopoDS_Shell S2, TopoDS_Shell S3) -> BRepBuilderAPI_MakeSolid
__init__(self, TopoDS_Solid So) -> BRepBuilderAPI_MakeSolid
__init__(self, TopoDS_Solid So, TopoDS_Shell S) -> BRepBuilderAPI_MakeSolid

That is to say, you first have to convert the sewed shape to a Shell.

Here is your code corrected:

sewing = BRepBuilderAPI_Sewing()

for i in range(14):
sewing.Add(faces[i])

sewing.Perform()
sewed_shape = sewing.SewedShape()
# It works fine until here, and I can display the shell

from OCC.TopoDS import *
tds = TopoDS()

solid = BRepBuilderAPI_MakeSolid(tds.Shell(sewed_shape))

I guess it should work (not tested).

Regards,

Thomas

adrenalin123's picture

Thank you very much! It worked! I thought, sewing faces already returns a shell.
If I use ShapeType() on the sewed_shape, it says: this is a shell (enumeration 3)
For some reason, the MakeSolid does not take this shell.
If I use ShapeType() on the converted shape, it also says: this is a shell. But what is the difference between both of them?