how to create collection of xref objects into new drawing file.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
idsObjEntity-->collection of xref objects
private void CloneObjectIds(ObjectIdCollection idsObjEntity, String strFileName)
{
try
{
Database dbNew = new Database(true, false);
Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = dbNew.TransactionManager;
ObjectId idModelSpace;
using (Transaction mTy = tm.StartTransaction())
{
BlockTable bt = (BlockTable)tm.GetObject(dbNew.BlockTableId, OpenMode.ForRead, false);
BlockTableRecord Btr = (BlockTableRecord)tm.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForRead, false);
//idModelSpace = bt[BlockTableRecord.ModelSpace];
idModelSpace = Btr.Id;
}
IdMapping Mappin = new IdMapping();
RTA_ApplicationData.Db.WblockCloneObjects(idsObjEntity, idModelSpace, Mappin, DuplicateRecordCloning.Ignore, false);
String strFolderName = strFileName;
strFileName = strFileName + ".dwg";
String strPathName;
String pathName = Assembly.GetExecutingAssembly().Location;
pathName = pathName.Replace("LayerFilter.dll", "Drawing");
DirectoryInfo dirInfo = Directory.CreateDirectory(pathName + "\\" + strFolderName);
if (System.IO.File.Exists(pathName + "\\" + strFolderName))
{
return;
}
dbNew.SaveAs(pathName + "\\" + strFolderName + "\\" + strFileName, DwgVersion.Newest);
strPathName = pathName + "\\Temp\\" + strFileName;
}
}
here i take the objectid collection as xref filter by its layer name.i tried to clone the object in new dwg its shows eWrongdatabase.