Active Contributor
Posts: 47
Registered: ‎03-16-2012
Message 1 of 2 (201 Views)

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

201 Views, 1 Replies
10-12-2012 06:39 AM

idsObjEntity-->collection of xref objects
                private void CloneObjectIds(ObjectIdCollection idsObjEntity, String strFileName)
                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))
                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.


With Regards,
ADN Support Specialist
Posts: 749
Registered: ‎03-21-2011
Message 2 of 2 (151 Views)

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

10-19-2012 07:30 AM in reply to: varadan01

Hi Varadarajan,


Replied to the other thread on the same topic :


Developer Technical Services
Autodesk Developer Network

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.