How can I move a page from 1 report to another report? I do not see an easy way to do it.
Iām wondering the same, I want to duplicate a page in the same report
Any way to do this simply? I am also wondering.
Bump, same question. It is painful to duplicate one currently..
Well, by some definition of "easy", this works. I put this all in the script console, but you should able to park the script in the project library and just invoke from the script console.
Grumble grumble don't call into support if this doesn't work. This snippet is provided with no warranty, no expectations or disclaimers of support, your mileage may vary, etc. If you are encountering an issue with this, please post it here on this thread or make a new public forum thread about it, linking to this post.
from time import sleep
from java.awt import EventQueue
from java.lang import Runnable
from com.inductiveautomation.rm.editor import RMEditorClipboard, RMEditorPaneUtils
from com.inductiveautomation.reporting.designer.workspace import ReportingResourceWorkspace
from com.inductiveautomation.ignition.designer import IgnitionDesigner
from com.inductiveautomation.reporting.common.resource import ReportResource
from com.inductiveautomation.ignition.common.project.resource import ResourcePath
def copyPage(sourceReport, sourcePage, targetReport, targetPage = -1):
designer = IgnitionDesigner.getFrame()
workspaceManager = designer.workspace
reportWorkspace = None
for i in range(workspaceManager.workspaceCount):
workspace = workspaceManager.getWorkspace(i)
if workspace.key == ReportingResourceWorkspace.WORKSPACE_KEY:
reportWorkspace = workspace
class OpenReport(Runnable):
def __init__(self, path):
self.path = path
def run(self):
resourcePath = ResourcePath(ReportResource.RESOURCE_TYPE, self.path)
reportWorkspace.open(resourcePath)
sleep(1)
sourceEditor = reportWorkspace.findEditor(resourcePath).orElseThrow()
sourceEditor.showDesignPanel()
sleep(1)
EventQueue.invokeAndWait(OpenReport(sourceReport))
sleep(1)
pageToCopy = RMEditorPaneUtils.getMainEditor().document.getPage(sourcePage)
EventQueue.invokeAndWait(OpenReport(targetReport))
sleep(1)
if targetPage >= 0:
RMEditorPaneUtils.getMainEditor().document.addPage(pageToCopy, targetPage)
print "Copied page", sourcePage, "from report", sourceReport, "to report", targetReport, "at page", targetPage
else:
RMEditorPaneUtils.getMainEditor().document.addPage(pageToCopy)
print "Copied page", sourcePage, "from report", sourceReport, "to the end of report", targetReport
sourceReport = "a"
sourcePage = 0 # 0 index
targetReport = "b"
targetPage = -1 # -1 to append to the end, or a 0-indexed page to insert
copyPage(sourceReport, sourcePage, targetReport, targetPage)
Hah!
Thank you for the "easy" solution, it works like a charm!