Issues with object named PropertyTreeScriptWrapper MapWrapper


Hi all,

I am having trouble making copies to an object in python to translate over to another object. For example:

a = props.plots[index].trends

props.plots[index+1].trends = a

This completely wrecks the json structure, giving me a value type of “PropertyTreeScriptWrapper$MapWrapper” whose full path is “com.inductiveautomation.perspective.gateway.script.PropertyTreeScriptWrapper$MapWrapper”. Normally this is not an issue, I know I can treat this as a dictionary.

However, this particular json is nested with other json/dicts/lists in it. I can recursively go through it and make a copy to get rid of the object, but that’s terrible and I do reach the recursion depth limit sometimes. It’s not slow by any means, but that could change at high number of items. It’s presence is halting development.

I’d rather not use recursion, so how can we completely cast that object as a dict wherever it appears, or is there an alternative to copying that entire json over (aside from copying it piece by piece by knowing what the structure should look like for each json occurence). I’d also rather not copy each json piece by piece in order to move it to another json, but if we have to we have to.




What happens if you try:

a = props.plots[index].trends.tolist()
props.plots[index+1].trends = a


This is also something we’re (I’m) actively working on fixing - at minimum, the PropertyTreeScriptWrapper and related classes will be able to pass into the builtin dict function to make a native Python structure.

Unfortunately, no firm timeline on that fix - hopefully 8.0.5.



I see why it is required though, it’s a pointer to the object and not so much a standalone json. It works extremely well for assigning values in-situ to the object in question, but just not for simple copy operations since it’s acting as a pointer and not a json/dict. All we really would need is a method or scripting function to convert that object into its respective tree.

I managed to fix my script and used this to achieve it what I needed, temporarily.

	def copy(self, d):
		#typeNameWrapper = "com.inductiveautomation.perspective.gateway.script.PropertyTreeScriptWrapper$MapWrapper"
		typeNameWrapper = "PropertyTreeScriptWrapper$MapWrapper"
		typeNameArray = "array"

		if isinstance(d, list) or self.getTypeName(d) == typeNameArray:
			output = []
			for val in d:
		elif isinstance(d, dict) or self.getTypeName(d) == typeNameWrapper:
			output = {}
			for key in d:
				output[key] = self.copy(d[key])
			output = d
		return output
    def getTypeName(self, val):
		return type(val).__name__




This works, but only for the first level. Any nested jsons will remain as their object and need to be casted to a dict/list as well. The script provided above takes care of the issue recursively for me until there is a fix for it.