Message 1 of 2
Not applicable
03-23-2018
09:36 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Fairly new to C# .net so I am a bit lost with the flowchart below. I have blocks with custom attributes and I want to iterate through each object within the model space ( found in the blocktablerecord?) to find them. Then I want to access their attributes to look for the word "notes" within the Tags value. I found this tutorial on Extract Attribute info but I don't understand how AttributeCollection works. is it like the blocktablerecord that constains all entities?

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Excel = Microsoft.Office.Interop.Excel;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.LayerManager;
using Autodesk.AutoCAD.Runtime;
using ACADapp = Autodesk.AutoCAD.ApplicationServices.Application;
using ATTCOL = Autodesk.AutoCAD.DatabaseServices.AttributeCollection;
namespace Get_Notes_v0._1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void FindNotes_Click(object sender, EventArgs e)
{
// Get the current document and database
Document Doc = ACADapp.DocumentManager.MdiActiveDocument;
Database DB = Doc.Database;
Editor ED = Doc.Editor;
// Start a transaction
using (Transaction TRANS = DB.TransactionManager.StartTransaction())
{
// Open the Block table for read
BlockTable Btable = TRANS.GetObject(DB.BlockTableId, OpenMode.ForRead) as BlockTable;
BlockTableRecord BTR = TRANS.GetObject(DB.BlockTableId, OpenMode.ForRead) as BlockTableRecord;
//look at each objects attributes for key word note or notes
foreach (ObjectId OBJID in BTR)
{
ATTCOL ATTREF = OBJID.GetObject(OBJID.Database, OpenMode.ForRead) as ATTCOL;
{
if (ATTREF.Tag == "CONST_REMARKS")
{
if (ATTREF.Value == "NOTE" || ATTREF.Value == "NOTES")
{
}
}
}
}
}
}
}
}
Solved! Go to Solution.