Hi itsjdl,
I’m not convinced OpticStudio is the right tool to do that. Your approach sounds reasonable and I can’t comment further on why it isn’t working, but you might be better off using something like Python (or MATLAB if you have it) to perform the fit. In Python, SciPy has some handy features to do just that. Have a look at this thread. You mainly need to modify the fit function (called function in the answer) to match whatever freeform surface you want (the equations can be found in the Help File typically).
Once the fit is done, you can input the parameters in OpticStudio. You could even automate the work with the ZOS-API.
Hope this helps.
Take care,
David
segdata = ZRDResult.ReadNextSegmentFull(1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
21, 22, 23, 24, 25, 26, 27, 28, 29)
Python.Runtime.PythonException: since Python.NET 3.0 int can not be converted to Enum implicitly. Use Enum(int_value)
The above exception was the direct cause of the following exception:
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)
Hi itsjdl
When I run it at line 195 it seems that the interface is not compatible.
Environment:
zemax: 20.2.1
python: 3.10.0