STEP questions

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
jreinhardt
Posts: 329
Joined: Mon Sep 09, 2013 6:08 pm

STEP questions

Post by jreinhardt »

Hi everybody,

I tried to build a STEP exporter for BOLTS, which exports the parts available in BOLTS for FreeCAD to STEP files using FreeCAD.

I got it to do something, but a few issues and questions arose in the process. There exists a discussion about these issues and questions in a GitHub Issue, but I wanted to ask for advise here too.

I guess I should also mention, that I do not know very much about STEP and that I am struggling to organize all the information and words and concepts that I am picking up in my head. So my questions and problems might be obvious for someone who has a better overview.

1) Am I aiming for the right goal?

My current plan is to generate one step file per part (so one for a M4 nut ISO4035, one for a M5 nut ISO4035, one for a hex screw ISO 4017 M3 x 20, one for ISO 4017 M3 x 25 and so on). This way the user can use the "Open File" dialogue of his CAD tool to get the part he wants.

But this results in a lot of files, currently around thousand, and there are not yet many parts available in BOLTS. I organize them in a directory structure, so I think it is manageable, but if BOLTS grows, the number of files will grow even further.

Is this a good plan, or should I do it differently?

2) Ball bearing issue

Some parts (e.g. ball bearings) of the parts in BOLTS consist of several components (inner, outer ring, balls) that are not fused together, e.g. ball bearings. The python function that generates them puts them in a Compound so that they show up as one. There is no need for the user to manipulate these components, they are only cosmetic, to make the thing look like a ball bearing.

However, when I load the step file for the ball bearing in FreeCAD, I get the following result:
step_export_grouping.png
step_export_grouping.png (134.03 KiB) Viewed 9868 times
All the components are showing up as separate objects in the tree view. (I know about solution for the object naming in step, just didn't implement it yet.)

Is there a way to make the ball bearing only show up as one thing in the tree view when loading the step file? I tried fusing everything together, but that failed when things were disjoint.

3) User defined attributes

This is more a long-term question, not something that I consider high priority.

For a part there might be informations available that are not directly related to the geometric shape of the part, like material or finish. In the discussion on GitHub charliestirk (who seems to be a STEP expert) suggested that it might be a good idea to store these in user defined attributes, but that OpenCASCADE does not support this yet.

Are there any plans to support that in FreeCAD in the foreseeable or distant future?


I am happy to help out with tasks that I can manage, but I do know very little about the inner workings of FreeCAD.

Thank you in advance.

Greetings

Johannes
BOLTS, standard parts library for FreeCAD Thread, Help with Translation
cwstirk
Posts: 19
Joined: Thu Dec 05, 2013 7:07 pm

Re: STEP questions

Post by cwstirk »

Hi Johannes,

Thanks for posting your questions here since I think the FreeCAD people involved in modeling, assemblies, and STEP translation can help. For issue 2, can you attach or link to your file(s) so they can inspect the details?

For issue 3, STEP has material identification and density capability, and OpenCasCade supports STEP material identification. An overview of OpenCascade STEP capabilities is here

http://dev.opencascade.org/doc/overview ... _step.html

And the OpenCascade changelog records that STEP materials capability has been fixed.

http://tracker.dev.opencascade.org/view.php?id=22962

Note that OCC 6.5.4 or later is needed for the latest bug fixes for materials, but it should not be difficult to add STEP materials to FreeCAD since it is similar to color in both OpenCascade and STEP. It should not be difficult to add density to OpenCasCade since it is modeled similarly to material in STEP for parts. Downstream applications such as CAE and CAM need material (and sometimes density) information.

Other attributes that are not described in CAX-IF recommended practices could be added to domain specific sets of user defined attributes. Some like surface finish may start as user defined attributes, and migrate to other recommended practices such as for PMI (where it is mentioned, but not yet further detailed). Example sets of user defined attributes can be found in the appendices of MIL-STD-31000A Technical Data Packages.

http://www.everyspec.com/MIL-STD/MIL-ST ... 00A_45888/

User defined attributes for parts or assembly component instances are modeled similarly to color and material, so should not be difficult to add to the OpenCasCade STEP processor and then to FreeCAD. In general, there are many entities and attributes enumerated in STEP schemas that are rarely if ever used in translator implementations if there does not exist a corresponding CAX-IF recommended practice and sample files. User defined attributes provides a general method to implement attributes in STEP translators while enabling them to be flexibly defined externally by the relevant organizations.

Here is a link to how product libraries are developed in a related standard, Industry Foundation Classes (IFC), which includes sets of properties and may provide some inspiration for your work.

http://www.scribd.com/doc/113881227/Pro ... ldingSMART#!

Note that IFC uses the EXPRESS language and the STEP integrated resources for their schemas, which is why the FreeCAD Arch workbench can use IfcOpenShell based partly on OpenCasCade as an importer.

Regards, Charlie
jreinhardt
Posts: 329
Joined: Mon Sep 09, 2013 6:08 pm

