How to import CAD objects

This article is part of the Illumination Systems Fundamentals free tutorial.

This article describes how to import CAD objects into OpticStudio, using STL, IGES, STEP, and SAT formats.

The choice of CAD format you use is likely to be based on the CAD program you use. STL is good for objects that are inherently faceted, or where you will use stereolithography to generate rapid prototypes. IGES and STEP are CAD exchange standards, and the choice between them will probably be based on the quality of your CAD program's export routines. SAT format will be used if your CAD program is based on the ACIS engine.

Authored By Mark Nicholson

Introduction

The ability to import CAD objects into OpticStudio is very important, particularly when undertaking complex opto-mechanical stray light simulations, where reflections and scattering from mounts is critical. It is also important in illumination systems, where light may be directed down a complex-shaped light pipe, for example in automotive dashboard design. OpticStudio has powerful and flexible CAD import capabilities and supports common CAD exchange formats.

Importing CAD objects

Because CAD objects can be of arbitrary complexity, a ray may interact with it many times. As a consequence, we use non-sequential ray tracing to describe the interaction of rays with CAD objects. CAD objects may be easily included in otherwise sequential optical systems by using hybrid mode non-sequential ray tracing.

OpticStudio supports four static CAD formats: STL, IGES, STEP and SAT (in addition to dynamic formats, such as SLDPRT and ZPO, not discussed in this article). Of these, only STL uses facets to represent the object; the other three model the object as a smooth, continuous surface shape. Facets are only used to draw these objects on screen, but do not affect the object beyond the aesthetic. Therefore, ray tracing to the continuous, smooth CAD surface is exact (at least to the limit of the accuracy of the CAD model) despite facets being used to draw the object.

It’s important to note that although OpticStudio supports genuinely faceted objects, in most cases facets are only used for rendering purposes, and the real surface shape used for ray tracing is exact.

STL format

STL (Stereolithography Tesselation Language) format is widely used in rapid prototyping and allows easy definition of very general shapes. It is based on a tri-mesh representation of the object, in which the surface shape of the object is approximated by a set of triangular facets.

Modern Machine Systems gives a useful overview of the STL format.1 Each facet in an STL file is defined by the {x,y,z} coordinates of the three corners, and the surface normal vector. Here, for example, is the first few lines of a sample STL file produced by AutoCAD:

 solid AutoCAD

facet normal 0.0000000e+000 0.0000000e+000 1.0000000e+000

outer loop

vertex 6.0000000e+000 4.0000000e+000 6.0000000e+000

vertex 6.0000000e+000 6.0000000e+000 6.0000000e+000

vertex 4.0000000e+000 6.0000000e+000 6.0000000e+000

endloop

endfacet

facet normal 0.0000000e+000 0.0000000e+000 1.0000000e+000

outer loop

vertex 6.0000000e+000 4.0000000e+000 6.0000000e+000

vertex 4.0000000e+000 6.0000000e+000 6.0000000e+000

vertex 4.0000000e+000 4.0000000e+000 6.0000000e+000

endloop

endfacet


(Note that OpticStudio imports both ASCII and binary versions of the STL format). The nature of STL makes it ideal for modelling objects like faceted reflectors and prisms. However, it is less good at modelling smoothly curved objects, where the facetization errors are likely to affect ray tracing accuracy.

STL objects are imported using the CAD Part: STL object type. The .stl file must be placed in the {Zemax}\Objects\CAD Files folder.

Non-sequential_component_editor

Once imported it is positioned like any other object.

In this example, the prism is exactly modelled by flat facets, but the sphere is only approximated:

The_prism_is_exact_but_the_sphere_is_approximate

The sphere is formed by a tri-mesh approximation:

A_close-up_of_the_sphere_shows_the_approximation

In this case, the facets drawn on screen are exactly those generated in the STL file, and rays interact with a series of flat facets.

IGES format

The Initial Graphics Exchange Specification (IGES) is an American National Standard whose intended purpose is to facilitate transfer of data between CAD programs. OpticStudio currently supports version 5.3 of the IGES standard. CAD Exchange is one of many reliable resources with more information on the IGES file format.2

IGES objects are stored in the {Zemax}\Objects\CAD Files folder, and are imported by the CAD Part: STEP/IGES/SAT object:

The_Object_properties_dialog

This object is exported from SolidWorks:

A_CAD_object_exported_from_Solid_Works

