Python fit object face (ex. for CAD)

  • 24 October 2022
  • 2 replies
  • 432 views

Userlevel 6
Badge +2

Attached file shows alternative method to the following code.

ZPL Macro:Fit CAD surface as a sequential surface

 

It uses ZOS-API with Python. The benefit is we will generate the fitting system automatically. 

A document is provided to show a simple example about how to use it.


2 replies

Userlevel 5
Badge +3

If you encounter such problem:

AttributeError: module 'clr' has no attribute 'AddReference'

You can try to uninstall the clr and follow the instruction below:

Getting started with Python – Knowledgebase (zemax.com)

 

 

Userlevel 4
Badge +2

If you are using PythonNET 3.0 and experiencing the error below, you can use the attached file. For more information about the changes in PythonNET 3.0, please refer to the following discussion.

 

System.ArgumentException: since Python.NET 3.0 int can not be converted to Enum implicitly. Use Enum(int_value) in method Boolean ReadNextSegmentFull(Int32 ByRef, Int32 ByRef, Int32 ByRef, Int32 ByRef, Int32 ByRef, ZOSAPI.Tools.RayTrace.RayStatus ByRef, Double ByRef, Double ByRef, Double ByRef, Double ByRef, Double ByRef, Double ByRef, Double ByRef, Double ByRef, Double ByRef, Double ByRef, Double ByRef, Double ByRef, Double ByRef, Double ByRef, Int32 ByRef, Int32 ByRef, Double ByRef, Double ByRef, Double ByRef, Double ByRef, Double ByRef, Double ByRef, Double ByRef) ---> Python.Runtime.PythonException: since Python.NET 3.0 int can not be converted to Enum implicitly. Use Enum(int_value)
   --- End of inner exception stack trace ---<---

Reply