Get runtime ressource Perspective/Styles/stylesheet.css is missing from IgnitionGateway.get().getProjectManager().getProject(projectName).get().getAllResources()

I try to retrieve the runtime Perspective/Styles/stylesheet.css
(in a projet with inherited projects)

image

stylesheet.css is missing with the following script:

from com.inductiveautomation.ignition.gateway import IgnitionGateway
context = IgnitionGateway.get()
projectManager = context.getProjectManager()
runtimeProject = projectManager.getProject(projectName).get()
runtimeProject.getAllResources
# Retrieve all ressources from project and its parents
allProjectResources = runtimeProject.getAllResources()

is there any way to retrieve it ?

1 Like

Sure it is.

	from com.inductiveautomation.ignition.gateway import IgnitionGateway
	from com.inductiveautomation.ignition.common.project.resource import ProjectResourceId, ResourceType
	from java.lang import String
	context = IgnitionGateway.get()
	projectManager = context.getProjectManager()
	projectName = system.project.getProjectName()
	runtimeProject = projectManager.getProject(projectName).get()
	stylesheetType = ResourceType("com.inductiveautomation.perspective", "stylesheet")
	
	# option 1 (worse)
	allResources = runtimeProject.getAllResources()
#	for id, resource in allResources.items():
#		system.perspective.print(str(id))
	stylesheetId = ProjectResourceId(projectName, stylesheetType, "")
	stylesheet = allResources[stylesheetId]
	
	# option 2 (better)
	stylesheet = runtimeProject.getSingletonResource(stylesheetType).get()
	
	
	system.perspective.print(String(stylesheet.getData("stylesheet.css"), "utf-8"))
07:51:29.241 [Browser Thread: 0f5d5db5-b048-4f64-951e-b05773b5c913] INFO Perspective.Designer.Workspace - /* Direct stylesheet authoring is an advanced feature. Knowledge of CSS required.*/
1 Like