Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <c>Block</c> class.
        /// </summary>
        /// <param name="name">Block name.</param>
        public Block(string name) : base(DxfObjectCode.Block)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw (new ArgumentNullException("name"));
            }

            this.name       = name;
            this.basePoint  = Vector3d.Zero;
            this.layer      = Layer.Default;
            this.attributes = new Dictionary <string, AttributeDefinition>();
            this.entities   = new List <IEntityObject>();
            this.record     = new BlockRecord(name);
            this.end        = new BlockEnd(this.layer);
        }
Beispiel #2
0
        internal Block(string name, IEnumerable <EntityObject> entities, IEnumerable <AttributeDefinition> attributes, bool checkName)
            : base(name, DxfObjectCode.Block, checkName)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            IsReserved     = string.Equals(name, DefaultModelSpaceName, StringComparison.OrdinalIgnoreCase);
            forInternalUse = name.StartsWith("*");
            description    = string.Empty;
            origin         = Vector3.Zero;
            layer          = Layer.Default;
            xrefFile       = string.Empty;
            Owner          = new BlockRecord(name);
            flags          = BlockTypeFlags.None;
            end            = new EndBlock(this);

            this.entities = new EntityCollection();
            this.entities.BeforeAddItem    += Entities_BeforeAddItem;
            this.entities.AddItem          += Entities_AddItem;
            this.entities.BeforeRemoveItem += Entities_BeforeRemoveItem;
            this.entities.RemoveItem       += Entities_RemoveItem;
            if (entities != null)
            {
                this.entities.AddRange(entities);
            }

            this.attributes = new AttributeDefinitionDictionary();
            this.attributes.BeforeAddItem    += AttributeDefinitions_BeforeAddItem;
            this.attributes.AddItem          += AttributeDefinitions_ItemAdd;
            this.attributes.BeforeRemoveItem += AttributeDefinitions_BeforeRemoveItem;
            this.attributes.RemoveItem       += AttributeDefinitions_RemoveItem;
            if (attributes != null)
            {
                this.attributes.AddRange(attributes);
            }
        }