AutoCAD Map 3D Developer

AutoCAD Map 3D Developer

20 Posts
1 Kudo
Registered: ‎11-09-2011
Post 1 of 2

Copy objects or entities from one dwg to another

267 Views, 1 Replies
01-18-2013 06:38 PM



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)
                            acSDocMgr.MdiActiveDocument = acSDoc
                        End Using
                    End Using

*Expert Elite*
9,833 Posts
1,218 Kudos
Registered: ‎06-29-2007
Post 2 of 2

Re: Copy objects or entities from one dwg to another

01-19-2013 03:36 AM in reply to: khushboo.singh



you don't need to take care of the coordinates as this function creates the new entities on exactly that position of the original drawing. Can you show us the source drawing and the destination drawing (after you let the code do it's things) so we see what is different?


Just a thought: you know that AutoCAD uses just WorldCoordinates for that deep functions. So be sure you don't have a user defined cs in any of these drawings when you compare the coordinate-values.

Also take care of the sysvar INSBASE, it might influence this situation too, but have not tried it now.


- alfred -

Ingenieur Studio HOLLAUS ...
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!