Get Block Attribute Tags

Top  Previous  Next

Dear Owen, comment this please:

 

 

public static List<string> GetBlockAttribTags(string blockName)

        {

            var result = new List<string>();

            var db = HostApplicationServices.WorkingDatabase;

            var attDefClass = RXObject.GetClass(typeof(AttributeDefinition));

            using (var tr = new OpenCloseTransaction())

            {

                var bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);

                var btr = (BlockTableRecord)tr.GetObject(bt[blockName], OpenMode.ForRead);

                if (btr.HasAttributeDefinitions)

                {

                    foreach (ObjectId id in btr)

                    {

                        if (id.ObjectClass == attDefClass)

                        {

                            var attDef = (AttributeDefinition)tr.GetObject(id, OpenMode.ForRead);

                            result.Add(attDef.Tag);

                        }

                    }

                }

            }

            return result;

        }