ZOS-API Interface Functions#

These are low-level functions to interface skZemax with the ZOS-API.

skZemax.skZemax_subfunctions._ZOSAPI_interface_functions._CheckIfStringValidInDir_(self, in_obj: Any, in_string: str, extra_include_filter: str | list | None = None, extra_exclude_filter: str | list | None = None, check_if_upper: bool = False) Any[source]#

Looks at a Zemax class/module/etc and sees if the given string is an attribute/call within the Zemax code (via a dir() call). This function returns the value of the attribute in the Zemax code. Returns None if string does not match anything.

If the given string matches more than one attribute, the first attribute within the dir() call will be given.

Parameters:
  • in_obj (Any) – The Zemax object to inspect.

  • in_string (str) – The string to find within the object. This is not case sensitive.

  • extra_include_filter (str, optional) – A string which (or list of strings), if provided, will keep only the elements of the dir() call that have this sequence within it, defaults to None

  • extra_exclude_filter (str, optional) – A string which (or list of strings), if provided, will exclude all the elements of the dir() call that have this sequence within it, defaults to None

  • check_if_upper (bool, optional) – If True, will only keep elements - of the object dir() - which are all upper cased, defaults to False

Returns:

he value of the Zemax object indicated by the string. None is returned if the string is not found.

Return type:

Any

skZemax.skZemax_subfunctions._ZOSAPI_interface_functions._SetAttrByStringIfValid_(self, in_obj: Any, in_string: str, in_value: Any, extra_include_filter: str | list | None = None, extra_exclude_filter: str | list | None = None, check_if_upper: bool = False)[source]#

Looks at a Zemax class/module/etc and sees if the given string is an attribute/call within the Zemax code (via a dir() call). This function sets the value of the attribute in the Zemax code.

If the given string matches more than one attribute, the first attribute within the dir() call will be given.

Parameters:
  • in_obj (Any) – The Zemax object to inspect.

  • in_string (str) – The string to find within the object. This is not case sensitive.

  • in_value (Any) – The value one would like to set the attribute/call identified by the in_string.

  • extra_include_filter (Union[str, list], optional) – A string which (or list of strings), if provided, will keep only the elements of the dir() call that have this sequence within it, defaults to None

  • extra_exclude_filter (Union[str, list], optional) – A string which (or list of strings), if provided, will exclude all the elements of the dir() call that have this sequence within it, defaults to None

  • check_if_upper (bool, optional) – If True, will only keep elements - of the object dir() - which are all upper cased, defaults to False

skZemax.skZemax_subfunctions._ZOSAPI_interface_functions.__LowLevelZemaxStringCheck__(self, in_obj, extra_include_filter: str | list | None = None, extra_exclude_filter: str | list | None = None, check_if_upper: bool = False) list[source]#

A low level function which produces a list of values given by python’s dir() call - after some additional filtering.

Parameters:
  • in_obj (_type_) – The object for which the contents will be listed.

  • extra_include_filter (str, optional) – A string which (or list of strings), if provided, will keep only the elements of the dir() call that have this sequence within it, defaults to None

  • extra_exclude_filter (str, optional) – A string which (or list of strings), if provided, will exclude all the elements of the dir() call that have this sequence within it, defaults to None

  • check_if_upper (bool, optional) – If True, will only keep elements which are all upper cased, defaults to False

Returns:

A list of the objects attributes (after any filtering)

Return type:

list

skZemax.skZemax_subfunctions._ZOSAPI_interface_functions._convert_raw_input_worker_(self, in_value: int | Any, object_type: Any, return_index: bool = True) int | Any[source]#

ZOS-API commonly uses a scheme of indexing objects within an array. For instance, a surface can be an object or a corresponding index number. This is a low level worker function which compares and converts Zemax index integers and Zemax object types to return what another function needs regardless of the user’s input. This is intended only to be called by other functions in skZemax submodules.

Parameters:
  • in_value (Union[int, Any]) – Either an index or an object of a Zemax data type.

  • object_type (Any) – The Zemax object type which should correspond to the index.

  • return_index (bool, optional) – Selects weather to return the index (True) or the object at that index (False), defaults to True

Returns:

Either the index of the object, or the object at the index depending on bool state of return_index.

Return type:

Union[int, Any]

skZemax.skZemax_subfunctions._ZOSAPI_interface_functions._ctype_to_numpy_(self, data: Any, data_length: int, data_type: Any = <class 'numpy.int64'>) Any[source]#

This method is a port from the example code attached to the ZemaxRaytraceSupplement/RayTrace.dll. This conversion helps interface python with the C# code.

Parameters:
  • data (Any) – A pointer to a double reported by the C# code.

  • data_length (int, optional) – The pointer array length to read in.

  • data_type (Any, optional) – The type of data to expect from the C# code, defaults to np.int64

Returns:

The value(s)

Return type:

Any