I need to read out the X half width and Y half width of a Detector Rectangle. The above code used to work but now it says no AttributeError: 'IObject' object has no attribute 'XHalfWidth'. Could you tell me a way to circumvent this problem.
When using the ZOS-API with Python. If something was working before and got broken, I always suspect this:
In your case, I think if you do:
x_half_width = d.ObjectData.__implementation__.XHalfWidth
It should fix your issue. I think it got broken when you installed a more recent version of Pythonnet (>2.5.2). You could also roll back Pythonnet to 2.5.2, but I think its less desirable. Also, I highly suggest looking at ZOSPy (mentioned at the end of the post I linked above), which alleviate such issues.
Take care,
David
Thanks, David, All works now. just one more thing to added, I noticed that access XHalfWidth and ZPosition need different syntax. It used to be identical.
When using the ZOS-API with Python. If something was working before and got broken, I always suspect this:
In your case, I think if you do:
x_half_width = d.ObjectData.__implementation__.XHalfWidth
It should fix your issue. I think it got broken when you installed a more recent version of Pythonnet (>2.5.2). You could also roll back Pythonnet to 2.5.2, but I think its less desirable. Also, I highly suggest looking at ZOSPy (mentioned at the end of the post I linked above), which alleviate such issues.
Take care,
David
Good to hear. As far as I can remember, ZPosition
has always been a property of the INCERow
interface (instance of d
in your code above). Are you saying that you were able to do the following before?
x_half_width = d.XhalfWidth
I don’t remember this being possible, but I could be wrong. You could also get the X Half-Width column by using the GetCellAt(int pos)
method of INCERow
, which lets you retrieve any cell of the NCE. Fox X Half-Width it would look like so:
d.GetCellAt(11).DoubleValue
It’s a little bit trial and error to figure out int pos
, which is why there is ObjectData
. But perhaps you find this method to be more direct.
In any case, don’t forget you can also read the Release Notes here:
https://community.zemax.com/opticstudio-release-notes-71
To check whether significant changes are being introduced in OpticStudio (including the ZOS-API).
Take care,
David
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.