.NET

Reply
*Glenn Ryan
Message 1 of 2 (95 Views)

PlotSettings and the NOD

95 Views, 1 Replies
11-17-2005 03:00 AM
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.
*Glenn Ryan
Message 2 of 2 (95 Views)

Re: PlotSettings and the NOD

11-17-2005 03:05 AM in reply to: *Glenn Ryan
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.
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.