I need to copy an existed dynamic block to another place exactly as it is: with the same Anno scale, the same visible state, the same visible attributes... etc.
I am almost there, but... attributes are refusing to go to the new position. They are copied but not moved to position of new block (they are copied exactly over the old block position and not somewhere around 0,0,0).
Any help?
Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
Dim db As Database = doc.Database
Using tr As Transaction = db.TransactionManager.StartTransaction()
'select block that I need to copy
Dim idBlock As New ObjectIdCollection()
Dim peo As New PromptEntityOptions(Environment.NewLine & "Select Block to Copy")
peo.SetRejectMessage(Environment.NewLine & "Not a Block Reference")
peo.AddAllowedClass(GetType(BlockReference), True)
idBlock.Add(doc.Editor.GetEntity(peo).ObjectId)
Using map As New IdMapping()
Dim newBref As BlockReference = Nothing
db.DeepCloneObjects(idBlock, db.CurrentSpaceId, map, False)
For Each idP As IdPair In map
If idP.Value.ObjectClass = RXClass.GetClass(GetType(BlockReference)) Then
newBref = DirectCast(tr.GetObject(idP.Value, OpenMode.ForWrite), BlockReference)
newBref.Position = New Point3d(0, 0, 0)
End If
Next
End Using 'map
tr.Commit()
End Using 'tr
Thanks in advance