Hello,
I have tried to use sample code from Python Samples [e17s06_py] for changing settings of Detector Rectangle object loaded in predefined system. But when I saved the new system with a new name, settings were still the same as in the predefined system.
How to load predefined system (in file A.zos), change some objects parameters and save the result as a new system (B.zos)?
def load_system(zos, lensdir=lensdir, lensfile=lensfile):
# load local variables
ZOSAPI = zos.ZOSAPI
TheApplication = zos.TheApplication
TheSystem = zos.TheSystem
# Open file
lensname = os.path.join(os.sep, lensdir, lensfile)
TheSystem.LoadFile(lensname, False)
return ZOSAPI, TheApplication, TheSystem
zos = PythonStandaloneApplication()
ZOSAPI, TheApplication, TheSystem = load_system(zos, lensfile='A.zos')
TheNCE = TheSystem.NCE
d = TheNCE.GetObjectAt(18) #Detector Rectangle
o = d.GetObjectTypeSettings(ZOSAPI.Editors.NCE.ObjectType.DetectorRectangle)
d.ChangeType( o)
d.ObjectData.XHalfWidth = 5
d.ObjectData.YHalfWidth = 5
TheSystem.SaveAs('B.zos')
I also tried to remove that object, insert new one and define the new one with new values of parameters. ObjectData are not the same as I defined. In GUI I see values X Half Width = 1 and Y Half Width = 1, but in the code is: “d.ObjectData.XHalfWidth = 5”.
Thanks!