compas icon indicating copy to clipboard operation
compas copied to clipboard

Docs Suggestion: using DataDecoder, DataEncoder with custom user classes

Open yck011522 opened this issue 5 years ago • 0 comments

Feature Request

I figured that I could encode and decode my own class objects with the same DataDecoder , DataEncoder system. As long as I implemented the following functions:

  • def to_data(self):
  • @property def data(self):
  • @classmethod def from_data(cls,data):

This works also if my objects is recursively placed within a compas.datastructure type objects, such as a Network. This function is fantastic (kudos to all devs who made this happen) and I think more people should be aware of it. Perhaps a simple page of documentation / example code can be added either within the pages of DataEncoder and DataDecoder. or in Tutorials.

yck011522 avatar Nov 06 '20 15:11 yck011522