Add IndexSubstitution or SubstiVar via API in Zenon12

Add IndexSubstitution or SubstiVar via API in Zenon12

Hello everyone,

I am currently facing an issue with the zenon API and I am running out of ideas what I might be doing wrong.

I am developing an Engineering Studio Wizard that creates ScreenSwitch functions.
Creating the ScreenSwitch itself works fine (picture, monitor, etc.), but I am struggling to correctly create and persist an IndexSubstitution (or SubstiVar) via the API.

No matter which approach I try (SetDynamicProperty, setting [-1], using indexed paths like [0].Source / [0].Destination), the substitution entries are not stored. When I read the values back immediately, the count stays 0, and in the XML export no <IndexSubstitution_0> / <SubstiVar_0> node is created.

It seems that the substitution collections are handled internally via a PropertyParameterAdapter, but I cannot find a documented or working example on how to properly create and fill these entries programmatically.

Has anyone successfully implemented IndexSubstitution or SubstiVar for ScreenSwitch functions via the zenon API and could point me in the right direction?

Any help or example code would be greatly appreciated.

Thank you very much!


  1. // Erstelle Funktion - Bildumschaltung
  2. IFunctionCollection functionCollection = myProject.FunctionCollection;
  3. IFunction newfunction = functionCollection.Create(sFunktionBildumschaltung, FunctionType.ScreenSwitch);

  4. newfunction.SetDynamicProperty("PictSwitch.Picture", "stbNewEnStatus");
  5. newfunction.SetDynamicProperty("PictSwitch.Monitor", "-2"); //Relativ Bildumschaltung

  6. newfunction.SetDynamicProperty("PictSwitch.IndexSubstitution[0].Source", "zziNewEnStatusVarvalue");
  7. newfunction.SetDynamicProperty("PictSwitch.IndexSubstitution[0].Destination", $"{sPfad}");

  8. newfunction.SetDynamicProperty("PictSwitch.IndexSubstitution[-1]", "1");