I've got a block with multiple attributes. This is not a problem to redefine the blocks attributes.
Some of the attributes contains dynamic fields (blockplace holder x y z parameters)
When i insert a block with such atributes that includes the blockplaceholder dynamic fields i get
X: InsertionPoint => It is recognized as an Dynamic field but displays InsertionPoint. and does not update the value.
Regenerating the modelspace does not help
How can i update the fielddata from vb.net?
I hope this you understand my problem...
Part of the code I use (where i think the problem is)
For Each attid As ObjectId In refbtr attent = tr.GetObject(attid, OpenMode.ForRead) If TypeOf attent Is AttributeDefinition Then Dim attdef As AttributeDefinition = attent Dim attref As New AttributeReference() attref.SetAttributeFromBlock(attdef, myBlockRef.BlockTransform) Dim attrefid As ObjectId = myBlockRef.AttributeCollection.AppendAttribute(attref) tr.AddNewlyCreatedDBObject(attref, True) End If Next
Regards
Peter
Solved! Go to Solution.
Solved by Jeffrey_H. Go to Solution.
I've already checked that one, (first thing i've thought) but it has no effect on the block attributes.
The UPDATEFIELD command doesn't affect it.
When I manual do a insert block, select the block from the drop down and place it next to the other the fields work as they are ment to be. So the defenition of the block is not wrong.
When I save the drawing and reopen it. The block inserted by the code still appears as InsertionPoint, the manual inserted block displays normal. They both have the exact same contents, the only difference is the way of placing the block.
So I think my code is not complete.
See this thread has more info
http://www.theswamp.org/index.php?topic=38857.0
Here is some code from above link
<CommandMethod("InsertBlockWithFieldAtts")> _ Public Sub InsertBlockWithFieldAtts() Dim doc As Document = Application.DocumentManager.MdiActiveDocument Dim db As Database = doc.Database Dim ed As Editor = doc.Editor Using trx As Transaction = db.TransactionManager.StartTransaction() Dim bt As BlockTable = trx.GetObject(db.BlockTableId, OpenMode.ForRead) Dim modelBtr As BlockTableRecord = trx.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForWrite) Dim blockBtr As BlockTableRecord = trx.GetObject(bt("C"), OpenMode.ForRead) Dim insertPoint As Point3d = ed.GetPoint("Select Insertion Point").Value Dim bref As New BlockReference(insertPoint, blockBtr.ObjectId) modelBtr.AppendEntity(bref) trx.AddNewlyCreatedDBObject(bref, True) For Each id As ObjectId In blockBtr If id.ObjectClass.Name = "AcDbAttributeDefinition" Then Dim attDef As AttributeDefinition = trx.GetObject(id, OpenMode.ForRead) Dim attref As New AttributeReference() attref.SetAttributeFromBlock(attDef, bref.BlockTransform) bref.AttributeCollection.AppendAttribute(attref) trx.AddNewlyCreatedDBObject(attref, True) If attDef.Constant Then Continue For End If Dim extDic As DBDictionary = trx.GetObject(attref.ExtensionDictionary, OpenMode.ForRead) Dim fieldDic As DBDictionary = trx.GetObject(extDic.GetAt("ACAD_FIELD"), OpenMode.ForRead) Dim fld As Field = trx.GetObject(fieldDic.GetAt("TEXT"), OpenMode.ForWrite) Dim strId As String = bref.ObjectId.OldIdPtr.ToString() Dim updteStr As String = "%<\_ObjId " & strId & ">%" Dim fieldCode As String = fld.GetFieldCode(FieldCodeFlags.AddMarkers) Dim newFieldCode As String = fieldCode.Replace("?BlockRefId", updteStr) fld.SetFieldCode(newFieldCode) End If Next trx.Commit() End Using ed.Regen() End Sub