Script Creation of windows

Hello all,

I have a project to migrate an old scada system to Ignition. The idea is to export the old scada views and variables in a database then create the new project in Ignition.

Let us assume that the database is correctly filled with all needed information.

I can create tags from variables list by using system.tag.addTag(). I can also instanciate templates in an existing window by using com.inductiveautomation.factorypmi.application.components.template

Problem : I am not able to create a new Window in a project. I had a look in the Programmer’s Guide (Chapter 4) and figured that I needed to create a project Resource.
Here is an extract from my code :

from com.inductiveautomation.ignition.common.project import ProjectResource

context = getContext(event)
newResourceId = context.getLockManager().newResourceId()
windowByte = event.source.parent.getComponent('Table').data.getValueAt(0,"CONTENT")

	dataNewWindow = ProjectResource(newResourceId, 'fpmi', 'window', 'WindowTEST',4,windowByte)
except Exception, err:
	print "ERROR", str(err)

the getContext function is defined here. Thank you Nick for sharing.

Now I’m stuck with the last argument of ProjectResource(). I can not figure what to set this argument to. I have tried so far:
[li] String containing pasted code of a designer copied window[/li]
[li] String from a BLOB in a database containing different part of the previous string (from all to only CDATA content)[/li]
[li] Byte Array from a dataSet containing the previous BLOB.[/li]
[li] Empty array[/li][/ul]

My question is : What does the ProjectResource constructor expect for its byte[] data argument?

Thanks in advance for the help.