Showing results 1 to 3 of 3

Thread: Add Variables with C# to Zenon (Editor-Mode)

  1. #1
    Join Date
    09.03.2015
    Posts
    34

    Default Add Variables with C# to Zenon (Editor-Mode)

    Hi,

    I am searching for a solution to add variables with C# to an open Project in the Zenon Editor.

    I am currently using the following code...

    this.zVariable = this.zProject.Variables()
    .CreateVar(psVariableName, null, tpKanaltypes.tpSystemVariable, GetDataType("STRING"));

    But I cannot see the created Variable in the Zenon Editor?!

    What's wrong?

    Regards...

  2. #2
    Join Date
    13.08.2013
    Posts
    57

    Beitrag Re: Add Variables with C# to Zenon (Editor-Mode)

    Hi Nollh,
    you are missing the drivertype

    try something like this, I solved it with an extension method, but you always can do it with a "normal" method
     public static zenOn.IDriver InternalDriver(this zenOn.Project pProject)
            {
                for (int i = 0; i < pProject.Drivers().Count; i++)
                {
                    if (pProject.Drivers().Item(i).Name == "Intern")
                    {
                        return pProject.Drivers().Item(i);
                    }
                }
                return null;
            } 
    public void createVar()
    {
    this.zVariable = this.zProject.Variables()
    .CreateVar(psVariableName, this.zProject.InternalDriver(), tpKanaltypes.tpSystemVariable, GetDataType("STRING"));
    }

    Best regards
    Sigi

  3. #3
    Join Date
    09.03.2015
    Posts
    34

    Default Re: Add Variables with C# to Zenon (Editor-Mode)

    Thanks for your help!

Similar Threads

  1. Can not restore a *.prj file from the zenOn Explorer with the zenOn Editor
    By kyle_lee in forum zenon Service Engine Supervisor
    Replies: 5
    Last Post: 30th July 2018, 10:45
  2. Add a variable type 'byte'
    By martijnvanspijk in forum Drivers
    Replies: 2
    Last Post: 28th May 2013, 11:00
  3. Add element to zenOn ListBox
    By fabios in forum VBA
    Replies: 1
    Last Post: 30th November 2012, 15:30
  4. Zenon 6.51 license vs. Demo mode
    By rbfernandez in forum zenon Service Engine Operator
    Replies: 2
    Last Post: 30th November 2012, 08:45
  5. Replies: 0
    Last Post: 20th August 2007, 17:04

Posting Rules

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •