How to access 2D or Multidimensional Arrays? #417
-
Hello, does pyads support accessing a 2D array directly? I didn't see anything in the documentation. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
I know you can read an array of an array plc.read_by_name('GVL.sample_array[0][0]', pyads.PLCTYPE_INT) you could try the following for multidimensional arrays: plc.read_by_name('GVL.sample_array[0,0]', pyads.PLCTYPE_INT) Let me know how you get on |
Beta Was this translation helpful? Give feedback.
-
Tested works: Declaration ST: Simple Access: General Implementation:
|
Beta Was this translation helpful? Give feedback.
-
The above code works, but only for a single element, and is very slow when writing large arrays, since each write requires a unique query to the network. The faster way to transfer a large array to/from is to do the entire thing in one query. Below is how to accomplish this. in MAIN POU on PLC:
in PLC Python:
If y'all want to update the documentation go ahead. Thanks. |
Beta Was this translation helpful? Give feedback.
-
there are some useful numpy optimisations that i have for dealing with odd pyads scenarios, i am going to add this one to it! |
Beta Was this translation helpful? Give feedback.
I know you can read an array of an array
you could try the following for multidimensional arrays:
Let me know how you get on