Message 1 of 8
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am trying to copy a block reference to each paperspace layout tab to the same coordinates. The program currently inserts the block at the user's selected coordinates. I get the block objectId and the user selected coordinates and pass them to the sub below. I have tried may things but cant seem to get it to work. Any help would be greatly appreciated.
Private Sub CopyToAllLayouts(acBlockReferenceObjectId As ObjectId, insertionPoint As Point3d)
Dim acCurrentDatabase As Database = Active.Database
Dim acDocumentEditor As Editor = Active.Editor
Using acDocumentLock As DocumentLock = Active.Document.LockDocument()
Using acTranaction As Transaction = Active.Database.TransactionManager.StartTransaction()
Dim acLayoutDatabaseDictionary As DBDictionary = TryCast(acTranaction.GetObject(acCurrentDatabase.LayoutDictionaryId, OpenMode.ForRead), DBDictionary)
For Each acLayoutDatabaseDictionaryEntry As DBDictionaryEntry In acLayoutDatabaseDictionary
Dim acLayout As Layout = CType(acLayoutDatabaseDictionaryEntry.Value.GetObject(OpenMode.ForRead), Layout)
Dim acLayoutName As String = acLayout.LayoutName
Dim acLayoutObjectId As ObjectId = acLayoutDatabaseDictionary.GetAt(acLayoutName)
Dim acBlockTableRecord = CType(acTranaction.GetObject(acLayout.BlockTableRecordId, OpenMode.ForRead), BlockTableRecord)
Dim acBlockReference As BlockReference = New BlockReference(insertionPoint, acBlockReferenceObjectId)
'Dim acBlockTable = DirectCast(acTranaction.GetObject(acCurrentDatabase.BlockTableId, OpenMode.ForRead), BlockTable)
'Dim acBlockReference = New BlockReference(insertionPoint, acBlockReferenceObjectId)
'Dim acBlockTableRecord = DirectCast(acTranaction.GetObject(acCurrentDatabase.CurrentSpaceId, OpenMode.ForWrite), BlockTableRecord)
'acBlockReference.TransformBy(acDocumentEditor.CurrentUserCoordinateSystem)
acBlockTableRecord.UpgradeOpen()
acBlockReference.TransformBy(acDocumentEditor.CurrentUserCoordinateSystem)
acBlockTableRecord.AppendEntity(acBlockReference)
acTranaction.AddNewlyCreatedDBObject(acBlockReference, True)
Next
acTranaction.Commit()
End Using
End Using
End Sub
Solved! Go to Solution.