Output a single STEP file from muliple shapes.

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
keithsloan52
Posts: 976
Joined: Mon Feb 27, 2012 5:31 pm

Output a single STEP file from muliple shapes.

Postby keithsloan52 » Sat Aug 17, 2019 2:43 am

Okay in my GDML workbench the GDML solids are implemented as FreeCAD python objects, but apart from having the GDML solid parameters they also each have a Shape for FreeCAD display purposes.

I have asked in the Geant4 forum if people would find it useful if apart from importing, editing the GDML if it would
be useful if the there was a facility to output a STEP file and whilst not a viral response there is some.

Now I could loop through the document and output each object as an individual STEP file using

Code: Select all

exportStep( string )
Description: Exports the content of this shape to an STEP file. 
But how could I create just one STEP file? Do I need to output each object to a temp file, add some glue type STEP definitions to identify an individual object and then concatenate together?

I know there are people in the community who have dealt with FreeCAD and STEP input and output, so looking for
advice on how I can lesson my learning curve from having to researching from scratch and having to gain a lot of expertise in STEP.

Thanks
keithsloan52
Posts: 976
Joined: Mon Feb 27, 2012 5:31 pm

Re: Output a single STEP file from muliple shapes.

Postby keithsloan52 » Sat Aug 17, 2019 7:29 am

I found https://searchcode.com/codesearch/view/1618194/

and Part has

Code: Select all

 __toPythonOCC__(Part.Shape)
Description: Helper method to convert an internal shape to pythonocc shape
Returns: an OCC.Shape
But is there a better way?
User avatar
easyw-fc
Posts: 2614
Joined: Thu Jul 09, 2015 9:34 am

Re: Output a single STEP file from muliple shapes.

Postby easyw-fc » Sat Aug 17, 2019 7:49 am

keithsloan52 wrote:
Sat Aug 17, 2019 7:29 am
I found https://searchcode.com/codesearch/view/1618194/

and Part has

Code: Select all

 __toPythonOCC__(Part.Shape)
Description: Helper method to convert an internal shape to pythonocc shape
Returns: an OCC.Shape
But is there a better way?
You can make a union or a compound of shapes and export it as STEP or you can inser a 'Part' container, add your shapes to the container and export the main container.
keithsloan52
Posts: 976
Joined: Mon Feb 27, 2012 5:31 pm

Re: Output a single STEP file from muliple shapes.

Postby keithsloan52 » Sat Aug 17, 2019 11:00 am

easyw-fc wrote:
Sat Aug 17, 2019 7:49 am
keithsloan52 wrote:
Sat Aug 17, 2019 7:29 am
I found https://searchcode.com/codesearch/view/1618194/

and Part has

Code: Select all

 __toPythonOCC__(Part.Shape)
Description: Helper method to convert an internal shape to pythonocc shape
Returns: an OCC.Shape
But is there a better way?
You can make a union or a compound of shapes and export it as STEP or you can inser a 'Part' container, add your shapes to the container and export the main container.
Cannot union or compound as mostly separate objects i.e. distinct objects.

Will have to check out container as not used them before. Could not find any obvious way to create one, which workbench
does one use? Think it is the same problem. FreeCAD is not oriented to multiple objects in a doc.
keithsloan52
Posts: 976
Joined: Mon Feb 27, 2012 5:31 pm

Re: Output a single STEP file from muliple shapes.

Postby keithsloan52 » Sat Aug 17, 2019 11:03 am

Think I need to use Python OCC but confused about how I install it and get FreeCAD to recognize it.
User avatar
easyw-fc
Posts: 2614
Joined: Thu Jul 09, 2015 9:34 am

Re: Output a single STEP file from muliple shapes.

Postby easyw-fc » Sat Aug 17, 2019 11:24 am

keithsloan52 wrote:
Sat Aug 17, 2019 11:00 am
Cannot union or compound as mostly separate objects i.e. distinct objects.

Will have to check out container as not used them before. Could not find any obvious way to create one, which workbench
does one use? Think it is the same problem. FreeCAD is not oriented to multiple objects in a doc.
???
https://www.freecadweb.org/wiki/Std_Part/en
keithsloan52
Posts: 976
Joined: Mon Feb 27, 2012 5:31 pm

Re: Output a single STEP file from muliple shapes.

Postby keithsloan52 » Sat Aug 17, 2019 12:00 pm

Don't think it really solve things I am not dealing with standard Parts, can a Part contain a FreeCAD_Python_Object
and if yes when exporting as STEP will it just look at the Shape. Given Shape is not standard for such things
I doubt it.

A doc in my workbench is a whole series of FreeCAD_Python_Objects that implement GDML solids.
What I require is to loop through the document and output all the Shapes into a STEP file.

