15 Challenges in converting Rhino (.3dm) to Parasolid (x_t)

March 12, 2021

admin

Blog, Technology

0

15 Challenges in converting Rhino (.3dm) to Parasolid (x_t)

There are many CAD/CAM modelers available in the market (like SolidWorks, Rhino, Autodesk Inventor etc), each supporting a  different file format. If you want to convert one format to another then you need to write an exporter which will read/traverse each geometry present in the file (.3dm) and map it with the corresponding entity in another file (x_t) format. As every modeler has its own way of representing a geometry (like tolerance, unit, geometry creation etc.) so you might face some challenges while exporting one format to another.

In this blog, I am covering a few challenges one might face in the design of a Rhino to Parasolid converter.

1. NURBS creation: In Rhino the number of knots is m = n + p – 2 but in Parasolid the number of knots are m = n + p where n is number of control points and p is the order of curve, so in Parasolid there are two additional knots required to draw a NURBS curve. When Rhino is exporting and importing NURBS geometry, it automatically adds and removes these two superfluous knots as the situation requires. After reading the NURBS data from Rhino you have to add two superfluous knots at the start and end of the knots. This will help you to successfully create a B-Curve.

For rational NURBS curves creation in Parasolid you have to modify data coming from Rhino by increasing the dimension value by one, this will help to create a rational B-Curve in Parasolid.

2. Poly-curve creation: Rhino has a Poly-curve type for curve geometry which is basically a curve object having multiple curves (like – arc, line, polyline, NURBS etc). To handle this in Parasolid you can add a loop and create these curves separately.

3. B-Rep geometry creation: B-Rep can be created in Parasolid using Topology or Trim surface (Sewing a surface to form solid/sheet geometry) approach. For converting Rhino B-Rep geometry to Parasolid it is better to use the Trim surface approach because it is very difficult to create Topology for complex Rhino models.

4. Sum Surface creation: In the Rhino Sum surface are created using two curves, first is a base curve which will get extruded and second curve is the path curve which gives the path of extrusion. You can create Sum Surface in Rhino using sweep API but the curve location we get from Rhino is not correct. To create Sum surface at correct location you can either create Sum surface using NURBS data or you can use boundary curves from an ON_SumSurface object, it is best to get them using ON_SumSurface::IsoCurve(), rather than accessing the ON_SumSurface::m_curve.

5. Transformation of a curve Rev Surface creation: In Rhino for Rev surface you get a curve, rotation axis, and start and end  angle of rotation. You can create a corresponding surface by using Spin API, but this API takes curve, rotation axis and angle of rotation as input. Problem is Parasolid spin API doesn’t take start and end angle as input (it only takes a single angle). Now to correctly create Rev surface in Parasolid you cannot use the Rhino curve directly, you need to first translate the curve to a correct position using the rotation start angle. To that you have to create a transformation matrix by using the rotation start angle, rotation axis and rotation axis start coordinate. After transformation of a curve you can use spin API to create a Rev surface in Parasolid.

6. Extruded object creation using B-Rep: For creating extruded geometry in Parasolid it is better to use B-Rep data as it is easy to handle cases where extrude bodies are having slant surfaces or having cut (trimming) at some angle.

7. Trim a surface in Parasolid: For trimming Rhino surfaces in Parasolid we need to collect trimming curve data, but the trim curve data we get from Rhino does not have a trim loop and set data is required for trimming a surface in Parasolid. To handle this you need to write an algorithm which will collect the trim curve data and reorder it to come a continuous curve else it fails to trim the surface.

8. Fault while trimming NURBS surface in Parasolid: While trimming NURBS curves sometimes the surface trimming API gives ‘914’ error code which means that the surface is G1 continuous which is closed but not periodic. As a workaround for this problem you can disable the continuity check for the session. Or you can use the Parasolid BodyShop toolkit. This toolkit has a separate license, it is useful to repairs, optimizes and validates CAD data imported into Parasolid.

9. Find and fix faults in Parasolid: After creating a geometry like curve or surface in Parasolid you can use the Geom check API to check if there is any fault. Degeneracy and self intersecting are the common faults that can be found in curves and surfaces.
Parasolid provides different APIs which can be used for finding and fixing such problems on curves and surfaces. Sometimes while fixing degeneracy or self intersecting problems, Parasolid fix APIs sometimes split a curve or surface so you need to take care of these splits.
You can also check faults on Body by using a body check API, if there is any fault on face or edge then you can easily resolve the faults using face repair and edge repair API. If Parasolid repair APIs are still not able to fix the faults then you can also go for Parasolid BodyShop toolkit.

10. Scale Rhino entity to meters: Every unit in Parasolid is in meters (its size box is 1000 x 1000 x 1000 in meters), so if you are exporting Rhino model into Parasolid then you have to scale the model in meters else sometimes your model will not appear in the view and you will also get out of size box fault. You can get the model unit form ONX_Model object which has all the model settings. It is advised to transform the Rhino geometry and then convert it into Parasolid also don’t transform the original geometry, create a copy of the geometry using an ‘Duplicate()’ method.

11. Create instance definition block only once: As a block (geometry) present in instance definition can be referred more than once in the original model so to avoid geometry repetition you can first traverse the instance definition component and create its corresponding geometry (store it in some data structure container), you can refer these geometry objects once you get instance reference object while traversing model geometry and apply transformation to it.

12. Linked file reference file in Rhino: Instance definition blocks can also have linked file reference, which means that another Rhino (.3dm) file is referred to as a block in instance definition. To traverse a linked reference file you need to call your traversing code recursively.

13. Range of tolerance for trimming: While creating a trimming Rhino surface in Parasolid you can use surface trimming API. This API takes surface and trimming curve data as input, you need to provide the correct curve trim loop and set for trimming. Tolerance also plays a very important role in trimming a surface. You can use a range of tolerance values for trimming surfaces API (to get better results) then you have to recreate the surface and trimming curve data. Because once the surface and trimming curve is passed to the trimming API (and trimming got failed) you cannot use that data again for trimming with new tolerance. 

14. Copying the Rhino entity: Every geometry object in Rhino has a ‘Duplicate()’ method which creates a copy of the geometry object. You should always work on the copy object as it will not impact an actual geometry object. It is your responsibility to free the memory of the duplicate object.

15. Receive old version x_t file in session: For receiving parts from older Parasolid x_t files you need a corresponding schema file. Parasolid setup comes with a schema folder, you can either set the schema folder path in ‘P_SCHEMA’ environment variable and use it in the session/frustrum or you can also keep a copy of schema folder with your project like it is done in Example App provided by Parasolid. If Parasolid frustrum fails to find the schema file for that version then it will not be able to read the part from the x_t file.

Conclusion

Writing a converter is a challenging task as evey modeler has its own way of representing a geometry. This blog covers a few of the major challenges that one might encounter while converting a Rhino entity to Parasolid. This blog will help to reduce the time and efforts required whenever you start designing your own convertor.

Author: Mahendra S.
Contact us:
info@prototechsolutions.com
ProtoTech Solutions

Leave a Reply

Your email address will not be published. Required fields are marked *