cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Combining Creo and Zemax

Highlighted
Mat
Regular Member

Combining Creo and Zemax

This will show You, how You can easily import coordinate systems from Zemax to Creo. All code is attached to this blog entry as a zip-file.

The zipfile includes code from these sources:

In Zemax - an optics simulation software - optical elements can be located by their local coordinate systems. This is very helpful if the components of an optical system are not placed in a straight line but dirstributed in xyz directions.

The following scripts uses a text file, which was exported by zemax and is structured like:

<optical_component_name>,<translation in x>,<translation in y>,<translation in z>,<rotation around x>,<rotation around y>,<rotation around z>

e.g. this could be the content of a simple system (see "zemax_csys-export.txt").

! DD.MM.YYYY automatically generated by Zemax

! Generated from Zemax-file: Lensfilename.zmx

SRF_0_base,0.0000000000,0.0000000000,0.0000000000,0.0000000000,0.0000000000,0.0000000000

SRF_1_dummy,0.0000000000,0.0000000000,5.0000000000,0.0000000000,0.0000000000,0.0000000000

SRF_2_lens1,0.0000000000,0.0000000000,6.0000000000,20.0000000000,0.0000000000,0.0000000000

SRF_3_lens2,0.0000000000,0.0000000000,8.0000000000,20.0000000000,0.0000000000,0.0000000000

SRF_4_aperture,0.0000000000,0.0000000000,12.0000000000,0.0000000000,0.0000000000,0.0000000000

SRF_5_dummy,0.0000000000,0.0000000000,14.0000000000,0.0000000000,0.0000000000,0.0000000000

SRF_6_image,0.0000000000,0.0000000000,20.0000000000,0.0000000000,0.0000000000,0.0000000000

This text files was generated by the zemax macro "Export Creo CS text file.zpl".

In Creo Parametric run "zemax_app.html" in Your embedded browser. Make sure ActiveX is activated.

The page will ask you to point to the zemax transfer text file, which contains the coordinate system information.

choose-text-file.PNG

Then the page will read the file's content by using

var active_file = fso.OpenTextFile(filepath, 1, false);

var active_file_string = active_file.readAll();

active_file.Close();

Then the information of the file gets structured in serveral arrays and displayed in a table.

loaded-text-file.PNG

After pressing "Create Csys" the script will create the coordinate systems by using the function "create_csys_from_file()", which was described in https://www.ptcusercommunity.com/people/Mat/blog/2016/02/26/create-coordinate-system-via-weblink .

Hint: It is mandatory, that there is a coordinate system in Your part, which is named "CS_0". This would be the starting point for this import.

At last, all coordinate systems are created and renamed.

csys-created.PNG

Enjoy!