<?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 Re: How to modify the components of a BlockReference? in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/how-to-modify-the-components-of-a-blockreference/m-p/2916080#M61890</link>
    <description>&lt;P&gt;You can't edit a block reference's mtext. You would have to redefine the text in the block definition. Otherwise copy the block definition with a new unique blockname and then edit that definition and then replace the block reference with the new block reference you just created.&lt;BR /&gt;&lt;BR /&gt;Attributes are the only objects that can be edited per block reference.&lt;BR /&gt;&lt;BR /&gt;When you explode the Block Reference you are making a copy of the contents. You could use those contents to build a new block. Also the original Block Reference is still in the drawing when you explode it. You haven't affected the block refererence at all by exploding it.&lt;/P&gt;</description>
    <pubDate>Mon, 14 Feb 2011 19:18:58 GMT</pubDate>
    <dc:creator>arcticad</dc:creator>
    <dc:date>2011-02-14T19:18:58Z</dc:date>
    <item>
      <title>How to modify the components of a BlockReference?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-modify-the-components-of-a-blockreference/m-p/2915380#M61888</link>
      <description>&lt;P&gt;How can you modify the components of a BlockReference.&lt;BR /&gt;I have an XXX (a Civil Entity), which I explode it and I obtain a BlockReference.&lt;BR /&gt;I take the BlockReference and exploded it and I get the components (MTexts).&lt;BR /&gt;I modify the Contents attribute of the Mtext object, but I don't see any changes in the drawing.&lt;BR /&gt;So, any ideas? Maybe there is fundamental thing which I don't see.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;[CommandMethod("app")]&lt;BR /&gt;        public static void app()&lt;BR /&gt;        {&lt;BR /&gt;&lt;BR /&gt;            Document document = Application.DocumentManager.MdiActiveDocument;&lt;BR /&gt;            Database database = document.Database;&lt;BR /&gt;            Editor editor = Application.DocumentManager.MdiActiveDocument.Editor;&lt;BR /&gt;            String caleDirector = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\" + "NumeroteazaKilometrii\\";&lt;BR /&gt;            listAx = new List&amp;lt;Entity&amp;gt;();&lt;BR /&gt;&lt;BR /&gt;            &lt;BR /&gt;            using (Transaction transaction = database.TransactionManager.StartTransaction())&lt;BR /&gt;            {&lt;BR /&gt;                Entity minor;&lt;BR /&gt;&lt;BR /&gt;                DBObjectCollection dBObjectCollection = new DBObjectCollection();&lt;BR /&gt;&lt;BR /&gt;                PromptSelectionResult promptSelectionResult = Helper.selectEntities("Minor", document, true);&lt;BR /&gt;&lt;BR /&gt;                if (promptSelectionResult.Status == PromptStatus.OK)&lt;BR /&gt;                {&lt;BR /&gt;                    SelectionSet selectionSet = promptSelectionResult.Value;&lt;BR /&gt;                    minor = transaction.GetObject(selectionSet[0].ObjectId, OpenMode.ForWrite) as Entity;&lt;BR /&gt;                    if (minor == null) return;&lt;BR /&gt;                }&lt;BR /&gt;                else&lt;BR /&gt;                {&lt;BR /&gt;                    return;&lt;BR /&gt;                }&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;                &lt;BR /&gt;                if (minor is AlignmentMinorStationLabelGroup)&lt;BR /&gt;                {&lt;BR /&gt;                    minor.Explode(dBObjectCollection);&lt;BR /&gt;&lt;BR /&gt;                    foreach (Entity elementAx in dBObjectCollection)&lt;BR /&gt;                    {&lt;BR /&gt;                        listAx.Add(elementAx);&lt;BR /&gt;                    }&lt;BR /&gt;&lt;BR /&gt;                    Entity minor2 = listAx[0];&lt;BR /&gt;                    dBObjectCollection.Clear();&lt;BR /&gt;                    listAx.Clear();&lt;BR /&gt;&lt;BR /&gt;                    BlockReference block = null;&lt;BR /&gt;                    if (minor2 is BlockReference)&lt;BR /&gt;                    {&lt;BR /&gt;                        block = minor2 as BlockReference;&lt;BR /&gt;                    }&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;                    if (block != null)&lt;BR /&gt;                    {&lt;BR /&gt;                        block.Explode(dBObjectCollection);&lt;BR /&gt;                        foreach (Entity e in dBObjectCollection)&lt;BR /&gt;                        {&lt;BR /&gt;                            if (e is MText)&lt;BR /&gt;                            {&lt;BR /&gt;                                MText mText = e as MText;&lt;BR /&gt;                                mText.Contents = "BlaBlaBla";&lt;BR /&gt;                            }&lt;BR /&gt;                        }&lt;BR /&gt;                    }&lt;BR /&gt;                }&lt;BR /&gt;                transaction.Commit();&lt;BR /&gt;            }&lt;BR /&gt;        }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know I must take the components directly from database, but I don't know how to do this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I modified this line&lt;BR /&gt;&lt;STRONG&gt;MText mText = e as MText;&lt;/STRONG&gt;&lt;BR /&gt;with&lt;BR /&gt;&lt;STRONG&gt;MText mText =&amp;nbsp; transaction.GetObject(e.ObjectId, OpenMode.ForRead); as MText;&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;But I receive "null ObjectId"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, how can I &lt;STRONG&gt;add&lt;/STRONG&gt; those entity to my &lt;STRONG&gt;block&lt;/STRONG&gt;? How can I delete some components from my block?&lt;BR /&gt;I can't seem to find some code to understand this thing. I found some code to insert new BlockReferences, but not to modify them.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Feb 2011 09:32:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-modify-the-components-of-a-blockreference/m-p/2915380#M61888</guid>
      <dc:creator>pesctx</dc:creator>
      <dc:date>2011-02-14T09:32:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify the components of a BlockReference?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-modify-the-components-of-a-blockreference/m-p/2915912#M61889</link>
      <description>&lt;P&gt;I know nothing about Civil objects but if you need to&lt;/P&gt;&lt;P&gt;get valid ObjectID you have to add exploded objects&lt;/P&gt;&lt;P&gt;in the current space and then you can edit&lt;/P&gt;&lt;P&gt;the properties after&lt;/P&gt;&lt;P&gt;you could check if ObjectID before easy way&lt;/P&gt;&lt;P&gt;if ((e.ObjectID!=ObjectID.NUll) &amp;amp;&amp;amp; (e.ObjectID.IsValid))&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;//TODO&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;Just from top of my head&lt;/P&gt;</description>
      <pubDate>Mon, 14 Feb 2011 17:30:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-modify-the-components-of-a-blockreference/m-p/2915912#M61889</guid>
      <dc:creator>Hallex</dc:creator>
      <dc:date>2011-02-14T17:30:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify the components of a BlockReference?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-modify-the-components-of-a-blockreference/m-p/2916080#M61890</link>
      <description>&lt;P&gt;You can't edit a block reference's mtext. You would have to redefine the text in the block definition. Otherwise copy the block definition with a new unique blockname and then edit that definition and then replace the block reference with the new block reference you just created.&lt;BR /&gt;&lt;BR /&gt;Attributes are the only objects that can be edited per block reference.&lt;BR /&gt;&lt;BR /&gt;When you explode the Block Reference you are making a copy of the contents. You could use those contents to build a new block. Also the original Block Reference is still in the drawing when you explode it. You haven't affected the block refererence at all by exploding it.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Feb 2011 19:18:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-modify-the-components-of-a-blockreference/m-p/2916080#M61890</guid>
      <dc:creator>arcticad</dc:creator>
      <dc:date>2011-02-14T19:18:58Z</dc:date>
    </item>
  </channel>
</rss>