Re: STEP questions

Post by jreinhardt »

Attaching some files to inspect. A ball bearing that suffers from issue 2 in step, fcstd and the python code that generates the part.

I had to zip the python code and the step file, because the extensions were not allowed.
Attachments
Ball-bearing.zip
(16.16 KiB) Downloaded 116 times
Ball-bearing-608.fcstd
(6.07 KiB) Downloaded 118 times
BOLTS, standard parts library for FreeCAD Thread, Help with Translation
User avatar
jriegel
Founder
Posts: 3369
Joined: Sun Feb 15, 2009 5:29 pm
Location: Ulm, Germany
Contact:

Re: STEP questions

Post by jriegel »

We have some general shortcomings in FreeCAD about STEP. At the moment we use the OCC high level step importer, which transfer the product structure in a OCC OCAF document (which we not use besides STEP import). OCC transfers only the things it has target objects in its data model. Colors and names are transported to an extend but e.g. no additional attributes or newer protocols like STEP-NC of IFC. This bugs me a long time already, since STEP is the only reasonably well defined and good standardized exchange format! There are two solution for it.

1) Using the OCC low level STEP parser and do the object and shape transfer by our self and transfer directly into FreeCAD objects.

2) Using the http://stepcode.org/ project and have full control about the supported STEP protocols

The second one is more work, but more promising for the future...

Anyway, its one of the bigger next steps if Assembly is runing...
Stop whining - start coding!
cwstirk
Posts: 19
Joined: Thu Dec 05, 2013 7:07 pm

Re: STEP questions

Post by cwstirk »

Hi Juergen,

I was hoping that there was some sort of issue with the BOLTS modeling approach with respect to FreeCAD was the source of the problem #2, but you indicate that root cause is the STEP translator. Is it the same as this issue?
http://www.opencascade.org/org/forum/th ... 3/?forum=3
Is there another modeling approach, or some new capabilities in the Assembly branch that could solve BOLTS problem #2?

The OCC low-level STEP importer (XDE) is not well-documented with respect to assembly structure and colors
http://tracker.dev.opencascade.org/view.php?id=20814
though some developers are able to use it, like Roman Lygin in CAD Exchanger.

For assemblies, FreeCAD can import the CAX-IF STEP files with external references, but each has missing, mis-placed or mis-colored parts in the GUI. The files are here
http://www.cax-if.org/library/index.html
Note that CAD Exchanger gets the part placement correct, but not the color or view orientation for some of the files.

Note that OpenCasCade bugtracker has issues with some aspects of external references using XDE.
http://tracker.dev.opencascade.org/view.php?id=3883
http://tracker.dev.opencascade.org/view.php?id=13328

It would be useful for FreeCAD to correctly import files with STEP external references, especially for the Assembly workbench. I use FreeCAD for fast and free STEP viewing, and look forward to better support for STEP assemblies. There could also be an option in the FreeCAD STEP exporter for a single file, single assembly structure and multiple part files, or nested external references. Note that CAD Exchanger exports them as a single file.

Regarding use of XDE or STEPcode for FreeCAD, XDE would probably be easier, assuming it becomes better documented, or FreeCAD figures out how to use it with the existing documentation. I am involved in STEPcode, and there have been some discussions with the OCE, OCCT, and IfcOpenShell communities about replacing the OCC STEP translator with STEPcode. It would be a big project, so we need to figure out if it is worth it from a performance (memory consumption with large files) or capability (adding new STEP capabilities like PMI, 3D Annotations, User Defined Attributes, 3D Tessellation, etc.) perspective. If FreeCAD wanted to bypass the OCC STEP translator and directly use STEPcode, I am sure that the STEPcode community would be willing to help as they have helped BRL-CAD, OpenVSP, and other developers. Like IfcOpenShell, you could run the translators together, using the existing OCC translator(s) for some things like topology and geometry, and another translator for other things that it does not handle as needed.

Regards, Charlie
User avatar
jriegel
Founder
Posts: 3369
Joined: Sun Feb 15, 2009 5:29 pm
Location: Ulm, Germany
Contact:

Re: STEP questions

Post by jriegel »

Hi Charli,
first of all thank you very much for that great piece of information. There was quit some development in the STEP community since I last checked!

I will start to digging into the information you gave.

For the short term it make sense to go with the XDE interface and utilize all it can give to use. Especially the BREP shape translation and healing is a big plus to me.

The first steps are to pioneer a internal model representation of Assemblies and other complex types. Even multi model files are on the roadmap. If the internal representation is good enough the translation library is easier to exchange.

IN the long run I would like to use a more open lib like STEPCode and the ability to add additional stuff via a EXPRESS compile. IMO the real beauty of STEP is its high level description language and its extensibility.

But for a while we have to live with different libs and translation methods. But a vision clearly would be a general translation engine in FreeCAD which is capable of supporting all of FreeCADs module, like Arch (IFC), CAM (STEP-NC), FEM, Tolerances, ......... and lot more....
Stop whining - start coding!
cwstirk
Posts: 19
Joined: Thu Dec 05, 2013 7:07 pm

