<?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 CHANGE COLOR OF TEXT WITHIN A BLOCK in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/change-color-of-text-within-a-block/m-p/4801835#M45480</link>
    <description>&lt;P&gt;We have 600 blocks with text in them and the text is presently set to color by layer.&amp;nbsp; Each block has a unique name.&amp;nbsp; All have an &lt;STRONG&gt;08&lt;/STRONG&gt; and a &lt;STRONG&gt;20&lt;/STRONG&gt; plain text entity within them, which are part of a dynamic visibility parameter.&amp;nbsp; We want to change the &lt;FONT color="#33cccc"&gt;&lt;STRONG&gt;08&lt;/STRONG&gt;&lt;/FONT&gt; to cyan (index color 4) and the &lt;FONT color="#ff00ff"&gt;&lt;STRONG&gt;20&lt;/STRONG&gt;&lt;/FONT&gt; to magenta (index color 6).&amp;nbsp; We want to change them without having to open every block in the block editor.&amp;nbsp; This is only my second VB.NET program, and I am stuck.&amp;nbsp; Here's the code so far:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;        &amp;lt;CommandMethod("PCC")&amp;gt; _
        Public Sub PCC()
            Dim myDB As DatabaseServices.Database
            Dim myDWG As ApplicationServices.Document
            Dim myEd As EditorInput.Editor
            Dim myTransMan As DatabaseServices.TransactionManager
            Dim myTrans As DatabaseServices.Transaction
            Dim myPSR As EditorInput.PromptSelectionResult
            Dim MySS As EditorInput.SelectionSet
            Dim myAcadEnt As DatabaseServices.Entity
            Dim PlantCode As DBText
            Dim myObjIDs As DatabaseServices.ObjectIdCollection
            Dim myObjID As DatabaseServices.ObjectId
            myDWG = ApplicationServices.Application.DocumentManager.MdiActiveDocument
            myDB = myDWG.Database
            myEd = myDWG.Editor
            myPSR = myEd.GetSelection()
            If Not IsNothing(myPSR.Value) Then
                MySS = myPSR.Value
                myTransMan = myDWG.TransactionManager
                myTrans = myTransMan.StartTransaction
                myObjIDs = New DatabaseServices.ObjectIdCollection(MySS.GetObjectIds)
                For Each myObjID In myObjIDs
                    myAcadEnt = myObjID.GetObject(DatabaseServices.OpenMode.ForRead)
                    If myAcadEnt.ObjectId.ObjectClass.IsDerivedFrom(RXClass.GetClass(GetType(DBText))) Then
                        PlantCode = myAcadEnt
                        If PlantCode.TextString.Equals("08") Then
                            myAcadEnt.UpgradeOpen()
                            myAcadEnt.ColorIndex = 4
                        End If
                        If PlantCode.TextString.Equals("20") Then
                            myAcadEnt.UpgradeOpen()
                            myAcadEnt.ColorIndex = 6
                        End If
                    End If
                    myTrans.Commit()
                    'myTrans.Dispose()
                    myEd.Regen()
                Next
                myTrans.Dispose()
                myTransMan.Dispose()
            End If
        End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;The code only works on simple text, and not on the text within the blocks.&amp;nbsp; And if more that one item is selected, it throws an exception at&lt;/P&gt;&lt;PRE&gt;myAcadEnt = myObjID.GetObject(DatabaseServices.OpenMode.ForRead)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Attached is a DWG with a couple of the blocks and some plain text I've been using for testing.&amp;nbsp; Any help in getting this to work would be greatly appreciated.&lt;/P&gt;</description>
    <pubDate>Fri, 07 Feb 2014 19:46:30 GMT</pubDate>
    <dc:creator>bobmc</dc:creator>
    <dc:date>2014-02-07T19:46:30Z</dc:date>
    <item>
      <title>CHANGE COLOR OF TEXT WITHIN A BLOCK</title>
      <link>https://forums.autodesk.com/t5/net-forum/change-color-of-text-within-a-block/m-p/4801835#M45480</link>
      <description>&lt;P&gt;We have 600 blocks with text in them and the text is presently set to color by layer.&amp;nbsp; Each block has a unique name.&amp;nbsp; All have an &lt;STRONG&gt;08&lt;/STRONG&gt; and a &lt;STRONG&gt;20&lt;/STRONG&gt; plain text entity within them, which are part of a dynamic visibility parameter.&amp;nbsp; We want to change the &lt;FONT color="#33cccc"&gt;&lt;STRONG&gt;08&lt;/STRONG&gt;&lt;/FONT&gt; to cyan (index color 4) and the &lt;FONT color="#ff00ff"&gt;&lt;STRONG&gt;20&lt;/STRONG&gt;&lt;/FONT&gt; to magenta (index color 6).&amp;nbsp; We want to change them without having to open every block in the block editor.&amp;nbsp; This is only my second VB.NET program, and I am stuck.&amp;nbsp; Here's the code so far:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;        &amp;lt;CommandMethod("PCC")&amp;gt; _
        Public Sub PCC()
            Dim myDB As DatabaseServices.Database
            Dim myDWG As ApplicationServices.Document
            Dim myEd As EditorInput.Editor
            Dim myTransMan As DatabaseServices.TransactionManager
            Dim myTrans As DatabaseServices.Transaction
            Dim myPSR As EditorInput.PromptSelectionResult
            Dim MySS As EditorInput.SelectionSet
            Dim myAcadEnt As DatabaseServices.Entity
            Dim PlantCode As DBText
            Dim myObjIDs As DatabaseServices.ObjectIdCollection
            Dim myObjID As DatabaseServices.ObjectId
            myDWG = ApplicationServices.Application.DocumentManager.MdiActiveDocument
            myDB = myDWG.Database
            myEd = myDWG.Editor
            myPSR = myEd.GetSelection()
            If Not IsNothing(myPSR.Value) Then
                MySS = myPSR.Value
                myTransMan = myDWG.TransactionManager
                myTrans = myTransMan.StartTransaction
                myObjIDs = New DatabaseServices.ObjectIdCollection(MySS.GetObjectIds)
                For Each myObjID In myObjIDs
                    myAcadEnt = myObjID.GetObject(DatabaseServices.OpenMode.ForRead)
                    If myAcadEnt.ObjectId.ObjectClass.IsDerivedFrom(RXClass.GetClass(GetType(DBText))) Then
                        PlantCode = myAcadEnt
                        If PlantCode.TextString.Equals("08") Then
                            myAcadEnt.UpgradeOpen()
                            myAcadEnt.ColorIndex = 4
                        End If
                        If PlantCode.TextString.Equals("20") Then
                            myAcadEnt.UpgradeOpen()
                            myAcadEnt.ColorIndex = 6
                        End If
                    End If
                    myTrans.Commit()
                    'myTrans.Dispose()
                    myEd.Regen()
                Next
                myTrans.Dispose()
                myTransMan.Dispose()
            End If
        End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;The code only works on simple text, and not on the text within the blocks.&amp;nbsp; And if more that one item is selected, it throws an exception at&lt;/P&gt;&lt;PRE&gt;myAcadEnt = myObjID.GetObject(DatabaseServices.OpenMode.ForRead)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Attached is a DWG with a couple of the blocks and some plain text I've been using for testing.&amp;nbsp; Any help in getting this to work would be greatly appreciated.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Feb 2014 19:46:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/change-color-of-text-within-a-block/m-p/4801835#M45480</guid>
      <dc:creator>bobmc</dc:creator>
      <dc:date>2014-02-07T19:46:30Z</dc:date>
    </item>
    <item>
      <title>Re: CHANGE COLOR OF TEXT WITHIN A BLOCK</title>
      <link>https://forums.autodesk.com/t5/net-forum/change-color-of-text-within-a-block/m-p/4801899#M45481</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This should help you: &lt;A target="_self" href="http://through-the-interface.typepad.com/through_the_interface/2007/02/changing_the_co.html"&gt;Changing Colour of Nested Entities&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Gaston Nunez&lt;/P&gt;</description>
      <pubDate>Fri, 07 Feb 2014 20:17:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/change-color-of-text-within-a-block/m-p/4801899#M45481</guid>
      <dc:creator>hgasty1001</dc:creator>
      <dc:date>2014-02-07T20:17:35Z</dc:date>
    </item>
    <item>
      <title>Re: CHANGE COLOR OF TEXT WITHIN A BLOCK</title>
      <link>https://forums.autodesk.com/t5/net-forum/change-color-of-text-within-a-block/m-p/4801945#M45482</link>
      <description>&lt;P&gt;I was just reading about GetNestedEntity when your reply came.&amp;nbsp; Seems like all the examples I had seen deal with changing block attributes or block table records, which aren't the same thing.&amp;nbsp; This should be a big help.&amp;nbsp;I'll try to implement it in my project, and let you know.&amp;nbsp; Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 07 Feb 2014 20:42:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/change-color-of-text-within-a-block/m-p/4801945#M45482</guid>
      <dc:creator>bobmc</dc:creator>
      <dc:date>2014-02-07T20:42:31Z</dc:date>
    </item>
  </channel>
</rss>

