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

Best way for Serialization?

Joel Buehler
Enthusiast

Hehey evryone. 

 

Id like that my user can save his work he did in my plugin into an add-on object. but my project object is quite big and im not firm enough in cpp to write for all sub-objects memmory read and write methods. so i had the idea that i just serialize my object and save the json or xml string into the add-on object. unfortunately in cpp serialization is also a difficult topic.. but did someone do this before and can share some tipps and tricks?  

 

i see that we have in the AddOnCommandTest example some sort of JSON deserialization and in the goodies example there is a small xml serializer and deserializer. 

 

im happy about any kind of suggestions or tipps! 

1 ACCEPTED SOLUTION
2 REPLIES 2
Solution

Hi Joel!

Maybe the example called CommunicationClient_Test would be a good start. It uses the class ObjectState to do the serialization (in general). It uses the functionalities provided by ObjectStateJSONConversion.hpp.

And if you need more examples for that, you can also check out:

  1. https://github.com/tlorantfy/archicad-additional-json-commands/tree/master/Src which uses also ObjectState to create additional JSON interfaces like in the example Add-On and
  2. https://github.com/ENZYME-APD/tapir-archicad-automation/tree/main/archicad-addon which builds even further on top of that.

 

I also suspect that going from ObjectState <-> JSON to ObjectState <-> Binary later would be an option, since there are already functions for this as well.

 

Hope that helps,

Bernd

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

Very Cool! Thank you very much! 

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!