Hello, I am using code in ZPL which include exporting of objects (non-sequential mode) to CAD files-created by Zemax community:
SUB export
IF PureNSmode == 1
start_number = num_objects + 1
end_number = new_object - 1
ELSE
start_number = surf_no
end_number = surf_no
ENDIF
# Export the solid objects as CAD files
VEC1(1) = ext # CAD file type
VEC2(2) = 8 # spline segments
VEC1(3) = start_number # start surface
VEC1(4) = end_number # end surface
VEC1(5) = 1 # ray data layer
VEC1(6) = 0 # lens data layer
VEC1(7) = 0 # do not export dummy surfaces
VEC1(8) = 0 # do not export surfaces as solids
VEC1(9) = 5 # ray pattern NONE
VEC1(10) = 0 # number of rays = 0
VEC1(11) = 0 # wavenumber
VEC1(12) = 0 # field number
VEC1(13) = 0 # do not 'delete vignetted'
VEC1(14) = 1 # dummy thickness
VEC1(15) = 0 # do not split rays
VEC1(16) = 0 # do not scatter rays
VEC1(17) = 0 # do not use polarization
VEC1(18) = 0 # use the current configuration
!PRINT " Saving to: " file$
EXPORTCAD file$
# Erase all the extra objects
!PRINT " Erasing objects #",num_objects+1,"-",new_object-1,"...",
IF (new_object - num_objects) > 1
FOR i, num_objects+1, new_object-1, 1
DELETEOBJECT surf_no, num_objects+1
NEXT
PRINT
!PRINT "DONE"
ENDIF
UPDATE ALL
RETURN
Everything was fine until I start to use new version of ANSYS OpticStudio 2024r1. Exported CAD files are corrupted and miss there information (and subsequently they are incorrectly imported into cad software)... also results file has different content:
2024r1 (STL file):
...
facet normal 0 1 0
outer loop
vertex 80 200 80
vertex 80 200 0
vertex -80 200 0
endloop
endfacet
endsolid 1 written by HOOPS Exchange
….
Zemax OS 22.3 (STL file):
SPATIAL INTEROP STL WRITER COLOR=żżż˙ \ -==P_—˝žż@,6Ä’ÄEłŤCłż5Ä˝ŇÄEłŤCč5ĵ‚Ä•ÉŤC -==P_—˝žżč5ĵ‚Ä•ÉŤCłż5Ä˝ŇÄEłŤC |5Äŕ>Ä•ÉŤC -=˝P_—=ž?—î5Ä?yĜȎC
...