0 Members and 1 Guest are viewing this topic.
<CommandMethod("ReplaceBlocks")> _ Public Sub ReplaceBlocks() Dim db As Database = HostApplicationServices.WorkingDatabase Using tr As Transaction = db.TransactionManager.StartTransaction Dim bt As BlockTable = db.BlockTableId.GetObject(OpenMode.ForRead) Dim btrCircle As BlockTableRecord = bt("C").GetObject(OpenMode.ForRead) Dim btrRectangle As BlockTableRecord = bt("Rec").GetObject(OpenMode.ForRead) Dim objIdColl As ObjectIdCollection = btrCircle.GetBlockReferenceIds(True, False) For Each objId As ObjectId In objIdColl Dim bref As BlockReference = objId.GetObject(OpenMode.ForWrite) bref.BlockTableRecord = btrRectangle.ObjectId Next tr.Commit() End Using End Sub
Attributes anyone?
Code: [Select] bref.BlockTableRecord = btrRectangle.ObjectId
bref.BlockTableRecord = btrRectangle.ObjectId
don't eat vbnet, just c#
In that case you may want to use WblockCloneObjects (which was totally inappropriate before).If you open the database,grab the entities from the block b, WblockCloneObjects those enties to the new drawing database (neither need to be open) block a. Then rename the block if necessary.