Skip to main content

I'm using the python interface to ZOS API.



I am trying to set the power on a source in the NSE. I can't seem to set this attribute. I am able to set the position, angle, source charateristics etc.



any ideas?



Code: (at least enough to illustrate what I'm doing...)





NSCE = TheSystem.NCE

S = NSCE.InsertNewObjectAt(1)

S.ChangeType(S.GetObjectTypeSettings(constants.ObjectType_SourceDiode))

# This works fine.

S.XPosition = DiodeFaceAtRadius

ObjectSrc = CastTo(S.ObjectData, 'IObjectSources')

# Neither one of these stements does anything.

ObjectSrc.Power = 1.0

ObjectSrc.NumberOfLayoutRays = 100

# This works fine.

ADiodeSrc = CastTo(S.ObjectData, 'IObjectSourceDiode')

ADiodeSrc = CastTo(S.ObjectData, 'IObjectSourceDiode')

ADiodeSrc.DeltaX = 0.18

Hi George,



I used your code in an Interactive Extension and saw that the Power and NumberOfLayoutRays properties updated the system as expected. Can you let me know what version of Python and OpticStudio you're using? Also, are you working in the Standalone Application, or the Interactive Extension? It shouldn't make a difference, but I would like to mimic the test conditions as closely as possible!



In the meantime, you could try the more generic GetCellAt command to make the updates to the Source Diode object. Here's an example of what I mean:



 



objParameters = CastTo(S, 'IEditorRow')


objParameters.GetCellAt(11).IntegerValue = 456


layoutRays = objParameters.GetCellAt(11).Value


print(layoutRays)


objParameters.GetCellAt(13).DoubleValue = 15


power = objParameters.GetCellAt(13).Value


print(power)


 



Will that work for you? Let me know if you have any problems with this method.



Best,



Allie


Reply