Script the owning object
- Last UpdatedJul 08, 2024
- 2 minute read
The owning object in a ShowGraphic script function resolves only relative references. Any absolute reference is not affected by the owning object. The owning object is independent of the graphic definition. The relative reference is resolved by the object that hosts the script. For example, where GraphicName = "me.S1" or "Obj1.S1", and OwningObject = "Obj2", the owning object resolves only the relative reference in the graphic S1.
Consider a scenario where there are two automation object instances, "Reactor_001" and "Reactor_002" in a user application. Both instances have four user-defined attributes, int1, int2, real1 and real2, and the graphic S1.
The graphic (Reactor_001.S1) has the following UDA references:
-
Me.int1 (relative reference)
-
Me.real1 (relative reference)
-
Reactor_001.int2 (absolute reference)
-
Reactor_001.real2 (absolute reference)
If you configure Reactor_001.S1 with the ShowGraphic script ("me.S1" or "Reactor_001.S1", OwningObject = "Reactor_002") and execute the script at run time, the system displays Reactor_001.S1, though the relative reference within this graphic points to Reator_002 object.
In such a case:
-
The graphic always opens from only the host automation object instance, here "Reactor_001".
-
The GraphicName property can be set to relative reference, absolute reference or the Visualization folder graphic name. If a relative reference is used in the GraphicName property, then the graphic will always open from only the host automation object instance, here "Reactor_001". If an absolute reference or Visualization folder graphic name is used in the GraphicName property such as "Reactor_001.S1" or "S1", then the system will search for such graphic by its name.
-
The relative references for Me.int1, Me.real1 is redirected to Reactor_002.
-
The absolute references for Reactor_001.int2 and Reactor_001.real2 come from Reactor_001 only, and are not redirected to Reactor_002.
Relative references (such as me.int1) used in custom property override on embedded graphics would resolve to the owning object of the embedded graphic. Whereas the relative references used in container scripts would resolve to the owning object of the graphic where the script is configured.