LIMITATIONS ON ITEM.SETNAME() AND ITEM.SETVALUE()- Printable Version +- RoboDK Forum (//www.sinclairbody.com/forum) +-- Forum: RoboDK (EN) (//www.sinclairbody.com/forum/Forum-RoboDK-EN) +--- Forum: RoboDK API (//www.sinclairbody.com/forum/Forum-RoboDK-API) +--- Thread: LIMITATIONS ON ITEM.SETNAME() AND ITEM.SETVALUE() (/Thread-LIMITATIONS-ON-ITEM-SETNAME-AND-ITEM-SETVALUE) |
LIMITATIONS ON ITEM.SETNAME() AND ITEM.SETVALUE()-sig.johnnson-05-04-2023 I have an application where it would be useful to store custom information with RoboDK's target objects. (The information is related to the state of the broader machine when it reaches a certain target.) This way, the information would persist across saves of the .rdk workstation rather than becoming unlinked from the robolink.Item handles associated with those targets when my robolink.Robolink() connection closes. To this end, I have two questions: 1. Is the robolink.Item.setValue() method in active use right now? Or might I be able to co-opt it? If it's user-available, does it work like a Python dict? (Or would you be able to share other additional documentation for the function of .setValue()?) 2. What is the character limit for robolink.Item.Name()? (As a plan-B, I can dump the data I want into a string and store it in the target name.) As a workaround, it's possible to store the target handle / target data link as pickled data in a file, but it makes it tricky and somewhat indeterminate if targets get modified in the workstation without Python's knowledge. RE: LIMITATIONS ON ITEM.SETNAME() AND ITEM.SETVALUE()-Albert-05-05-2023 You can store custom binary data by using item.setParam("parameter", bytevalue), and you can retrieve it by using item.getParam("parameter"). This feature was added for this purpose and at RoboDK we use it internally to create apps and new products. Example:
Code:
mydata = b'custom byte array'
item.setParam has a different behavior when the second parameter is a string. More information here: //www.sinclairbody.com/doc/en/PythonAPI/robodk.html#robodk.robolink.Item.getParam RE: LIMITATIONS ON ITEM.SETNAME() AND ITEM.SETVALUE()-sig.johnnson-05-05-2023 Thanks, Albert. That's exactly what I was looking for. |