Object has no attribute 'Cell Span Data'

Hello, I am trying to set the cell span data of a power table in a python script like this:

cell_span_headers = ["row", "column", "width", "height"]
cell_span_data = []
for i in xrange(0, dataset.getRowCount(), 6):
	cell_span_data.append([i, "Enabled", 1, 6])
cell_span_data = system.dataset.toDataSet(cell_span_headers, cell_span_data)
power_table = event.source.parent.getComponent("Power Table")
setattr(power_table, "Cell Span Data", cell_span_data)

When I run this code I get the following error

16:48:37.640 [AWT-EventQueue-0] ERROR com.inductiveautomation.ignition.client.util.gui.ErrorUtil - <HTML>Error executing script for event:&nbsp;<code><b>actionPerformed</b></code><BR>on component:&nbsp;<code><b>Write L3Towers Targets to Tag</b></code>.
com.inductiveautomation.ignition.common.script.JythonExecException: Traceback (most recent call last):
  File "<event:actionPerformed>", line 100, in <module>
AttributeError: 'com.inductiveautomation.factorypmi.application.com' object has no attribute 'Cell Span Data'

	at org.python.core.Py.AttributeError(Py.java:178)
	at org.python.core.PyObject.noAttributeError(PyObject.java:965)
	at org.python.core.PyObject.object___setattr__(PyObject.java:3821)
	at org.python.core.PyObject.object___setattr__(PyObject.java:3792)
	at org.python.core.PyObject$object___setattr___exposer.__call__(Unknown Source)
	at org.python.core.PyObjectDerived.__setattr__(PyObjectDerived.java:1043)
	at com.inductiveautomation.factorypmi.application.script.PyComponentWrapper.__setattr__(PyComponentWrapper.java:169)
	at org.python.core.__builtin__.setattr(__builtin__.java:1093)
	at org.python.core.BuiltinFunctions.__call__(__builtin__.java:203)
	at org.python.core.PyObject.__call__(PyObject.java:498)
	at org.python.pycode._pyx279.f$0(<event:actionPerformed>:100)
	at org.python.pycode._pyx279.call_function(<event:actionPerformed>)
	at org.python.core.PyTableCode.call(PyTableCode.java:173)
	at org.python.core.PyCode.call(PyCode.java:18)
	at org.python.core.Py.runCode(Py.java:1687)
	at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:788)
	at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.runActions(ActionAdapter.java:206)
	at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.invoke(ActionAdapter.java:299)
	at com.inductiveautomation.factorypmi.application.binding.action.RelayInvocationHandler.invoke(RelayInvocationHandler.java:57)
	at com.sun.proxy.$Proxy102.actionPerformed(Unknown Source)
	at java.desktop/javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
	at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
	at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
	at java.desktop/javax.swing.DefaultButtonModel.setPressed(Unknown Source)
	at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
	at java.desktop/java.awt.Component.processMouseEvent(Unknown Source)
	at java.desktop/javax.swing.JComponent.processMouseEvent(Unknown Source)
	at java.desktop/java.awt.Component.processEvent(Unknown Source)
	at java.desktop/java.awt.Container.processEvent(Unknown Source)
	at java.desktop/java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
	at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
	at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Window.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
	at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.desktop/java.awt.EventQueue$5.run(Unknown Source)
	at java.desktop/java.awt.EventQueue$5.run(Unknown Source)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.run(Unknown Source)
Caused by: org.python.core.PyException: AttributeError: 'com.inductiveautomation.factorypmi.application.com' object has no attribute 'Cell Span Data'
	... 55 common frames omitted

Is there a better way to set the cell span data of a power table?

Take a closer look at the proper property name:

https://docs.inductiveautomation.com/display/DOC81/Vision+-+Power+Table#VisionPowerTable-Properties

{ Names in the property editor are "prettied up" for the user. Hover over them to get the "scripting name", or look at the documentation. }

If you get an error that says a particular property doesn't exist, you either don't have the object you think you have, or you've misunderstood/mistyped the name.

Also, if you are trying to use setattr() to set an attribute that has a not-valid-for-python-or-java name, take that as a hint.

2 Likes

Thanks! I've been searching for the property name and didn't know where to look. That's a huge help.