示例#1
0
        /// <summary>
        /// Defines a block attribute.
        /// </summary>
        /// <param name="blockName">The block name.</param>
        /// <param name="tag">The tag.</param>
        /// <param name="value">The value.</param>
        /// <param name="prompt">The prompt.</param>
        /// <param name="position">The position.</param>
        /// <param name="style">The style.</param>
        public static void DefineBlockAttribute(string blockName, string tag, string value, string prompt, Point3d position, ObjectId style)
        {
            var ad = new AttributeDefinition(position, value, tag, prompt, style);

            using (var trans = HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction())
            {
                var block = trans.GetObject(DbHelper.GetBlockId(blockName), OpenMode.ForWrite) as BlockTableRecord;
                block.AppendEntity(ad);
                trans.AddNewlyCreatedDBObject(ad, true);
                trans.Commit();
            }
        }