Now this object is exported using whatever SolidWorks considers most appropriate (probably NURBS).3 It is rendered on-screen using facets, because IGES objects can be extremely complex:

This_view_uses_facets_only_for_on-screen_drawing

It is important to note that OpticStudio uses these facets for only one reason: to draw the object on-screen. IGES objects are represented internally as exact, smooth objects, not as a set of facets like STL objects.

STEP format

STEP, the Standard for the Exchange of Product Model Data, is a comprehensive ISO standard (ISO 10303) that describes how to represent and exchange digital product information.4

For the OpticStudio user there is little difference between IGES and STEP. Both works well with OpticStudio, and your choice between these two standards is likely to be based on the quality of your CAD program's export routines. IGES is the older format, and several CAD vendors use their own export translator, which leads to some variation between vendors. STEP is newer, and most CAD vendors use bought-in libraries like Step Tools, which means that there may be more uniformity between different CAD packages' implementation of STEP.

STEP objects are accessed and behave exactly like IGES objects in OpticStudio.

SAT format

The SAT format is used by the ACIS geometry modeling engine developed by Spatial Technologies.5 It directly represents the internal data structures of the ACIS modeler. That means if you load an SAT file into an ACIS-based CAD program, there's normally no translation at all: the file goes straight in. Hence this is not a "CAD Exchange" format but is better describes as a purely CAD format.

You will most likely see the SAT file format if you use an ACIS-based CAD program and will probably not use it at all if you don't. Again, this format is a smooth, continuous object representation. Usage is exactly as per the IGES file format.

Imported CAD object properties and parameters

There are a set of properties that you can use to control the imported object. These controls are found in the Non-Sequential Component Editor parameter cells and Object Properties window. This discussion applies to all four CAD import types previously mentioned.

The_properties_of_the_Imported_Object

The properties are:

Material. Only one material can be applied per object. As this coffee pot consists of a glass jar, plastic lid, plastic handle, aluminum ring to hold the handle onto the jug, and some metal screws that hold the handle onto the ring, these objects should be exported from the CAD package separately, and then imported into OpticStudio individually. Alternatively, the imported object can be Exploded to expose each individual component as a separate CAD object (the steps to do so are shown in the Knowledgebase article "How to explode a CAD assembly"). Then each sub-object can be given the appropriate optical properties. The use of relative object references allows all sub-objects to be positioned relative to a master object, so that the whole coffee pot can be moved and rotated as a single unit.

Scale. This is a dimensionless scale factor that allows you to increase or decrease the size of the object.

Mode. The Mode flag controls the tradeoff between set-up time and ray tracing speed. Use mode 1 for fast set up time and slower ray tracing, mode 2 for medium set up time and medium ray tracing, and mode 3 for slow set up time and fast ray tracing. Generally, use mode 1 during set-up of the system in OpticStudio, and mode 3 for tracing a large number of rays for detailed analysis. Note: accuracy is not affected by the mode flag. Only ray-tracing speed and the initial loading time of the object is affected.

X, Y and Z Voxels define how many volume elements are used to define an invisible bounding box in which the object is defined. Voxel technology allows for fast ray tracing by precomputing which objects, or portions of objects, lie within a given voxel. A ray entering a voxelated space may only intersect some subset of the total number of voxels; and therefore, only these voxels need to be checked for possible ray-object intersections. The greater the number of voxels, the longer the set-up time but the faster the ray tracing. It generally takes some experimenting to determine the optimum number of voxels. Note that accuracy is not affected by the number of voxels. Only ray-tracing speed and the amount of memory required to represent the object is affected.

Explode? A flag which indicates whether the CAD part has been exploded. This is used by OpticStudio, and not set by the user. In order to explode a CAD object, use the CAD...Explode CAD Assembly tool in the toolbar of the Non-Sequential Component Editor.

Chord Tolerance. This setting is available in the Object Properties...CAD tab. The effects of the Chord Tolerance parameter depend on the applied CAD library. In case of using the SMS CAD library it affects only the rendering of the solid within the layout plots. On the other hand, in case of using the ACIS CAD library the Chord Tolerance together with the Maximum Edge Length control not only the rendering of the object, but also affect the ray trace speed and accuracy in a similar way to the Drawing Resolution for native OpticStudio objects. To render the solid, OpticStudio converts the solid to list of triangles which approximate the shape. The tolerance is the maximum allowed distance in lens units between a single triangle and the actual surface of the solid. More triangles are added if the tolerance is set smaller which yields more accurate results, at the expense of speed and a larger memory requirement. In case of the ACIS CAD library, this setting is also used to provide a first guess as to the location of the ray-object intercept point. So the smaller the triangle the closer the initial guess is to the correct solution and the more likely OpticStudio will converge to the correct intersection. The default value of zero will use a chord tolerance related to the size of the object sufficient to generate a coarse approximation of the object shape that will render quickly. 

