Copy objects or entities from one dwg to another

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi
I am using VS 2010 and AutoCAD Map 3D 2012.
I am opening a dwg say A.dwg and selecting few entities on it. I am trying to copy it to another dwg say B.dwg.
For this, I have used WblockCloneObjects function.
The objects are copied to B.dwg as such, but without any reference to A.dwg coordinates.
The objects should be automatically copied to B.dwg at the same location/place/coordinates as in A.dwg.
Could you please let me know how should I modify the code to take the coordinates automatically from A.dwg and paste the objects at the same location in B.dwg?
Here is the code I am using for WblockCloneObjects. myObjs is a ObjectIDCollection which contains the entities/objects from A.dwg to be cloned/copied to B.dwg.
Using acLckDoc As DocumentLock = acSDoc.LockDocument
Using acTransNew As Transaction = acSDoc.Database.TransactionManager.StartTransaction()
Dim acBlkTbl As BlockTable = acSDoc.Database.BlockTableId.GetObject(OpenMode.ForRead)
Dim acBlkTblRecord As BlockTableRecord = acTransNew.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), OpenMode.ForRead)
Dim acIdMap As IdMapping = New IdMapping()
acSDoc.Database.WblockCloneObjects(myObjs, acBlkTblRecord.ObjectId, acIdMap, DuplicateRecordCloning.Replace, False)
acTransNew.Commit()
acSDocMgr.MdiActiveDocument = acSDoc
End Using
End Using