Skip to main content

I have created a custom object based on the sample of the HalfCylinder.DLL object. So far, this works. I would like to return a value directly to the non-sequential component editor. E.g. for the half cylinder, add a field volume and return the current volume. This way during optimization, I can control the volume of the cylinder without using extra scripts to use the volume. I tried to use an extra field, and then attribute a value inside the code:

in the given half cylinder, in line 64 (just before the switch(code)):

data[104] = volume;

but the volume field in zemax’ non-sequential component editor is not updated.

I hope to get along the idea of I want to do. For the volume, I could use a script in zemax, but imagine it is value that I calculate in cpp anyway, it would be more efficient to reuse this. Is this possible?

@joachim

 

As far as I understand, the communication of the NCE column data to the DLL is unidirectional (the column aren’t updated after the DLL is run).

If you look at HalfCylinder.c, in line 58-60, you find some basic error trapping:

if (R <= 0.0) R = 1.0;
if (L <= 0.0) L = 1.0;
if (N < 6) N = 6;

What this means is that if, for example, the radius R, which is coming from the Radius column, is strictly smaller than 0.0, then the DLL sets the radius R to 1.0. But, if you put a Radius of -5.0 in the NCE, this value remains at -5.0, while the HalfCylinder is drawn with a Radius of 1.0.

I’m not an expert in this, but what I think happens is that when OpticStudio needs the DLL, it sends the column values to the DLL, and then gets in return what it needs to represent the object, perform ray traces, ...etc. Some people have asked how data can be shared between DLLs before, such as this post:

In this instance, I think the proposed solution is to write data to a file, and then parse the data where you need it. This will of course add some overhead, and its not clear what will be the most efficient way (vs scripting in OS as you mentioned).

PS: there’s also a bit of a semantic issue with your example because given a specific volume, there are multiple HalfCylinders who could be correct.

I hope this helps and take care,

 

David


Reply