Is there a scripting function that allows reading the Project Description property, as defined under Configure–>System–>Projects–>Edit–>Project Settings–>Description?
Thanks!
Is there a scripting function that allows reading the Project Description property, as defined under Configure–>System–>Projects–>Edit–>Project Settings–>Description?
Thanks!
Try this:
from com.inductiveautomation.factorypmi.application import FPMIApp
desc = FPMIApp.getInstance().clientContext.project.description
Hi pturmel,
Thanks for your reply.
I tried executing it from the Script Console, but get the following message:
> Traceback (most recent call last):
> File "<buffer>", line 2, in <module>
> AttributeError: 'com.inductiveautomation.factorypmi.application.FPM' object has no attribute 'clientContext'
After searching, I found the following API 7.8.1 documentation, which states that the getInstance() method has been deprecated.
Any idea where to find the latest API documentation?
Thanks.
Here is the latest SDK JavaDocs:
http://files.inductiveautomation.com/sdk/javadoc/ignition79/790-beta1/index.html
And here is the answer to your question, but this only works from the client atm.
from com.inductiveautomation.factorypmi.application import FPMIApp
print FPMIApp.getInstance().getClientPanel().getClientContext().getProject().getDescription()
FPMIApp has been deprecated forever.
Actually, there’s a 7.9.4 Javadoc; pretty sure this is the latest release:
http://files.inductiveautomation.com/sdk/javadoc/ignition79/794-beta1/index.html
Also, you can skip FPMIApp.getInstance()
with BasicContainer’s getAppContext()
, eg, from a button:
event.source.parent.getAppContext().getProject().getDescription()
Thanks PGriffith, this works for the project's description:
event.source.parent.getAppContext().getProject().getDescription()
What about the project's title?
event.source.parent.getAppContext().getProject()
Doesn't work...
event.source.parent.getAppContext().getProject().getDisplayTitle()
should work in 7.9 - it will either be the project’s title field, or just the name if the title is unspecified.
event.source.parent.getAppContext().getProject().getTitle()
or getName()
as appropriate should work in 8.0.
Thanks, this works from a button on the window but I cannot get it to work when a window is opened... Im using the following code on a window's internalFramActivated event handler.
system.gui.getParentWindow(event).getComponentForPath('Root Container.projectName').text = event.source.parent.getAppContext().getProject().getDisplayTitle()
system.gui.getParentWindow(event).getComponentForPath('Root Container.projectDescription').text = event.source.parent.getAppContext().getProject().getDescription()
And am getting this error:
AttributeError: 'com.inductiveautomation.factorypmi.application.FPM' object has no attribute 'getAppContext'
event.source.parent
is how you go from a component to its parent, meaning the root container of the window it’s on (assuming you’re not using groups or containers, anyways) - but if you’re running the code and you’re already on a window/root container, then going up to .parent
is giving you an object that doesn’t contain the method getAppContext()
. Try swapping in event.source.rootContainer.getAppContext()
.
Thanks, learning so much from you today, I really appreciate it!
How can I get this in Perspective for ignition 8.1?
Can you get it here?
https://docs.inductiveautomation.com/display/DOC81/system.perspective.getProjectInfo