cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

2024 Technology Preview Program:
Master powerful new features and shape the latest BIM-enabled innovations

Archicad C++ API
About Archicad add-on development using the C++ API.
SOLVED!

Dynamic size of UserData

Lk__
Participant

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Solution

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

Bernd Schwarzenbacher - Archicad Add-On Developer - Get Add-Ons & Archicad Tips on my Website: Archi-XT.com

View solution in original post

2 REPLIES 2
Solution

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

Bernd Schwarzenbacher - Archicad Add-On Developer - Get Add-Ons & Archicad Tips on my Website: Archi-XT.com

Hi Bernd, 

 

This looks exactly what I was looking for.

 

Thanks!

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!