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.