AutoCAD Map 3D Developer
Welcome to Autodesk’s AutoCAD Map 3D Developer Forums. Share your knowledge, ask questions, and explore popular AutoCAD Map 3D Developer topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Copy objects or entities from one dwg to another

1 REPLY 1
Reply
Message 1 of 2
khushboo.singh
490 Views, 1 Reply

Copy objects or entities from one dwg to another

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

1 REPLY 1
Message 2 of 2

Hi,

 

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 -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost