Skip to main content

I am having trouble changing settings in the ZOS API when trying to do a single ray trace in Python.



My code:



        ray_trace = self.theSystem.Analyses.New_RayTrace()


        if ray_trace.IsRunning():


            ray_trace.WaitForCompletion()


        settings = ray_trace.GetSettings()



When I try to set the Py to 0, I get



settings.Py = 0


*** AttributeError: '' object has no attribute 'Py'



How do I change settings for a single ray trace?



 

Hi Tony



The RayTrace analysis has dedicated settings:





I have tried the following commands using Python.NET and it works correctly:



RayTrace=TheSystem.Analyses.New_RayTrace();


Settings=RayTrace.GetSettings ();


Settings.Py


1.0


So I would recommend checking with the Interactive Extension to understand what is going on. You can also check the types of the variables returned:





And last thing. Are you using Python.NET or Python using the COM communication?



If you are using the COM communication, then this might be why you have an error. You will need to cast the settings. Have a look at that article:  ZOS-API using Python. You will need to write something like



thesettings_RayTrace = CastTo(Settings, 'IAS_RayTrace') 


Let us know if that helps and do not hesitate if you have any further questions.



Sandrine


Reply