Trace mode. Using the ACIS CAD library there are four ray Trace mode options available, although Standard is the default and recommended setting:

  • Standard – this is the default mode; rays are traced to the faceted model, then an iterative method is used to converge to the true intersection to the underlying NURBS geometry; the ray is reflected/refracted based on the surface normal at the intersection point.
  • Flat – rays are traced to the triangles only and reflected/refracted based on the normal of the triangles plane.
  • Shaded – rays are traced to the triangles only and reflected/refracted based on an interpolated normal from the vertices of the triangle.
  • Kernel – uses the ray tracer built in to the ACIS library. Note that this method is extremely slow, but highly accurate and can serve as a reference. This is the only mode that does not rely on the faceting of the object.

Comments on accuracy and ray tracing speed

Objects from CAD packages import easily using the STL Object for faceted objects and Imported Object for continuous, smooth objects using IGES, STEP or SAT file formats.

Not all types of surface shapes may be ray traced with adequate accuracy using representations supported by CAD file formats, such as IGES, SAT, and STEP. For planes, spheres, and cylinders, the CAD representation, if done correctly, is of very high precision suitable for optical accuracy ray tracing. However, higher order shapes do not usually have a native representation in CAD formats.

For example, an aspheric surface with a polynomial term of the form r16 may have no equivalent representation in the chosen CAD format. A CAD program will generally approximate this shape using a segmented spline,3 which is generally a piece-wise fit of the surface using multiple lower order polynomials. Typically, multiple third or fourth order polynomials are used to approximate the surface. This is probably adequate for mechanical design, but not for optical precision ray tracing, where surfaces must be known to tiny fractions of the wavelength of light.

This problem often arises when a high optical precision surface is modeled in OpticStudio, then exported as a CAD file, then imported as an CAD file for subsequent ray tracing. For example, the optical precision of the part is lost upon exporting the native OpticStudio asphere as a CAD spline.

For non-imaging optics, and when importing mechanical parts for stray-light analysis, the precision of the CAD representation is usually adequate. For imaging systems, great care must be taken to verify that the imported CAD part is a suitably accurate description of the desired shape. Note that OpticStudio uses a relative internal optical precision of about 1E-12 for ray tracing. Most CAD representations of objects are many orders of magnitude coarser.

Simple objects such as spherical lenses typically ray trace slower when imported in CAD format than the native OpticStudio object of identical shape. In general, always use OpticStudio's built-in objects where a suitable object exists. Ray tracing speed for imported objects is critically dependent upon the efficient representation of the solid shape within the imported file.

The identical object may be represented in a nearly infinite number of ways using the various solid and surface entity types supported by the CAD formats OpticStudio can import. For example, an efficient representation of an object may use only a few spline surfaces, while an inefficient representation of the object may use hundreds of smaller spline surfaces. Although from a mechanical modeling perspective the two representations may both be valid and the resulting solids identical, the representation with the larger number of spline surfaces will ray trace slower. The only remedy is to return to the source of the CAD file and see if a more efficient representation may be generated. We have experience of seeing several orders of magnitude difference in both exported object size and ray-tracing speed by tuning the CAD programs export routines to yield the most efficient representation.

References

1. Beard, Tom. "Machining From STL Files." Modern Machine Shop. January 01, 1997. Accessed January 17, 2019. http://www.mmsonline.com/articles/019704.html.

2. CADEX Ltd. 2008. IGES. Accessed 2019. https://cadexchanger.com/iges.

3. Tiller, Wayne, and Les A. Piegl. 1996. The NURBS Book (Monographs in Visual Communication). Springer.

4. STEP Tools, Inc. 2019. What is STEP? http://www.steptools.com/stds/step/step_1.html.

5. Dassault Systemes. 2019. Spatial. https://www.spatial.com/.

ACIS and SAT are registered trademarks of Spatial Corporation.

 

KA-01667

Was this article helpful?
5 out of 7 found this helpful

Comments

0 comments

Please sign in to leave a comment.