TheSwamp
Code Red => .NET => Topic started by: kaster on February 05, 2015, 10:01:39 AM
-
Howto make new ACAD drawing file from existing layer (with all entities)?
I'm trying with Database.WblockCloneObjects and this works, but subsequently publishing of drawings (many layers from one drawing -> many opened drawings) give me uninitialized drawings in publishing window.
sourceDb.WblockCloneObjects(sourceIds, destDbMsId, mapping, DuplicateRecordCloning.Replace, false);
destDb.SaveAs("c:\\temp\\dwgs\\CopyTest.dwg", DwgVersion.Current);
How to do that properly that so created drawings are "publishable"?
Thanks
-
The following article may be closely or remotely relevant to your problem and worth of looking at:
http://adndevblog.typepad.com/autocad/2015/01/using-wblockcloneobjects-copied-modelspace-entities-disappear-in-the-current-drawing.html (http://adndevblog.typepad.com/autocad/2015/01/using-wblockcloneobjects-copied-modelspace-entities-disappear-in-the-current-drawing.html)
-
That was first good orientation. Following is my standing now:
// doc is opened multilayer drawing document
// LOOP OVER many layers
//foreach (string layerName in layerNames) {
string dwgFile = Path.GetDirectoryName(doc.Name) + "\\" + layerName + DocUtil.DWG_EXTENSION;
Document acNewDoc = DocUtil.OpenDocument(dwgFile, true, false, true); ;
using (Transaction transNew = acNewDoc.Database.TransactionManager.StartTransaction()) {
using (DocumentLock doclck = acNewDoc.LockDocument()) {
using (Database destDb = acNewDoc.Database) {
ObjectId destDbMsId = SymbolUtilityServices.GetBlockModelSpaceId(destDb);
ObjectIdCollection layerEntities = elements[layerName];
transNew.TransactionManager.QueueForGraphicsFlush();
// next prepare to deepclone the recorded ids to the destdb
IdMapping mapping = new IdMapping();
// now clone the objects into the destdb
doc.Database.WblockCloneObjects(layerEntities, destDbMsId, mapping, DuplicateRecordCloning.Replace, false);
// hier I must delete my (non standard named layout)
LayoutUtil.deleteLayout("Work");
// and after this i have regenerated "Layout1" with all graphic elements into
}
}
transNew.Commit();
// regen all
}
// } loop
But I have new issue:
doc.SendStringToExecute("publish\n", false, false, false);
Calls command "publish" but, all my pdf sheets (from multisheet pdf - one per layout) are empty.
If I run it manually each my pdf sheet (from multisheet pdf) is OK and contains drawing elements.
Any ideas?
Thanks