Author Topic: walking the Block Table  (Read 2060 times)

0 Members and 1 Guest are viewing this topic.

JimAndi

  • Guest
walking the Block Table
« on: August 28, 2011, 11:20:00 AM »
Hello All,

I have been trying to find out how to walk the blocktable to see if a block name in the list. 

I am using this code:

                   BlockTable bt = (BlockTable)tr.GetObject(db.Database.BlockTableId, OpenMode.ForRead);
                     int i = 0;
                     //            String FoundTB = "";    FoundTB = "No";
                     foreach (DataRow row in ds.Rows)
                     {
                         if (!bt.Has(ds.Rows["DWGNAME"].ToString()))
                         {
                             FoundTB = ds.Rows["DWGNAME"].ToString();
                         }
                         i++;
                     }

It is working, but I am getting a block name to block that has been deleted.  Do I need to purge the draw? I only really want the block name to the Title Block that is inserted on a layer called "Title" because I do not know what Title Block the user inserted.

Any help on this would be great! (I would buy lunch)  :-D

Jim

JimAndi

  • Guest
Re: walking the Block Table
« Reply #1 on: August 28, 2011, 02:35:13 PM »
I need help with this...
Do you know how to do this in .NET?

(setq EN (ssname (ssget "X" (list (cons 0 "INSERT")(cons 8 "TITLE")(cons 66 1))) 0))

anyone?

gile

  • Gator
  • Posts: 2520
  • Marseille, France
Re: walking the Block Table
« Reply #2 on: August 28, 2011, 03:57:13 PM »
Hi,

Code: [Select]
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
TypedValue[] filter = { new TypedValue(0, "INSERT"), new TypedValue(8, "TITLE"), new TypedValue(66, 1) };
PromptSelectionResult psr = ed.SelectAll(new SelectionFilter(filter));
if (psr.Status != PromptStatus.OK) return;
ObjectId en = psr.Value.GetObjectIds()[0];
Speaking English as a French Frog

JimAndi

  • Guest
Re: walking the Block Table
« Reply #3 on: August 28, 2011, 04:56:35 PM »
 Thank you..... now I have to figure out how to get the block name... but I I will start on that task... :-D

JimAndi

  • Guest
Re: walking the Block Table
« Reply #4 on: August 28, 2011, 07:00:11 PM »
Hi All,
how do you get the block name from a entity id?
jim

gile

  • Gator
  • Posts: 2520
  • Marseille, France
Re: walking the Block Table
« Reply #5 on: August 29, 2011, 03:17:44 AM »
Start a Transaction.
Open the BlockReference within the transaction.
Get the Name property of the BlockReference object.
If BlockReference object do not have a Name property (depends on which SDK version you are targeting), open the BlockTableRecord whose the BlockReference refers and get the Name property ob the BlockTableRecord .

Look at the AutoCAD .NET Developer's Guide >Create and Edit AutoCAD Entities > Open and Close Objects.
Speaking English as a French Frog

JimAndi

  • Guest
Re: walking the Block Table
« Reply #6 on: August 29, 2011, 04:57:37 PM »
Thank you....