//向块中用程序添加属性

代码
 //添加属性    //  houlinbo QQ420021327
        private void AddAttJoinWire(Transaction tr, BlockReference refJoinWire, BlockTableRecord  refJoinWireBtr, Point3d newPtWireSLine, int i)
        {
             Point3d ptWireNo 
= new Point3d(newPtWireSLine.X + 1, newPtWireSLine.Y + 10);
            
string wireNo = Convert.ToString(i + 1);
            AttributeDefinition attDefWireNo 
= new AttributeDefinition(ptWireNo, wireNo, "WIRENO" + wireNo, "芯线序号" + wireNo, db.Textstyle);
            attDefWireNo.Height 
= 2;
            refJoinWireBtr.AppendEntity(attDefWireNo);
            tr.AddNewlyCreatedDBObject(attDefWireNo, 
true); //属性定义添加到块的块表记录中,

            AttributeReference attRefWireNo 
= new AttributeReference();
            attRefWireNo.SetPropertiesFrom(attDefWireNo);
            attRefWireNo.SetAttributeFromBlock(attDefWireNo, refJoinWire.BlockTransform);
            refJoinWire.AttributeCollection.AppendAttribute(attRefWireNo);
            tr.AddNewlyCreatedDBObject(attRefWireNo, 
true);  //属性引用添加到块的引用中,  如果块表记录中不添加块定义,块引用中将不显示块提示一项
        }
原文地址:https://www.cnblogs.com/houlinbo/p/1625013.html