Author Topic: Get the real block name  (Read 469 times)

0 Members and 1 Guest are viewing this topic.

Offline fixo

  • Full Member
  • ***
  • Posts: 135
  • Karma: +4/-0
  • Gender: Male
    • prefered language: C
    • Prog expertise: Good
    • View Profile
Get the real block name
« on: July 12, 2012, 07:55:14 AM »
    Assume to use transaction in this function as an argument

Code: [Select]
       //      get the real block name.        //
        static public string EffectiveName(Transaction tr, BlockReference bref)
        {
            BlockTableRecord btr = null;

            if ((bref.IsDynamicBlock) | (bref.Name.StartsWith("*U", StringComparison.InvariantCultureIgnoreCase)))
            {
                btr = tr.GetObject(bref.DynamicBlockTableRecord, OpenMode.ForRead) as BlockTableRecord;
            }
            else
            {
                btr = tr.GetObject(bref.BlockTableRecord, OpenMode.ForRead) as BlockTableRecord;
            }
            return btr.Name;
        }

~'J'~