When you save a drawing, AutoCAD creates an instance of the AcDbDwgFiler and passes it to all the entities that requires a save. Entities write the information about themselves using that filer instance.
On similar lines, it is possible to implement your own DwgFiler by deriving from AcDbDwgFiler and implement its virtual methods such that they write to a buffer. The instance of your custom filer can then be passed on to the entities that you are interested in by calling its "dwgOutFields".
So, yes, it is possible to do that.
But, if you can explain more about what you are trying to achieve by this technique, other experts in this forum may suggest an alternate way of doing it without needing this technique if that is possible.
I was aware of the AcDbDwgFiler, and the possibility of deriving from it, i just haven't been able to figure out (i'm probably blind) how to point out a buffer to the filer. Sorry if i am not clear enough.
I only need to save some entities in one of our own file formats.
There we need to create a "DWG SECTION" where we save information about the entities in binary.
So suppose i iterate through the database and stumble upon an entity i need to save.
Do i call dwgOutFields on it, or are there other intermediate steps? And how to i instantiate an AcDbDwgFiler derived object that points to a buffer?
Thanks for taking interest in my problem.
I dont understand what you mean by "AcDbDwgFiler derived object that points to a buffer"
The buffer is a class member variable that you will maintain in your derived class.
Let me clarify how this might work :
1) Derive a class from AcDbDwgFiler, say AcDbMyDwgFiler
2) Have a buffer (say of type AcString) as a class member variable in AcDbMyDwgFiler class
3) Override all the virtual methods of AcDbDwgFiler and provide an implemention of those methods such that they update the AcString member variable. For example, the "writeDouble" method should update the string based on the double parameter.
Regarding the usage of the AcDbMyDwgFiler :
When you iterate the model space and find entities that interest you, then create an instance of the AcDbMyDwgFiler by getting its AcRxClass and using it to call the "AcRxClass::create" method.
Finally call the dwgOutFields method on the entity and pass-in the instance of AcDbMyDwgFiler.
Now you have the buffer from the AcDbMyDwgFiler class and you can use it as you need it.
Hope this clarifies.
Access a broad range of knowledge to help get the most out of your products and services.