How to save an entity to a file

How to save an entity to a file

songmaverick
Contributor Contributor
551 Views
6 Replies
Message 1 of 7

How to save an entity to a file

songmaverick
Contributor
Contributor

I would like to save a list which including many entities to a .txt in order to read it to blockTableRecord.

I would like to serialize these entities and save to a file. But the Object is not marked as serializable..

Anyony could tell me how to solve this?

 

Thanks in advance!!

songmaverick_0-1693538042299.png

 

 

0 Likes
Accepted solutions (2)
552 Views
6 Replies
Replies (6)
Message 2 of 7

kerry_w_brown
Advisor
Advisor
Accepted solution

@songmaverick 

Without knowing how you are making the blockTableRecord, you may be able to achieve your goal by either ;

saving the ObjectID 

or the drawingName and Handle (if in a different database )

as well as any other data you need.

 

Frankly, it's a task that requires some planning, but the data required and the way you save the data depends on how  you intend building the blockTableRecord.

 

Regards,


// Called Kerry or kdub in my other life.

Everything will work just as you expect it to, unless your expectations are incorrect. ~ kdub
Sometimes the question is more important than the answer. ~ kdub

NZST UTC+12 : class keyThumper<T> : Lazy<T>;      another  Swamper
0 Likes
Message 3 of 7

daniel_cadext
Advisor
Advisor

Maybe subclass a dwgfiler / dxffiler and implement iserializable

edit, or maybe just use wblock

Python for AutoCAD, Python wrappers for ARX https://github.com/CEXT-Dan/PyRx
0 Likes
Message 4 of 7

ActivistInvestor
Mentor
Mentor
Accepted solution
There is no 'push-button' means of serialization for AutoCAD objects. You would have to implement the entire serialization mechanism yourself, which is no small undertaking. The end result would be not much unlike a binary DXF file.
Message 5 of 7

songmaverick
Contributor
Contributor

Thanks !!

Yes , you are right..

I have to recode all the class and implement the serialization .

So I find a way to solve this problem, which is to save as a dwg file and open what I save . 

0 Likes
Message 6 of 7

songmaverick
Contributor
Contributor
Thanks !!
Yes , you are right..
I have to recode all the class and implement the serialization but there is too much work to do.
Finally I find a way to solve this problem, which is to save these entities as a dwg file and open what I save .
0 Likes
Message 7 of 7

songmaverick
Contributor
Contributor
Thanks !!
Yes , you are right..
It is the best way to save these as a dwg file and open it
0 Likes