How to "label" my source file by xrecord and find the xrecord in the new file

How to "label" my source file by xrecord and find the xrecord in the new file

Anonymous
Not applicable
506 Views
2 Replies
Message 1 of 3

How to "label" my source file by xrecord and find the xrecord in the new file

Anonymous
Not applicable

.NET C# AC2017

 

1) I attached a xrecord to NamedObjectsDictionary of file a.dwg. Works fine

...

DBDictionary nod = (DBDictionary)trans.GetObject(database.NamedObjectsDictionaryId, OpenMode.ForWrite);

...

Xrecord myXrecord = new Xrecord();

....

nod.SetAt("MyData", myXrecord);

trans.AddNewlyCreatedDBObject(myXrecord, true);

...

trans.commit();

 

2) Insert file a.dwg to other file b.dwg and want to use my xrecord data. Using insert command, drag and drop, etc. produce the same result.

I use mgdDbg but cant find the Xrecord.

 

 

I think xrecord of NamedObjectsDictionary should become xrecord of inserted block - but that seems to be wrong.

 

How can I "label" my source file by xrecord and find the xrecord in the new file after I inserted the source file without using a block at the source file?

 

 

0 Likes
507 Views
2 Replies
Replies (2)
Message 2 of 3

_gile
Consultant
Consultant

Hi,

 

Basically, when you insert a dwg file in another one, AutoCAD creates a new block definition (BlockTableRecord) and deep clone the entities contained in the source file model space into the newly created block definition.

 

One way should be attaching the xrecord to the extension dictionary of an entity contained in the source file model space, so that you can get it in the cloned entity of the block definition.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 3 of 3

Anonymous
Not applicable

Hi,

 

thank you for that option.

 

I have > 50.000 files which can be totaly different (different entities/objects)

This files are used as blocks inside other (Autocad dwg) documents.

 

I want/have to "label" that files to check version and some other custom properites

after that files are inserted as block to a target document/database.

 

1) A additional entitiy including the xrecord is possible, but not secure - user can remove/modify that entity.

2) I also thought about a custom object - but I don't want to use object enablers, etc. (replacement for xrecord)

3) Override the insert command is also a non wanted solution

 

AllInOne:

If there is another option to identify a block (inserted from a file) I would be happy

 

Tank you very much

 

nil

 

 

0 Likes