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

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

Combining Creo and Zemax

Mat
13-Aquamarine
13-Aquamarine

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!


This thread is inactive and closed by the PTC Community Management Team. If you would like to provide a reply and re-open this thread, please notify the moderator and reference the thread. You may also use "Start a topic" button to ask a new question. Please be sure to include what version of the PTC product you are using so another community member knowledgeable about your version may be able to assist.
0 REPLIES 0
Top Tags