<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Inserting blocks in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/inserting-blocks/m-p/7113675#M31235</link>
    <description>So i have a block made up of a circle and 2 attributes. When i am in acad and use the insert command it inserts just fine, everything is there.&lt;BR /&gt;I have a program that searches the current drawing to see if this block exists in the blocktable, and if it does i insert it into the drawing but only the circle show up, not the attributes. I say that i "insert" this block from code but im not sure that's accurate. I append it to the blocktablerecord and then use the addnewlycreatedDBObject, true command.&lt;BR /&gt;When i do this with a block made of anything else, like lines, text, shapes, etc it inserts just fine. It is only the atttibutes that dont show up.&lt;BR /&gt;Do i need to define the attributes before "inserting" it or something? The attributes are already part of the block that is already in the drawing. I just cannot figure out how to get this block with its attributes, that already exists in the current drawing to insert.&lt;BR /&gt;&lt;BR /&gt;Thanks for any assistance,&lt;BR /&gt;James</description>
    <pubDate>Sun, 28 May 2017 17:39:54 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2017-05-28T17:39:54Z</dc:date>
    <item>
      <title>Inserting blocks</title>
      <link>https://forums.autodesk.com/t5/net-forum/inserting-blocks/m-p/7113675#M31235</link>
      <description>So i have a block made up of a circle and 2 attributes. When i am in acad and use the insert command it inserts just fine, everything is there.&lt;BR /&gt;I have a program that searches the current drawing to see if this block exists in the blocktable, and if it does i insert it into the drawing but only the circle show up, not the attributes. I say that i "insert" this block from code but im not sure that's accurate. I append it to the blocktablerecord and then use the addnewlycreatedDBObject, true command.&lt;BR /&gt;When i do this with a block made of anything else, like lines, text, shapes, etc it inserts just fine. It is only the atttibutes that dont show up.&lt;BR /&gt;Do i need to define the attributes before "inserting" it or something? The attributes are already part of the block that is already in the drawing. I just cannot figure out how to get this block with its attributes, that already exists in the current drawing to insert.&lt;BR /&gt;&lt;BR /&gt;Thanks for any assistance,&lt;BR /&gt;James</description>
      <pubDate>Sun, 28 May 2017 17:39:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/inserting-blocks/m-p/7113675#M31235</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-05-28T17:39:54Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting blocks</title>
      <link>https://forums.autodesk.com/t5/net-forum/inserting-blocks/m-p/7113717#M31236</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You have to explicitly add AttributeReference instances to the newly created BlockReference.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;        public void InsertBlock(BlockTableRecord owner, Point3d position, BlockTableRecord btr, Transaction tr)
        {
            var br = new BlockReference(position, btr.ObjectId);
            owner.AppendEntity(br);
            tr.AddNewlyCreatedDBObject(br, true);
            if (btr.HasAttributeDefinitions)
            {
                foreach (ObjectId id in btr)
                {
                    if (id.ObjectClass.Name == "AcDbAttributeDefinition")
                    {
                        var attDef = (AttributeDefinition)tr.GetObject(id, OpenMode.ForRead);
                        if (!attDef.Constant)
                        {
                            var attRef = new AttributeReference();
                            attRef.SetAttributeFromBlock(attDef, br.BlockTransform);
                            attRef.TextString = attDef.TextString; // &amp;lt;- set the default attribute value
                            br.AttributeCollection.AppendAttribute(attRef);
                            tr.AddNewlyCreatedDBObject(attRef, true);
                        }
                    }
                }
            }
        }&lt;/PRE&gt;
&lt;P&gt;you can also see this topic:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://help.autodesk.com/view/OARX/2018/ENU/?guid=GUID-2107599E-9405-4D8B-A6DD-83D603B41568" target="_blank"&gt;http://help.autodesk.com/view/OARX/2018/ENU/?guid=GUID-2107599E-9405-4D8B-A6DD-83D603B41568&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 28 May 2017 18:59:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/inserting-blocks/m-p/7113717#M31236</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2017-05-28T18:59:02Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting blocks</title>
      <link>https://forums.autodesk.com/t5/net-forum/inserting-blocks/m-p/7113890#M31237</link>
      <description>Thank you yet again sir!</description>
      <pubDate>Sun, 28 May 2017 23:52:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/inserting-blocks/m-p/7113890#M31237</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-05-28T23:52:42Z</dc:date>
    </item>
  </channel>
</rss>

