Message 1 of 31
Not applicable
02-21-2017
07:47 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have the below code as a means of transferring attribute values from one place to another. Within it I'm trying to make it skip a specific attribute with a tag "INITIALS". The message box within the code is there to test the If/Else/EndIf. It works. The message only pops up when it hits that attribute. Yet the result is the attribute with the tag "INITIALS" is still added to the list. Any ideas as to why it works but doesn't?
Using AcTrans As Transaction = AcDb.TransactionManager.StartTransaction()
Dim bt As BlockTable = AcTrans.GetObject(AcDb.BlockTableId, OpenMode.ForRead, False, True)
For Each id As ObjectId In bt
Dim btr As BlockTableRecord = DirectCast(AcTrans.GetObject(id, OpenMode.ForRead), BlockTableRecord)
If btr.Name.ToUpper = BlkName.ToUpper Then
For Each ObjId As ObjectId In btr.GetBlockReferenceIds(False, False)
Dim br As BlockReference = AcTrans.GetObject(ObjId, OpenMode.ForRead)
If br.Name = BlkName Then
Dim z As Integer = 0
For Each obj1 As ObjectId In btr
obj = AcTrans.GetObject(obj1, OpenMode.ForRead)
If TypeOf obj Is AttributeDefinition Then
Dim AttDef As AttributeDefinition = obj
Dim AttRef As AttributeReference = CType(AcTrans.GetObject(br.AttributeCollection(z), OpenMode.ForRead), AttributeReference)
If AttDef.Tag = "INITIALS" Then
MsgBox("Skipping INITIALS")
ElseIf AttDef.Tag = "INITIALS" = False Then
taglist.Add(AttDef.Tag)
txtlist.Add(AttRef.TextString)
z = z + 1
End If
End If
Next
End If
Next
End If
Next
AcTrans.Commit()
End Using
Solved! Go to Solution.