ObjectARX

Reply
Active Contributor
Bica.Bogdan
Posts: 30
Registered: ‎06-12-2012
Message 1 of 4 (208 Views)

Copy entity data to dwg buffer

208 Views, 3 Replies
11-26-2012 12:56 AM

Hello,

I'm wondering if it's possible to copy data about one or more AcRxObject(AcDbEntity to be more precise) in the DWG format to a buffer.

Any ideas?

ADN Support Specialist
Balaji_Ram
Posts: 691
Registered: ‎03-21-2011
Message 2 of 4 (168 Views)

Re: Copy entity data to dwg buffer

12-03-2012 07:00 AM in reply to: Bica.Bogdan

Hello,

 

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.

 

 



Balaji
Developer Technical Services
Autodesk Developer Network

Active Contributor
Bica.Bogdan
Posts: 30
Registered: ‎06-12-2012
Message 3 of 4 (155 Views)

Re: Copy entity data to dwg buffer

12-04-2012 07:38 AM in reply to: Balaji_Ram

Hi!

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.

 

ADN Support Specialist
Balaji_Ram
Posts: 691
Registered: ‎03-21-2011
Message 4 of 4 (128 Views)

Re: Copy entity data to dwg buffer

12-06-2012 08:59 AM in reply to: Bica.Bogdan

Hello,

 

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.



Balaji
Developer Technical Services
Autodesk Developer Network

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.