2024 Technology Preview Program:
Master powerful new features and shape the latest BIM-enabled innovations
2023-10-14 08:15 PM
Hello,
I want to attach (and than read) some user data to attributes I'm creating in my add-on.
The thing is the data is actually an array of strings of various lengths and sizes.
Technically, I know the size of the entire data buffer when creating the handle for saving, but what about reading?
I assume that Archicad knows how many bytes it allocated for the handle when retrieving data, but how do I get that?
Should I attach this information in the data itself? Or is there another, more 'proper' way of dealing with this?
Solved! Go to Solution.
2023-10-16 12:33 AM
Hi TK!
You can get the size of the entire data buffer when reading with BMGetHandleSize.
Assuming you are storing a list of strings, I think it would be best to read and write the single entries delimited with a null character "\0". When you read the data, you'd iterate through the characters until you hit the \0 character and that would mark the end of the current string entry.
An alternative would be to work on a bit higher level and use GS::IChannel/GS::OChannel. You can see an example of their use in AddOnObject_Manager example project. I think one could adapt that approach to be used for element user data.
Hope that helps! Let me know if in case you need more information on this.
Bernd
2023-10-16 12:33 AM
Hi TK!
You can get the size of the entire data buffer when reading with BMGetHandleSize.
Assuming you are storing a list of strings, I think it would be best to read and write the single entries delimited with a null character "\0". When you read the data, you'd iterate through the characters until you hit the \0 character and that would mark the end of the current string entry.
An alternative would be to work on a bit higher level and use GS::IChannel/GS::OChannel. You can see an example of their use in AddOnObject_Manager example project. I think one could adapt that approach to be used for element user data.
Hope that helps! Let me know if in case you need more information on this.
Bernd
2023-10-16 09:08 AM
Hi Bernd,
This looks exactly what I was looking for.
Thanks!