Re: STEP questions

Post by cwstirk »

Hi Juergen,

For the FreeCAD Assembly workbench, as you dig into the CAX-IF info, follow the External References recommended practices and the PDM Schema Usage Guide. There is also some good information on http://www.wikistep.org.

I checked some other STEP files from the CAX-IF library, and FreeCAD can import STEP sample files with Supplemental Geometry and 3D Annotations, but they are not visible. It may be difficult to support these capabilities if they require extensive changes to OpenCasCade. If you want to view a STEP file, the most conformant viewer is probably the free IDA-STEP viewer, though even it does not display Supplemental Geometry, or list Material Identification. IDA-STEP viewer does display 3D Annotations and PMI.

For the newest STEP AP 242 schema (which replaces 203 and 214), FreeCAD can read some files, but crashes on others that IDA-STEP viewer can validate and display. I have no idea what the problem is, and unfortunately the files are proprietary. The CAX-IF implementation coverage matrix shows that many CAD and translator vendors have working 242 translators.

AP 242 also includes new capabilities such as a 3D tessellated representation
http://www.cax-if.org/documents/test_suite_33j_v11.pdf
which is also being used for PMI presentation, and would map to OpenCasCade meshes. Other things already in the AP242ed1 schema of potential interest to FreeCAD include machining form features, kinematics, and composites (see http://www.ap242.org). Planning for 242 edition 2 includes PMI for assemblies, electrical harnesses, and other capabilities. There is a lot going on in STEP that is not well known, but new capabilities will be rolling out on a regular basis.

To support these new 242 capabilities, as well as the older ones mentioned above that FreeCAD does not support, the OpenCasCade translator will need significant work, or you will need to run something like STEPcode in parallel. Thanks for all your work on FreeCAD, it is a great tool and has a lot of potential! The FreeCAD developers seem to have a lot of knowledge and ability, but you will need support from OpenCasCade and possibly STEPcode going forward.

Regards, Charlie
User avatar
jriegel
Founder
Posts: 3369
Joined: Sun Feb 15, 2009 5:29 pm
Location: Ulm, Germany
Contact:

Re: STEP questions

Post by jriegel »

Hallo,
yesterday I did a code review into the OCC STEP implementation to judge what we can do with it. It works like most STEP implementation with a generated class library which reflect some EXPRESS files and load any supported entity into memory. After reading it allows to transfer geometrical shapes starting from a certain STEP entity (number). But it seams I also get access to the low level classes which represent all the entities in the file. This should allow us to transfer additional information into our data model AND keep the shape transfer process.

But you are also right that we could use STEPCode and the OCC implementation together. We could use STEPCode to traverse the STEP document, retrieve all information we need. After that we could use the OCC implementation to just transfer the Shape representations... That would make us very flexible. With STEPCode we could support all kinds of APs and future extensions!

The AP 242 Stuff is new to me! I have to take a look - thanks again for the interesting information!
For 3D tessellations we have a own (much better) data structure in the mesh module. I planed anyway to support meshes in the Assembly workbench, since triangle meshes become more common in CAE.
Stop whining - start coding!
User avatar
easyw-fc
Veteran
Posts: 3633
Joined: Thu Jul 09, 2015 9:34 am

Re: STEP questions

Post by easyw-fc »

jriegel wrote:We have some general shortcomings in FreeCAD about STEP.
....
2) Using the http://stepcode.org/ project and have full control about the supported STEP protocols
The second one is more work, but more promising for the future...
Hi, is there any evolution in that direction?
I used this approach to export FC Parts to VRML
https://github.com/easyw/kicad-3d-model ... RMLwColors

Do you think it would be possible to adapt this js parser, based on stepcode
https://github.com/erossignon/node-STEP ... eadStep.js
https://github.com/erossignon/node-STEP
from js to python to export FC objects to STEP in a more compact way?

thank you
Maurice
cwstirk
Posts: 19
Joined: Thu Dec 05, 2013 7:07 pm

Re: STEP questions

Post by cwstirk »

@easy-fc I have been waiting for @jriegel to respond regarding the status of STEP assemblies, as I am also interested in his progress. In the meantime, here is a link to documentation on the OCC STEP translator.
http://dev.opencascade.org/doc/overview ... _step.html
I believe FreeCAD uses the regular OCC STEP processor, which is why it does not handle assemblies like the lower-level OCC XDE processor.

I have no reason to believe that the node-STEP js parser is based on stepcode, and it only works on assembly structures, not geometric shapes. However, the author, Etienne Rossignon, is well-known and -respected in open source with OCC, STEP, etc.

Regarding more compact STEP files, in the short term you may want to use compression, which typically gets a 7 fold reduction.
https://www.cax-if.org/documents/rec_pr ... on_v11.pdf
Post Reply