Showing results 1 to 9 of 9

Thread: Problems with set_DynProperties

  1. #1
    Join Date
    29.04.2013
    Posts
    12

    Default Problems with set_DynProperties

    Hi, I'm having problems with the set_DynProperties function in VTSA. I'm trying to write to the "text line 1" property of the button.

    zenOn.IDynPicture scr = this.thisProject.DynPictures().Item("Screen1");
    zenOn.IElement btn = scr.Elements().Item("Button1");
    btn.set_DynProperties("Text1", "Hello You");

    I've tested to see if scr and btn exist and they do. What am I doing wrong?

    Denis.

  2. #2
    Join Date
    29.04.2013
    Posts
    12

    Default Re: Problems with set_DynProperties

    Does set_DynProperties work in VSTA for project.addin? What is the right path for a text button? I can't find any info on this.

  3. #3

    Default Re: Problems with set_DynProperties

    Hi Denis,

    Changing the button text via the API is not possible in the runtime (Project Addin). What is it that you are trying to achieve?

    When changing the text of a button in the editor, it is a good idea to check if the screen / button with the specified name actually exist, and save the screen afterwards:

           public void Macro_SetText()
            {
                zenOn.IDynPicture scr = this.ActiveDocument.DynPictures().Item("Screen1");
                if (scr != null)
                {
                    zenOn.IElement btn = scr.Elements().Item("Button1");
                    if (btn != null)
                    {
                        btn.set_DynProperties("Text1", "hello you");
                        scr.Save();    
                    }
                }
            }

    Best regards,
    Mark

  4. #4
    Join Date
    29.04.2013
    Posts
    12

    Default Re: Problems with set_DynProperties

    I think that I am confused about the runtime and editor things. Where do I put the c# code for the editor? What is the difference between the editor and the runtime?

    Thanks,
    Denis.

  5. #5

    Default Re: Problems with set_DynProperties

    Hi Denis,

    The c# code for the editor goes into the "WorkspaceAddin". You can access the workspace addin from the zenon editor through the "File" menu, or through the keyboard shortcut "Alt+F10".

    The c# code for the runtime goes into the "ProjectAddin", which can be accessed through the context menu in the project tree for the tree node "Programming Interfaces".

    Basically, you would place Macros in the WorkspaceAddin, to automate engineering of the zenon project in the zenon editor, like automatically creating screens, buttons, etc. You can call these macros through the VBA Macro toolbar after you have compiled the WorkspaceAddin (try the refresh button). Make sure your VSTA Macros start with "public void Macro_". Most of the VSTA wizards in the editor can also be found in source code in the WorkspaceAddin. Feel free to modify / enhance or reuse them as you see fit

    You would place Macros in the ProjectAddin, e.g. to modify the parameters of a runtime function prior to execution. Or to react on events such as variable change events, alarm events or screen events like mouseclick.

    I hope this makes it a bit clearer

    But maybe, you could still explain what you are trying to achieve with changing the button text?

    Regards,
    Mark

  6. #6
    Join Date
    29.04.2013
    Posts
    12

    Default Re: Problems with set_DynProperties

    Basically I wanted to change icons in 10 buttons depending on the screenthat the user is on. Then make them select different screens depending on what icons were showing up. I started with the text because I thought it would be easier. Maybe I have to find another way of going about it.

    So where can I put c# code that will execute while I run it on my hmi? I'd like to do stuff like scroll through pictures/buttons while swiping on the screen, move icons around, animations, ect.

    Thanks,
    Denis.

  7. #7

    Default Re: Problems with set_DynProperties

    Hi Denis,

    Quote Originally Posted by dlamarche View Post
    So where can I put c# code that will execute while I run it on my hmi? I'd like to do stuff like scroll through pictures/buttons while swiping on the screen, move icons around, animations, ect.
    c# code for mouse events / touch events, pointer events and gestures, go into the ProjectAddin, so they are executed during runtime on the HMI.

    Note that for animations, there are exist many different options in zenon that don't require coding in VSTA which can be configured at the dynamic elements in the editor itself.

    I hope this helps
    Cheers,
    Mark

  8. #8

    Default Re: Problems with set_DynProperties

    Quote Originally Posted by dlamarche View Post
    Basically I wanted to change icons in 10 buttons depending on the screenthat the user is on. Then make them select different screens depending on what icons were showing up. I started with the text because I thought it would be easier. Maybe I have to find another way of going about it.
    Not everything in zenon requires coding via VSTA /VBA . In fact most functionality is integrated as standard functionality that requires no coding at all. A majority of projects running on HMIs don't use any VBA or VSTA.

    For your requirement, there are different options. Which approach fits best, depends a bit on your project and further requirements.

    I assume you have some type of operating screen, with those 10 buttons and depending on which main screen the user is currently viewing, these 10 buttons should change in how they are displayed and what functionality they execute. Does that sound about right?

    You could stack buttons in the operating screen, and use the visibility property of the button to link a variable. This variable can be an internal variable that is linked to the "screen active" property of the screen. This way you can make only those buttons visible that are applicable for the screen. This is just one solution, there are other possibilities, like using differet operating screens for each main screen, or integrating the operating buttons in the screen, and use substitution at the function that calls the screen to replace the functions behind the buttons.

    Instead of buttons you could use a combi element that allows showing different graphics based on variable values / variable status.

    I hope this gives you some ideas

    Best regards,
    Mark

  9. #9
    Join Date
    22.04.2021
    Posts
    5

    Frage Re: Problems with set_DynProperties

    Quote Originally Posted by markclemens View Post
    Not everything in zenon requires coding via VSTA /VBA . In fact most functionality is integrated as standard functionality that requires no coding at all. A majority of projects running on HMIs don't use any VBA or VSTA.



    For your requirement, there are different options. Which approach fits best, depends a bit on your project and further requirements.



    I assume you have some type of operating screen, with those 10 buttons and depending on which main screen the user is currently viewing, these 10 buttons should change in how they are displayed and what functionality they execute. Does that sound about right?



    You could stack buttons in the operating screen, and use the visibility property of the button to link a variable. This variable can be an internal variable that is linked to the "screen active" property of the screen. This way you can make only those buttons visible that are applicable for the screen. This is just one solution, there are other possibilities, like using differet operating screens for each main screen, or integrating the operating buttons in the screen, and use substitution at the function that calls the screen to replace the functions behind the buttons.



    Instead of buttons you could use a combi element that allows showing different graphics based on variable values / variable status.



    I hope this gives you some ideas



    Best regards,

    Mark

    Hi, I met similar problem during making an application. I would like to modify some parameters like width or hight of screen elements, such as rectangle. Is this possible to modify it through VSTA macros ? 

Similar Threads

  1. Startup problems
    By croc in forum Engineering Studio & Service Engine
    Replies: 9
    Last Post: 19th June 2019, 08:16
  2. Various Problems about Sicam230 6.22 SP1 Editor
    By ali in forum zenon Energy Edition
    Replies: 1
    Last Post: 14th December 2009, 03:17
  3. Screen Size Problems
    By douglasm in forum zenon Service Engine Operator
    Replies: 1
    Last Post: 23rd June 2009, 07:36
  4. Client - Server communication problems
    By dragosmoss in forum zenon Network
    Replies: 8
    Last Post: 13th May 2009, 14:38
  5. Problems with Message Control
    By doppellhelix in forum zenon Network
    Replies: 1
    Last Post: 24th June 2008, 09:26

Posting Rules

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