Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3594260
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T19:41:22+00:00 2026-05-18T19:41:22+00:00

How can I loop through the AttributeReferences for a BlockReference and create an exact

  • 0

How can I loop through the AttributeReferences for a BlockReference and create an exact copy (looks the same to AutoCAD user) of the AttributeReference as a DBText entity. I’ve seen the code to do this in AutoLisp from the express tools burst.lsp, but I haven’t been able to figure out how to translate it to .Net. Here is the simple code for looping through the Attribute References

    foreach (ObjectId attributeReferenceId in blockReference.AttributeCollection)
    {
      AttributeReference attributeReference = (AttributeReference)transaction.GetObject(attributeReferenceId, OpenMode.ForWrite);
      // Make DBText copy
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T19:41:23+00:00Added an answer on May 18, 2026 at 7:41 pm

    To solve this problem I have copied specific properties from the AttributeReference into a new DBText object. Here is the specific code that worked for me to burst a blockreference. SetTextStyle and GetTextStyle are extension methods on the DBText class to work with changes between versions of the AutoCAD API.

    private static void BurstSingle(Transaction transaction, Database database, 
     BlockReference blockReference)
    {
      BlockTableRecord theModelSpaceBlock = 
     (BlockTableRecord)transaction.GetObject(blockReference.BlockId, OpenMode.ForWrite);
    
      foreach (ObjectId attributeReferenceId in blockReference.AttributeCollection)
      {
     AttributeReference attributeReference = 
      (AttributeReference)transaction.GetObject(attributeReferenceId, OpenMode.ForWrite);
    
     Entity textVersionOfAttributeReference;
    
     if (attributeReference.IsMTextAttribute)
     {
       MText mText = (MText)attributeReference.MTextAttribute.Clone();
       textVersionOfAttributeReference = mText;
     }
     else
     {
       DBText dbText = new DBText();
       dbText.SetDatabaseDefaults(database);
       dbText.Thickness = attributeReference.Thickness;
    
       if (attributeReference.LayerId == database.LayerZero)
      dbText.LayerId = blockReference.LayerId;
       else
      dbText.LayerId = attributeReference.LayerId;
    
       if (attributeReference.ColorIndex == EntityColorIndex_ByBlock)
      dbText.ColorIndex = blockReference.ColorIndex;
       else
      dbText.ColorIndex = attributeReference.ColorIndex;
    
       if (attributeReference.Linetype.ToUpper() == "BYBLOCK")
      dbText.LinetypeId = blockReference.LinetypeId;
       else
      dbText.LinetypeId = attributeReference.LinetypeId;
    
       dbText.Height = attributeReference.Height;
       dbText.TextString = attributeReference.TextString;
       dbText.Rotation = attributeReference.Rotation;
       dbText.Oblique = attributeReference.Oblique;
       dbText.SetTextStyle(attributeReference.GetTextStyle());
       dbText.IsMirroredInX = attributeReference.IsMirroredInX;
       dbText.IsMirroredInY = attributeReference.IsMirroredInY;
       dbText.HorizontalMode = attributeReference.HorizontalMode;
       dbText.VerticalMode = attributeReference.VerticalMode;
    
       if (attributeReference.AlignmentPoint.Y != 0.0)
      dbText.AlignmentPoint = attributeReference.AlignmentPoint;
    
       dbText.Position = attributeReference.Position;
       dbText.Normal = attributeReference.Normal;
       dbText.WidthFactor = attributeReference.WidthFactor;
    
       textVersionOfAttributeReference = dbText;
    
       theModelSpaceBlock.AppendEntity(textVersionOfAttributeReference);
       transaction.AddNewlyCreatedDBObject(textVersionOfAttributeReference, true);
     }
      }
    
      DBObjectCollection explodedParts = new DBObjectCollection();
      blockReference.Explode(explodedParts);
    
      foreach (Entity explodedPart in explodedParts)
      {
     if (!(explodedPart is AttributeDefinition))
     {
       if (explodedPart.ColorIndex == EntityColorIndex_ByBlock)
      explodedPart.ColorIndex = blockReference.ColorIndex;
    
       if (explodedPart.LayerId == database.LayerZero)
      explodedPart.LayerId = blockReference.LayerId;
    
       if (explodedPart.Linetype.ToUpper() == "BYBLOCK")
      explodedPart.LinetypeId = blockReference.LinetypeId;
    
       theModelSpaceBlock.AppendEntity(explodedPart);
       transaction.AddNewlyCreatedDBObject(explodedPart, true);
     }
    
     explodedPart.Dispose();
      }
    
      explodedParts.Clear();
    
      blockReference.Erase();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can you cast a List<int> to List<string> somehow? I know I could loop through
I can loop through all of the rows in a php script and do
I know I can loop through a list of strings like this: list<string>::iterator Iterator;
I know I can loop through each level of the object, but I would
Is these a way i can loop through a PHP array and have the
So basically I understand you can loop through an array in either of these
I want to sort the properties of an object so I can loop through
The rmdir() function fails if the folder contains any files. I can loop through
I know I can loop over the string or build a regex or invert
How can I build a loop in JavaScript?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.