I previously suspected:
<QUOTE>
The point here is that could be the attributeDefinition added in this way is not properly initialized due to how BricsCAD implement its .NET API
</QUOTE>
It looks like it has been proved: it is BricsCAD's .NET API implementation bug: AttributeDefinition has 0 height if not explicitly set.
I tried this with AutoCAD:
1. Create a TextStyle with its Text Height=0.0, and set this TextStyle as current (so, if Text/Attribute Def/Ref is created and its text style is not specified, this text Style would be used).
2. If manually create text/attribute definition in AutoCAD, and this Text Style is used, AutoCAD always gives a default text height of 0.2, and one cannot set the height to 0.0.
3, Following code adds attribute definition to an existing block (the same as the OP) without setting any property (so, the attribute definition would use current text style):
private static ObjectId UpdateBlockDefinition(Document dwg)
{
var blkId = ObjectId.Null;
var blkName = "TestBlock";
using (var tran=dwg.TransactionManager.StartTransaction())
{
var bt = (BlockTable)tran.GetObject(dwg.Database.BlockTableId, OpenMode.ForRead);
if (bt.Has(blkName))
{
blkId = bt[blkName];
var blk = (BlockTableRecord)tran.GetObject(blkId, OpenMode.ForWrite);
var att = new AttributeDefinition();
att.Tag = "TAG A";
[color=blue]// att = 0.0 //When I explicitly try to set height to 0.0, AutoCAD raises exception[/color]
[color=red]blk.AppendEntity(att);[/color]
tran.AddNewlyCreatedDBObject(att, true);
}
tran.Commit();
}
return blkId;
}
When I examine the varaiable "att" in debugging when a break point is placed in the red line, I can see AutoCAD set its height to 0.2 in spite the TextStyle applied to it has text height being 0.0 and the code does not explicitly set the attribute definition's height. Also, the blue line of code indicates that attribute definition height cannot be 0.0.
So, that is why the OP's code works in AutoCAD.
Since the same code does not work in BriscCAD, one could do the same debugging to examine if BricsCAD somehow makes/allows 0.0 height attribute definition being added into block definition. If so, that is BricsCAD's bug.