How to import SOLIDWORKS (or Parasolid, JT, NX, Creo) files into Open CASCADE

What is Open CASCADE

OCC has data structures to describe 3D models with precise B-Rep and various API to perform modeling operations (fillets and chamfers, Boolean operations, etc.). For the last 20+ years the OCC company has been focusing on rendering custom development services. So development of the kernel is mainly driven by those customer projects. Although some core modules are mainly in the maintenance mode, the kernel can still be a viable option for businesses evaluating the development platform for their apps.

CAD file formats supported by Open CASCADE

CAD Exchanger components vs Open CASCADE’s

We have to have a long-term predictable R&D roadmap, invest a far greater amount of human talents into product development, and be more responsive to numerous corner cases reported by our customers. Those focused efforts result in a broader amount of formats (20+ at the time of this writing), a broader range of format versions, more efficient implementations (including two hold patents related to parallel computing), and eventually quality. With millions of users using CAD Exchanger-based applications, the stream of CAD files going through CAD Exchanger codes is in dozens of millions every year! That challenge does require us to provide world-class CAD data converters in order to be a successful sustainable business.

We have multiple clients who decided to base their apps on Open CASCADE and they use some of the techniques described below to take advantage of the two worlds — OCC and CAD Exchanger.

Integration of CAD Exchanger into an OpenCASCADE-based app

Let’s consider some technical details.

How to read SOLIDWORKS file into Open CASCADE

Option 1. Topology and geometry only

In this case, your simplest code might look as follows:

#include <cadex/SDL_Reader.hxx>cadex::SLD_Reader aReader;
TopoDS_Shape aShape;
if (!aReader.ReadFile (“myfile.ldprt”s) || !aReader.Transfer (aShape))
{
//some error happened
return false;
}
//here aShape contains a full OCC shape

Option 2. Open CASCADE XDE

In this case, the contents of the CAD Exchanger model will be appended to the contents of aDoc: the assembly structure, colors, names, layers.

//convert CAD Exchanger document to OCC XDE document
Handle(TDocStd_Document) aDoc = ...; //
cadex::ModelXDE_Converter::Convert (aModel, aDoc);

Option 3. Open CASCADE topology and your own meta-data

The following code snippet demonstrates how this could be done.

class SceneGraphVisitor : public ModelData_Model::VoidElementVisitor
{
...
void operator() (const ModelData_Part& thePart) override
{
auto aBRep = thePart.BRepRepresentation();
if (aBRep) {
const auto& aRootList = aBRep.Get();
const TopoDS_Shape& aShape = aBRep.ToOCC(); //convert to OCC shape
Base_UTF16String aName = thePart.Name();
//bind aShape and aName in your data structures...
}
}
...
}

...
SceneGraphVisitor aVisitor;
aModel.Accept (aVisitor); //traverse model and retrieve data

Exporting Open CASCADE data into CAD files

TopoDS_Shape aShape = ...;
cadex::ModelData_Model aModel;
cadex::ModelData_ShapeConverter::Add (aShape, aModel);
cadex::JT_Writer aWriter;
if (!aWriter.Transfer (aModel) || !aReader.WriteFile (“myfile.jt”)) {
//some error happened
return false;
}

Benefits of CAD Exchanger

  • Truly seamless integration. It takes less than 5–10 lines of C++ code as explained above. Overall, perhaps sometimes it can be even more compact than using native OCC converters.
  • Single API. The conversion between CAD Exchanger SDK and OCC objects is totally format-agnostic. So if over time, you want to add new formats (e.g., NX after Solidworks) that will take a couple of extra lines (to add cadex::NX_Reader). We plan to achieve that extra amount to be zero (yes, zero!). In that case, even recompilation will not be required!
  • Single vendor. As I said, data conversion is our core business and our core architecture is shared across all formats. Although you can mix CAD Exchanger-based components with native OCC, preferring the former gives you consistent behavior, user experience, and benefits (such as delayed loading, CPU multi-threading, etc.). Price-wise, this can be even zero extra cost — e.g., when using our bundles, you get access to all formats.
  • Support. Again, due to very different business models, it is in our best interests to keep the quality of the converters as high as possible. So whenever you might encounter a very specific corner case, that report immediately goes into our tracker and will be picked up during upcoming development sprints.
  • Performance and Quality. Multi-core parallelism was my second professional passion (developed during ten years work in Intel software group), and multi-threading and high performance were in the DNA of CAD Exchanger from day one. We received two patents related to parallel computing, and this parallelism is part of the core architecture. Therefore even those overlapping formats (e.g., STEP, IGES, etc.) are implemented in a much more scalable way than legacy OCC codes. However, I remain fully open to counter-examples: if you come across any file where CAD Exchanger will demonstrate weaker results, drop me a line and our team will gladly review.

Conclusion

To evaluate CAD Exchanger SDK, please just fill out a brief evaluation form and you will receive further instructions to guide you step by step. Should you have any questions on this topic or any other, feel free to drop me an email at roman dot lygin at cadexchanger dot com. Either myself or my support team will be happy to help.

Thanks for reading!

CAD Exchanger is a technology that enables data exchange in the multi-CAD world.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store