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

PlotSettings and the NOD

1 REPLY 1
Reply
Message 1 of 2
Anonymous
256 Views, 1 Reply

PlotSettings and the NOD

Hi all,

I'm trying to copy (clone) the named pagesetups from a template file into
the current drawing.

This works, however the PlotSettings dictionary entries come across as
anonymous (*A), not as the original names. If you try the code below, then
use dbview, you'll see what I mean.

After a little reading, it seems dictionary entries are cloned as anonymous
entries.

Here is the relevant test code:

[CommandMethod("PSIMPORT")]

static public void PageSetupsImportCommand() {

// Get a pointer to the current document

Document curDoc = acadApp.DocumentManager.MdiActiveDocument;

// Get a pointer to the current doc's dbase...

Database curDb = curDoc.Database;

// Get a pointer to the current doc's editor...

Editor curEd = curDoc.Editor;

ObjectIdCollection psIds = new ObjectIdCollection();

using (Database psDb = new Database(false, true)) {

psDb.ReadDwgFile(@"YourTemplateFileHere.dwt", FileShare.ReadWrite, true,
null);

using (Transaction psTr = psDb.TransactionManager.StartTransaction()) {

DBDictionary psDicts =
(DBDictionary)psTr.GetObject(psDb.PlotSettingsDictionaryId,
OpenMode.ForRead);

foreach (System.Collections.DictionaryEntry psDict in psDicts) {

psIds.Add((ObjectId)psDict.Value);

}

}

IdMapping idMap = curDb.WblockCloneObjects(psIds,
curDb.PlotSettingsDictionaryId, DuplicateRecordCloning.Ignore, false);

}

}



Do I need to iterate over the idmap and change the anonymous entries names
to the name of the PlotSetting stored in the dictionary or is there another
way?



Cheers,

Glenn.
1 REPLY 1
Message 2 of 2
Anonymous
in reply to: Anonymous

I forgot to mention, if you change the WblockCloneObjects duplicate argument
to DuplicateRecordCloning.Replace an eWasErased exception is thrown....


"Glenn Ryan" wrote in message
news:5015900@discussion.autodesk.com...
Hi all,

I'm trying to copy (clone) the named pagesetups from a template file into
the current drawing.

This works, however the PlotSettings dictionary entries come across as
anonymous (*A), not as the original names. If you try the code below, then
use dbview, you'll see what I mean.

After a little reading, it seems dictionary entries are cloned as anonymous
entries.

Here is the relevant test code:

[CommandMethod("PSIMPORT")]

static public void PageSetupsImportCommand() {

// Get a pointer to the current document

Document curDoc = acadApp.DocumentManager.MdiActiveDocument;

// Get a pointer to the current doc's dbase...

Database curDb = curDoc.Database;

// Get a pointer to the current doc's editor...

Editor curEd = curDoc.Editor;

ObjectIdCollection psIds = new ObjectIdCollection();

using (Database psDb = new Database(false, true)) {

psDb.ReadDwgFile(@"YourTemplateFileHere.dwt", FileShare.ReadWrite, true,
null);

using (Transaction psTr = psDb.TransactionManager.StartTransaction()) {

DBDictionary psDicts =
(DBDictionary)psTr.GetObject(psDb.PlotSettingsDictionaryId,
OpenMode.ForRead);

foreach (System.Collections.DictionaryEntry psDict in psDicts) {

psIds.Add((ObjectId)psDict.Value);

}

}

IdMapping idMap = curDb.WblockCloneObjects(psIds,
curDb.PlotSettingsDictionaryId, DuplicateRecordCloning.Ignore, false);

}

}



Do I need to iterate over the idmap and change the anonymous entries names
to the name of the PlotSetting stored in the dictionary or is there another
way?



Cheers,

Glenn.

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