I think I need pythonOCC to do that. I have it installed and can import OCC from python, but need to get FreeCAD to recognise it.
User avatar
easyw-fc
Posts: 2614
Joined: Thu Jul 09, 2015 9:34 am

Re: Output a single STEP file from muliple shapes.

Postby easyw-fc » Sat Aug 17, 2019 12:18 pm

keithsloan52 wrote:
Sat Aug 17, 2019 12:00 pm
Don't think it really solve things I am not dealing with standard Parts, can a Part contain a FreeCAD_Python_Object
and if yes when exporting as STEP will it just look at the Shape. Given Shape is not standard for such things
I doubt it.

A doc in my workbench is a whole series of FreeCAD_Python_Objects that implement GDML solids.
What I require is to loop through the document and output all the Shapes into a STEP file.

I think I need pythonOCC to do that. I have it installed and can import OCC from python, but need to get FreeCAD to recognise it.
Simply post a sample FC file... FC can handle almost everything.

EDIT
here some examples:
gdml-part.step
(19.24 KiB) Downloaded 12 times
gdml-union.step
(46.22 KiB) Downloaded 10 times
gdml-union.FCStd
(29.12 KiB) Downloaded 13 times
gdml-compound.step
(15.96 KiB) Downloaded 10 times
gdml-compound.FCStd
(9.98 KiB) Downloaded 8 times
User avatar
saso
Posts: 1305
Joined: Fri May 16, 2014 1:14 pm
Contact:

Re: Output a single STEP file from muliple shapes.

Postby saso » Sat Aug 17, 2019 2:41 pm

while i have only made a quick look at GDML i think you are probably complicating this without a good reason... attached is sample geometry made in FreeCAD, once as solids and once and shells. next you should probably do some research why it is very common to use just shells when doing FEM analysis on any type of geometry and in all the different industries (mechanical, automotive, construction,...), you can also review why for the same reasons some industries like the automotive are by large working only with shells, also see catia volumes, catia fcm,... to get a better picture and understanding on the topic.

from the linked presentations for an GDML implementation in catia, they seem to be using standard catia geometry and structure and are just exporting to GDML, so I don't quite understand the need why doing it different in FreeCAD?

https://www.slideserve.com/lilian/catia ... ry-builder
https://www.slideserve.com/ian-chavez/d ... ry-builder

you should however also understand that cern is using catia for more or less everything, from the construction of their buildings to their machines... they probably have special agreements that go back decades and go very deep also in common scientific research, funding and political connections
Attachments
solid_shell.FCStd
(13.52 KiB) Downloaded 10 times
keithsloan52
Posts: 976
Joined: Mon Feb 27, 2012 5:31 pm

Re: Output a single STEP file from muliple shapes.

Postby keithsloan52 » Sat Aug 17, 2019 3:36 pm

saso wrote:
Sat Aug 17, 2019 2:41 pm
while i have only made a quick look at GDML i think you are probably complicating this without a good reason... attached is sample geometry made in FreeCAD, once as solids and once and shells. next you should probably do some research why it is very common to use just shells when doing FEM analysis on any type of geometry and in all the different industries (mechanical, automotive, construction,...), you can also review why for the same reasons some industries like the automotive are by large working only with shells, also see catia volumes, catia fcm,... to get a better picture and understanding on the topic.

from the linked presentations for an GDML implementation in catia, they seem to be using standard catia geometry and structure and are just exporting to GDML, so I don't quite understand the need why doing it different in FreeCAD?

https://www.slideserve.com/lilian/catia ... ry-builder
https://www.slideserve.com/ian-chavez/d ... ry-builder

you should however also understand that cern is using catia for more or less everything, from the construction of their buildings to their machines... they probably have special agreements that go back decades and go very deep also in common scientific research, funding and political connections
No No my friend it is you that needs to do the research.

Yes FEM uses Mesh and I am told is very different from the needs of Monte Carlo Simulation. If you look at this years GSOC there is an effort to use VecGeom. i..e Take a CAD BREP output from a CAD program, Tessellate the shapes into VecGeom and then use a lot of parallel cores to process the VecGeom to try and get the results in a reasonable time. Meshs as used by FEM just take way way to long to run.
from the linked presentations for an GDML implementation in catia, they seem to be using standard catia geometry and structure and are just exporting to GDML, so I don't quite understand the need why doing it different in FreeCAD?


You cannot go from BREP type geometries to GDML. Take a look at McCAD it tries to take BREP definitions and break down into a number of GDML solids.

I have read bits about CATIA but it is way too expensive unless you are somebody like CERN, so cannot afford to check out what they do.