Skip to main content

Hi,



There is a field 'Data File' in the GUI when Source File is selected as the source (in non-sequential mode). How can I load this file using the ZOS-API (NET connection in Python)? I create a ray file using Python in the right path (\ZEMAX\Objects\Sources\Source Files)



I found the tutorial for navigating the API documentation very useful, unfortunately I couldn't figure out how to do this.



Is there a way to turn my txt file to binary through the API?



And could I export the image from a detector directly using the API?



 



Thank you!

Hi Elisavet,



The property that you need to modify to set the .DAT file being used by the Source File is FileName1. If you look at Example 21 in our sample code files, you'll see it being used to set 'RAYFILE_LB_T67C_100K_190608_ZEMAX.DAT' as the source data:



#! [e21s03_py]


# Set 1st object as a Source File


Object_1 = TheNCE.GetObjectAt(1)


Typeset_SourceFile = Object_1.GetObjectTypeSettings(ZOSAPI.Editors.NCE.ObjectType.SourceFile)


Typeset_SourceFile.FileName1 = 'RAYFILE_LB_T67C_100K_190608_ZEMAX.DAT'


Object_1.ChangeType(Typeset_SourceFile)


Object_1.GetObjectCell(ZOSAPI.Editors.NCE.ObjectColumn.Par1).IntegerValue = 5


Object_1.GetObjectCell(ZOSAPI.Editors.NCE.ObjectColumn.Par2).IntegerValue = 1000


Object_1.GetObjectCell(ZOSAPI.Editors.NCE.ObjectColumn.Par3).DoubleValue = 2.485572


Object_1.GetObjectCell(ZOSAPI.Editors.NCE.ObjectColumn.Par8).DoubleValue = 0.47


Object_1.GetObjectCell(ZOSAPI.Editors.NCE.ObjectColumn.Par9).DoubleValue = 0.47


#! [e21s03_py]






As for the conversion from text to binary data, I don't think we have any native tool that performs this action. I think it would have to be something that you create yourself -- for example, we do have a related article which covers going from binary to text formats. You can read that here, and it comes with a sample code and executable file to perform the conversion.



Lastly, we do not currently have a way to save images from layout and analysis windows from the API. What we do recommend, if possible, is to leverage something like the EXPORTJPG/EXPORTBMP ZPL keywords, though this would mean writing a macro rather than working within the API.



Please let us know if you have any more questions here!



~ Angel


Reply