Scripting the Z-Order of an object

Is there a way to have a timer script constantly update the z-order of a specific object? I want to add a condition for one object to be hidden behind another until the condition is true. I was wanting to add 1 to the z-order of said object during this condition. I looked up that this is possible using the z-index function in java, but I’m not sure how to do it in Python within Ignition

-D :thumb_left:

1 Like

Well you could try calling the setComponentZOrder(Component comp, int index) method on a container to set the z-order index on a component in the container.

Example:

container = event.source.parent
container.setComponentZOrder(event.source,10)
1 Like

I got the z-order to change thanks to your suggestion. The issue now is that when I launch the project, the z order only updates when you change the tag in designer and then save (then updating the project in the full screen). I have a timer script running on property change so I don’t think it’s a scan issue with the tag.

also : is there a way to view the z index number of an object within designer?

You can print out the z order index with:

container = event.source.parent
print container.getComponentZOrder(event.source)

I don’t understand, what do tags have to to with z order indexes on components? What tag?

Sorry, referring to my original post. I have an expression that when said tag value is below 4 to change the z index to 8. else it will change it to 9. When I manually modify this tag in the OPC tag browser, the running project does not update the z-order on the live graphics until the original project is saved within designer.

Can you show the expression and the script that changes the z order?

Can you write a simple event script that changes the z order of a component? Does it work in the client?

I have a timer on the screen set to 100ms scan cycle.

On property change, this timer sets a custom property (int) on my object equal to the current count of the timer, cascading the property change to the object itself.

I have an on-property change script on the object :

[code]if system.tag.read(“eicn133PLC/Global/currentDomePosition”).value < 4:
container = event.source.parent
container.setComponentZOrder(event.source,9)

else:
container = event.source.parent
container.setComponentZOrder(event.source,8)[/code]

See if calling repaint() fixes things:

if system.tag.read("_eicn133PLC_/Global/currentDomePosition").value < 4: 
   container = event.source.parent
   container.setComponentZOrder(event.source,9)

else:
   container = event.source.parent
   container.setComponentZOrder(event.source,8)

container.repaint()

That worked flawlessly! Thanks! :smiley: