Skip to main content

Hello,

So I’ve been getting into the zos-api. I’ll not that I have little experience in object-oriented programming, so that might be limiting me. I’ve been trying to be able to target specific columns in the NCE editor for editing and having trouble doing so generically.

Currently, the only way I’ve found to do is the following (as an example):

Object.GetObjectCell(ZOSAPI.Editors.NCE.ObjectColumn.Par1).DoubleValue=value

With “par1” being the enum element of ObjectColumn. The problem is, I cant find a way to change that without straight-up adding a new line. So if I wanted to be able to, for example, modify several columns, I would need to have multiple lines, each with their own call. I’ve tried to make a function to do it generically, but I cant figure out a way to change it (The “Par1”).

I’ve found 2 functions that seem related, but dont really allow my to alter that element on the fly.

Enum.Getname finds a string corresponding to the enum element from an interger;

Enum.Parse does the opposite, using a name to generate an interger

I’ve tried looking at python more broadly, but I’m still loking for decent tutorials on OOP in python.

Thanks in advance for any help!

 

 

@William Oak 

 

Have you had a look at this as well?

In short using ObjectData, you call can a parameter by its column name. Here is an example for X Half Width of a Rectangle object:

rectangle = TheSystem.NCE.GetObjectAt(1)
print(rectangle.ObjectData.__implementation__.XHalfWidth)

This doesn’t address the multiple parameters assignment though. This is more complicated because of the types that every parameter of every object can have. Do you have a more detailed description of what you are trying to achieve?

Take care,


David


Thanks, you’ve guided me to exactly what I needed! I’ll keep looking for a way to ID an object type to simplify things for me.

 

 


I thought I’d share for others who may find it useful:

    def change_NCE_cell_content(TheSystem, row_no, column_no, value):
TheNCE=TheSystem.NCE
Object=TheNCE.GetObjectAt(row_no)

if Object.GetCellAt(column_no).DataType==0 and isinstance(value,int) :
Object.GetCellAt(column_no).IntegerValue=value
elif Object.GetCellAt(column_no).DataType==1 and isinstance(value, float):
Object.GetCellAt(column_no).DoubleValue=value

elif Object.GetCellAt(column_no).DataType==2 and isinstance(value, str):
Object.GetCellAt(column_no).Value=value

else:
sys.exit("ERROR, VALUE DOES NOT MATCH DATA TYPE")

You need to have TheSystem already called, but otherwise you just put in the row number, the column number, and the new value wanted in the cell. Hope else someone can make use of it!


Reply