Пример #1
0
 public static int IndexOf(this BlockTableRecord btr, AttributeDefinition attDef)
 {
     return((
                from att in btr.GetObjects <AttributeDefinition>()
                where !att.Constant
                select att).ToList <AttributeDefinition>().FindIndex((AttributeDefinition x) => x == attDef));
 }
Пример #2
0
        public static AttributeReference AddAttributeReferences(this BlockReference br, int index, string value)
        {
            BlockTableRecord   obj                = br.BlockTableRecord.GetObject <BlockTableRecord>();
            Transaction        topTransaction     = br.Database.TransactionManager.TopTransaction;
            AttributeReference attributeReference = null;

            AttributeDefinition[] array = obj.GetObjects <AttributeDefinition>().ToArray <AttributeDefinition>();
            for (int i = 0; i < (int)array.Length; i++)
            {
                AttributeDefinition attributeDefinition = array[i];
                AttributeReference  attributeReference1 = new AttributeReference();
                attributeReference1.SetAttributeFromBlock(attributeDefinition, br.BlockTransform);
                Point3d position = attributeDefinition.Position;
                attributeReference1.Position = position.TransformBy(br.BlockTransform);
                if (attributeDefinition.Justify != AttachmentPoint.BaseLeft)
                {
                    position = attributeDefinition.AlignmentPoint;
                    attributeReference1.AlignmentPoint = position.TransformBy(br.BlockTransform);
                    attributeReference1.AdjustAlignment(br.Database);
                }
                if (attributeReference1.IsMTextAttribute)
                {
                    attributeReference1.UpdateMTextAttribute();
                }
                if (i == index)
                {
                    attributeReference1.TextString = value;
                    attributeReference             = attributeReference1;
                }
                br.AttributeCollection.AppendAttribute(attributeReference1);
                topTransaction.AddNewlyCreatedDBObject(attributeReference1, true);
            }
            return(attributeReference);
        }
Пример #3
0
 private static BlockReference GetSection(BlockTableRecord btr, Point3d pt)
 {
     return(btr.GetObjects <BlockReference>().FirstOrDefault(b =>
                                                             b.Visible &&
                                                             b.GeometricExtents.IsPointInBounds(pt) &&
                                                             b.GetEffectiveName().StartsWith("ГП_СПП_2018")));
 }
Пример #4
0
        private void cbxBlock_Validating(object sender, CancelEventArgs e)
        {
            string text = this.cbxBlock.Text;

            if (text == "")
            {
                return;
            }
            BlockTable obj = this._db.BlockTableId.GetObject <BlockTable>();

            if (obj.Has(text))
            {
                BlockTableRecord      blockTableRecords = obj[text].GetObject <BlockTableRecord>();
                AttributeDefinition[] arrayAttDef       = (
                    from att in blockTableRecords.GetObjects <AttributeDefinition>()
                    where !att.Constant
                    select att).ToArray <AttributeDefinition>();
                if (arrayAttDef != null && arrayAttDef.Length != 0)
                {
                    this.cbxBlock.SelectedItem = blockTableRecords;
                    return;
                }
                AcAp.ShowAlertDialog(("Block terpilih tidak terdapat Attribute Reference."));
                this.cbxBlock.SelectAll();
                return;
            }
            ObjectId block = obj.GetBlock(text);

            if (block == ObjectId.Null)
            {
                AcAp.ShowAlertDialog("Block '" + text + "'Tidak ada.");
                this.cbxBlock.SelectAll();
                return;
            }
            BlockTableRecord obj1 = block.GetObject <BlockTableRecord>();

            AttributeDefinition[] arrayDef = (
                from att in obj1.GetObjects <AttributeDefinition>()
                where !att.Constant
                select att).ToArray <AttributeDefinition>();
            if (arrayDef == null || arrayDef.Length == 0)
            {
                AcAp.ShowAlertDialog("Tidak Ada Attribute pada Block yang dipilih.");
                this.cbxBlock.SelectAll();
                return;
            }
            if (!this.cbxBlock.Items.Contains(obj1))
            {
                this.cbxBlock.DataSource = this._db.GetBlocksWithAttribute();
            }
            this.cbxBlock.SelectedItem = obj1;
        }
Пример #5
0
 /// <summary>
 /// Добавление атрибутов к вставке блока
 /// </summary>
 public static void AddAttributes(BlockReference blRef, [NotNull] BlockTableRecord btrBl, Transaction t)
 {
     foreach (var atrDef in btrBl.GetObjects <AttributeDefinition>())
     {
         if (atrDef.Constant)
         {
             continue;
         }
         using var atrRef = new AttributeReference();
         atrRef.SetAttributeFromBlock(atrDef, blRef.BlockTransform);
         blRef.AttributeCollection.AppendAttribute(atrRef);
         t.AddNewlyCreatedDBObject(atrRef, true);
     }
 }
Пример #6
0
        private void btnBrowse_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.DefaultExt       = ".dwg";
            ofd.Title            = "Pilih File Block";
            ofd.RestoreDirectory = true;
            ofd.Multiselect      = false;
            if (ofd.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            ObjectId block = this._db.BlockTableId.GetObject <BlockTable>().GetBlock(ofd.FileName);

            if (block == ObjectId.Null)
            {
                AcAp.ShowAlertDialog("Invalid File");
                return;
            }
            BlockTableRecord obj = block.GetObject <BlockTableRecord>();

            AttributeDefinition[] array = (
                from att in obj.GetObjects <AttributeDefinition>()
                where !att.Constant
                select att).ToArray <AttributeDefinition>();
            if (array == null || array.Length == 0)
            {
                AcAp.ShowAlertDialog("");
                return;
            }
            if (!this.cbxBlock.Items.Contains(obj))
            {
                this.cbxBlock.DataSource = this._db.GetBlocksWithAttribute();
            }
            this.cbxBlock.SelectedItem = obj;
        }
Пример #7
0
 public static IEnumerable <T> GetObjects <T>(this BlockTableRecord source, OpenMode mode, bool openErased)
     where T : Entity
 {
     return(source.GetObjects <T>(mode, openErased, false));
 }
Пример #8
0
 public static IEnumerable <T> GetObjects <T>(this BlockTableRecord source)
     where T : Entity
 {
     return(source.GetObjects <T>(OpenMode.ForRead, false, false));
 }
Пример #9
0
 public static List <TextInfo> GetAttributesTextInfos(this BlockTableRecord btr)
 {
     return((
                from att in btr.GetObjects <AttributeDefinition>()
                select att.GetTextInfo()).ToList <TextInfo>());
 }