.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Copy NOD dictionary entry between drawings

6 REPLIES 6
Reply
Message 1 of 7
SRSDS
711 Views, 6 Replies

Copy NOD dictionary entry between drawings

Hi,
I need to drag a NOD dictionary entry between drawings if an entity is being copied between drawings but I can't access the sourceDB (last line of the code below). I've removed a few variable references and code  just to compact the problem. 
One extra problem I foresee is if  the source drawing is closed before  the entities are pasted into the new but I can probably easily reopen it or access it using sourceDb.ReadDwgFile(sourceFileName, System.IO.FileShare.Read, True, "")
Hope someone can point out what the problem might be.
 
Public destDb As New Database(False, True)   
Public sourceDb As New Database(False, True)

 

Private Sub doc_CommandWillStart(ByVal sender As System.Object, ByVal e As Autodesk.AutoCAD.ApplicationServices.CommandEventArgs)
If  e.GlobalCommandName = "COPYCLIP" Or e.GlobalCommandName = "COPYBASE" Or e.GlobalCommandName = "CUTCLIP" Then
sourceDb = HostApplicationServices.WorkingDatabase

 

destDb = HostApplicationServices.WorkingDatabase
If sourceDb = destDb Then
        Dim SourceNOD As DBDictionary = trans.GetObject(sourceDb.NamedObjectsDictionaryId, OpenMode.ForRead)
6 REPLIES 6
Message 2 of 7
jeff
in reply to: SRSDS

Depending on what and how it reference's the entity, and how it is nested and what all you you need copied

 

have you tried

DBDictionary.TreatElementsAsHard = true;

You can also find your answers @ TheSwamp
Message 3 of 7
SRSDS
in reply to: jeff

Hi Jeff,

 

Do I need to open and wrinte all dictionariesI use that way? Even the NOD.

 

Dim NOD As DBDictionary = trans.GetObject(db.NamedObjectsDictionaryId, OpenMode.ForWrite)

NOD .TreatElementsAsHard = True

Message 4 of 7
jeff
in reply to: SRSDS

I do not know what you are doing and would have to look back at the docs, but off the top of my head it might work if the entity contains a extension dictionary with a reference to the entry or the entry references the entity as hard pointer

You can also find your answers @ TheSwamp
Message 5 of 7
Alexander.Rivilis
in reply to: SRSDS

Another way is subscribe on Autodesk.AutoCAD.DatabaseServices.Database.BeginWblockObjects event.

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 6 of 7
SRSDS
in reply to: Alexander.Rivilis

Manually copying objects between drawings triggers what I want to do but doesn't affect it.

I want to be able to read from the source drawing database NOD. 

 

I get an eNotFromThisDocument error on this line.

Dim SourceNOD As DBDictionary = trans.GetObject(sourceDb.NamedObjectsDictionaryId, OpenMode.ForRead) 

Message 7 of 7
SRSDS
in reply to: SRSDS

Looks like it was the way I was defining the transaction. I was starting the transaction using the active document's database. This seems to work.

 

Dim tm As Autodesk.AutoCAD.DatabaseServices.TransactionManager = sourceDb.TransactionManager
Dim trans As Transaction = tm.StartTransaction() 

 

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost