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)); }
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); }
private static BlockReference GetSection(BlockTableRecord btr, Point3d pt) { return(btr.GetObjects <BlockReference>().FirstOrDefault(b => b.Visible && b.GeometricExtents.IsPointInBounds(pt) && b.GetEffectiveName().StartsWith("ГП_СПП_2018"))); }
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; }
/// <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); } }
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; }
public static IEnumerable <T> GetObjects <T>(this BlockTableRecord source, OpenMode mode, bool openErased) where T : Entity { return(source.GetObjects <T>(mode, openErased, false)); }
public static IEnumerable <T> GetObjects <T>(this BlockTableRecord source) where T : Entity { return(source.GetObjects <T>(OpenMode.ForRead, false, false)); }
public static List <TextInfo> GetAttributesTextInfos(this BlockTableRecord btr) { return(( from att in btr.GetObjects <AttributeDefinition>() select att.GetTextInfo()).ToList <TextInfo>()); }