Get Project Property 'Dock Axis Precedence' In Scripting

Hi, for resizing purposes I would like to get the value of the 'Docking Axis Precedence' in the 'Project Properties'.

I found a topic where it was possible to found the project description using folowing code:
print(str(event.source.parent.getAppContext().getProject().getDescription()))

Thanks in advance

This is probably a bad idea, and I would encourage you to not try to rely on specific information like this from the runtime when designing your windows. That said...

print(str(event.source.parent.getAppContext().getPrimaryDesktop().getAxisPrecedence()))

Thanks,

The reason I would like to use this is cause I use floating non maximized windows that I resize accordingly to be for instance a 'west overlay' that functions like an overlay (not cropping the main window) instead of a docked window that crops the main window. See screenshot:

I've written some project scripting functions (getOverlayWidth, getOverlayHeight and getLeftTop ect.) to detirmine sizes and points in my framework. These functions depend on 2 ignition docked windows, a north and a west one with a dock index of -1. Whenever the client starts I open these windows: north with a height of 0 and west with a width of 0, so you dont actually see them. Afterwards I use those windows to determine the width (north docked window) and height (west docked window) of the actual client runtime.

In my example you can see that my dock axis precedence is set to 'North/South' so to determine my actual overlay width I take the width of my north docked window and subtract it with the width of all my other open east or west windows:

# Get west and east docks width
winDockEastWidth = 0
winDockWestWidth = 0
for window in system.gui.getOpenedWindows():
	if window.getComponentForPath('_parent').dockPosition == winDockLocationEast:
		winDockEastWidth = winDockEastWidth + window.width
	if window.getComponentForPath('_parent').dockPosition == winDockLocationWest:
		winDockWestWidth = winDockWestWidth + window.width

# Get overlay width
return system.gui.getWindow(winPathClientDockSizeWidth).width - winDockEastWidth - winDockWestWidth

Whenever for some reason somebody changes this axis precedence, there is no need to subtract the east nor west dock. Thats why I like to know the axis precedence.

Now I realize this is a tricky way of working around the Ignition Vision posibilities, and after testing I've also noticed that I get other values for the axis precedence in 'Designer Testing' (play button) gives me 'North / South' and the actual Ignition client gives me 'Ă‚ÂżAxisPrecedence.NorthSouth?'. It stil give me north and south so I can get it out but this might change in future Ignition updates.

So, if you have a better solid option to get the actual client runtime width and height (red line A in the screenshot) so I don't need to use the trick with hidden docked windows that would make my day and probably be a better solution. I tried playing around with code I found at:
https://forum.inductiveautomation.com/t/how-to-get-vision-client-resolution/27328/4.
But this ends up in giving me the display resolution and not the actual client drawing resolution.

Next to this one more question. I got your solution working from a button, but how do i get to the getAppContext() from within project scripting?

Big thanks upfront already.

To get the client size. You will actaually want the root's contentPane, as the JFrame size includes the border.

I stuck this on a button, but it should work in the internalFrameActivated event as well.

from javax.swing import SwingUtilities
component = event.source

# Get the root JFrame
root = SwingUtilities.getRoot(component)
JFrameSize = root.size
JFrameWidth = JFrameSize.width
JFrameHeight = JFrameSize.height


# Get the ContentPane (Inside the borders)
contentPane = root.getContentPane()
contentPaneSize = contentPane.size
contentPaneWidth = contentPaneSize.width
contentPaneHeight = contentPaneSize.height

print 'JFrame: {} x {}'.format(JFrameWidth, JFrameHeight)
print 'ContentPane: {} x {}'.format(contentPaneWidth, contentPaneHeight)
5 Likes

Hi Jordan, thanks for the reply. It indeed works. Although I have still one problem.
Whenever en update is available and the update message underneath the windows commands pops up, it doesn't change in height value. Which does work with using hidden windows. Is there a way to catch this?

Thanks

No idea, as it doesn't change the dimensions of the root JFrame.

@PGriffith, can we catch the project update message in a vision client?

Another option, if on 8.1.24, is to skip using our project update banner and provide your own (or disable it completely):

1 Like