Looking for some advice on what the best way to proceed is. I'm still pretty new to object oriented programming.
I have a series of blocks with all the same attribute tag names. I need to create a function that allows me to change a block from one to another within a drawing.
Can I do this by just changing the blockID? or do I need to go through and grab all the info from the old block and insert a new block with the attribute values and then delete the old block.
Any suggestions are welcome.
So I've started writing some code, but now I'm stuck because both the BlockName and BlockID of the block I want to change are read-only....can someone help me out to what I'm doing wrong...or point me in the correct direction.
<CommandMethod("swapblk")> _ Public Sub swapblk() Dim db As Database = HostApplicationServices.WorkingDatabase Dim doc As Document = DocumentManager.MdiActiveDocument Dim ed As Editor = doc.Editor Dim newblockresult As PromptResult = ed.GetString("New block name: ") If newblockresult.Status = PromptStatus.OK Then Dim newblockname As String = newblockresult.StringResult.ToString Using Trans As Transaction = doc.TransactionManager.StartTransaction Dim myBlockTable As BlockTable = db.BlockTableId.GetObject(OpenMode.ForRead) If myBlockTable.Has(newblockname) = True Then Dim TVs(0) As TypedValue TVs(0) = New TypedValue(DxfCode.Start, "INSERT") Dim MYfILTER As New SelectionFilter(TVs) Dim PSR As PromptSelectionResult = ed.GetSelection(MYfILTER) If IsNothing(PSR.Value) = False Then For Each myOBJID As ObjectId In PSR.Value.GetObjectIds Dim myblockref As BlockReference = myOBJID.GetObject(OpenMode.ForWrite) Dim blkname As String = myblockref.BlockName Next End If Else MsgBox("New block must be already defined within the drawing") End If End Using End If End Sub
Try solution from this post. It seems very similar to your problem.
If you can't solve it, come again...