Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

Generate objects by code

agarcia
2020-03-26
2020-04-01
  • agarcia - 2020-03-26

    I'm trying to create code to generate objects in a visualization and sort them like boxes on a pallet. I have been searching in different topics and I have not found anything similar. Could someone tell me if this option is possible?

    On the other hand, can the width and length of a rectangle be modified? Because another option would be to create a specific number of objects and modify their position and size.

     

    Last edit: agarcia 2020-03-26
  • i-campbell

    i-campbell - 2020-03-26

    For me, if you can fix the number of objects, this is the best. Yes, rectangles can move. In its properties assign variables to Absolute movement, relative movement. These include position and scaling 'movements'.
    You can generate these with multiply elements..
    https://help.codesys.com/webapp/_visu_create_similar_elements_in_many_cases;product=core_visualization;version=3.5.15.0

     
    πŸ‘
    1
    • agarcia - 2020-03-26

      Thanks for your answer.

      If I have understood this correctly, I will be able to multiply already created objects, correct?

      Do you know any way to modify the width and length of the rectangles?

       
  • m.prestel - 2020-03-31

    Using these properties you can also change the width/height of the rectangle (not only the top left position)

    Best regards,
    Marcel

     
    • agarcia - 2020-03-31

      But I can't modify this property with a variable. I would like to modify this property based on a variable so that I can visualize the resizing in the product. I've seen that in scaling you can add a variable but this doesn't work for me.

       
      • appling - 2020-03-31

        Which codesys version are you using? For me (3.5.7) I can put variables there without problems. What is your compiler error? My variables are of type INT, maybe you are trying something different?

         
        • agarcia - 2020-03-31

          I get the following error when I enter the variable in the object property.

           
          • appling - 2020-04-01

            Looks like iHight is no variable of the INT data type. How have you declared iHight? And where have you declared it?
            Try this in a global variable list or in a Program:
            iHight : INT;
            and then access the variable in the visu page like this: MyVariableList.iHight
            If you have declared iHight within a program you will have to write the qualifier before the variable, so maybe that is your problem?

             
            • agarcia - 2020-04-01

              I have declared the variable as global without the attribute, anyway I tried to add access and I get the same message.

               
              • appling - 2020-04-01

                This is weird because the exact same setup works for me. I have one last idea:
                Try initializing the values with a non-zero value (it should be the starting coordinate of your edge on the visualization canvas). So for example iWidth : INT := 100;
                I hope this does the trick.

                 
                • m.prestel - 2020-04-01

                  You cannot put variables into X/Y/Width/Height

                   
                  • appling - 2020-04-01

                    Yes that is true! I thought we were talking about the movement variables!

                     
                    • m.prestel - 2020-04-01

                      thought the same, just wanna make sure we are all on the same page ;)

                       
                    • appling - 2020-04-01

                      I see what happened:
                      m.prestel said: "Using these properties you can also change the width/height of the rectangle (not only the top left position)" and meant that you can use the "relative movement" properties to adjust the dimensions of the object. Try putting your variables there.

                       
  • appling - 2020-03-31

    Hi,
    as i-campbell and m.prestel said, you can use the absolute movement property to move your elements on your visualization page.
    You can use the relative movement property to "move" only the right/bottom edge of your object, which makes it possible to change the size of your visualization elements.
    I am using this feature to "animate" some of my visualization pages and it works pretty good. I have tested it using up to 30 moved elements which did not slow my cycle time down (obviously this will depend on the hardware you are using). I would be interested if someone tried moving even more elements and observed performance issues.
    best regards

     
  • i-campbell

    i-campbell - 2020-03-31

    How many objects would you be interested in?

     
  • appling - 2020-03-31

    I don't know - for my current scenario the 20 circles that I am moving are plenty. Will codesys restrict the number of moving elements at some point?

     

Log in to post a comment.