<?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 iterate through items of a block reference in Dotnet ? in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/how-to-iterate-through-items-of-a-block-reference-in-dotnet/m-p/3871228#M50016</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It seems to me you do not completely understand what a block reference is an what are the differences and relationship between block definitions (BlockTableRecord object in .NET) and block references (BlockReference).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A block reference does not contains entities, it is only a geometric representation of a block definition.&lt;/P&gt;&lt;P&gt;If you want to change the block components layer, you have to do it within the block definition itereting it (without exploding nothing) and the changes will affect all the inserted references.&lt;/P&gt;</description>
    <pubDate>Sun, 14 Apr 2013 06:57:49 GMT</pubDate>
    <dc:creator>_gile</dc:creator>
    <dc:date>2013-04-14T06:57:49Z</dc:date>
    <item>
      <title>How to iterate through items of a block reference in Dotnet ?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-iterate-through-items-of-a-block-reference-in-dotnet/m-p/3871152#M50015</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm a newbie in dotnet and&amp;nbsp;want&amp;nbsp;&amp;nbsp;to now if is possible to iterate through items of a block reference.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My problem is the following : I explode a block reference in dotnet (it works well) and I want to change the items layer that compose the bloc reference. It's the reason why i need to browse items of this block.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If sombody have&amp;nbsp;another solution, I take it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thak you in advance for your help...&lt;/P&gt;</description>
      <pubDate>Sat, 13 Apr 2013 23:04:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-iterate-through-items-of-a-block-reference-in-dotnet/m-p/3871152#M50015</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-04-13T23:04:19Z</dc:date>
    </item>
    <item>
      <title>Re : How to iterate through items of a block reference in Dotnet ?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-iterate-through-items-of-a-block-reference-in-dotnet/m-p/3871228#M50016</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It seems to me you do not completely understand what a block reference is an what are the differences and relationship between block definitions (BlockTableRecord object in .NET) and block references (BlockReference).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A block reference does not contains entities, it is only a geometric representation of a block definition.&lt;/P&gt;&lt;P&gt;If you want to change the block components layer, you have to do it within the block definition itereting it (without exploding nothing) and the changes will affect all the inserted references.&lt;/P&gt;</description>
      <pubDate>Sun, 14 Apr 2013 06:57:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-iterate-through-items-of-a-block-reference-in-dotnet/m-p/3871228#M50016</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2013-04-14T06:57:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to iterate through items of a block reference in Dotnet ?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-iterate-through-items-of-a-block-reference-in-dotnet/m-p/3871257#M50017</link>
      <description>&lt;P&gt;Bonjour Gile,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Merci de ta réponse si rapide.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Je suis tout à fait d'accord sur le fait que je n'ai pas tout à fait compris la notion de block reference et c'est d'ailleurs pour cette raison que je solicite votre aide.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;J' ai lu plusieurs de vos tutoriaux et j'avoue que cela m'a permis d'avancer sur pas mal de point.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Je vais essayer de vous expliquer mon problème en français :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;1 - J'ai besoin d'exploser un block qui est inséré dans mon desssin (dans mon model_space) , jusqu'ici ça va&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;2 - mais ce block contient plusieurs solides qui ont des layers différents et pour cela, je voudrais pouvoir leur (solides) attribuer le même layer que celui du block d'origine. &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;voici le code&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;1 -&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;Public Sub ExplodeBlockOfSameLayerInModelSpace()
            Dim zDlg As Form_EBL = New Form_EBL()
            Dim zResult As System.Windows.Forms.DialogResult = AcadAp.ShowModalDialog(zDlg)
            Dim zDoc As Document = Application.DocumentManager.MdiActiveDocument
            Dim zDb As Database = zDoc.Database
            Dim zEd As Editor = zDoc.Editor
           
            If zResult = Windows.Forms.DialogResult.OK Then

                Dim i As Integer = 0

                Using zTrans As Transaction = zDb.TransactionManager.StartTransaction()

                    Dim zBlkTbl As BlockTable = zTrans.GetObject(zDb.BlockTableId, OpenMode.ForRead)
                    Dim zBlkTblRec As BlockTableRecord = zTrans.GetObject(zBlkTbl(BlockTableRecord.ModelSpace), OpenMode.ForRead)
                    Dim zBlkCl As RXClass = RXClass.GetClass(GetType(BlockReference))

                    For Each zBlkTblRecId As ObjectId In zBlkTblRec
                        Try

                            If zBlkTblRecId.ObjectClass = zBlkCl Then
                                Dim zBlkRef As BlockReference = TryCast(zTrans.GetObject(zBlkTblRecId, OpenMode.ForWrite, False), BlockReference)

                                If zBlkRef.Layer = zDlg.LstLayer.SelectedItem Then

                                    zEd.WriteMessage(String.Format(vbLf + "Block : {0} -- Id : {1} -- Layer : {2}", zBlkRef.Name, zBlkTblRecId, zBlkRef.Layer))
                                    zBlkRef.ExplodeToOwnerSpace()
                                    zBlkRef.Erase(True)
                                    i = i + 1

                                End If
                            End If
                        Catch ex As SystemException
                            zEd.WriteMessage(vbLf + "Problème rencontré : ", ex.Message())
                        End Try
                    Next
                    zEd.WriteMessage(String.Format(vbLf + "Total des blocs exploxés : {0} ", i))
                    zTrans.Commit()
                End Using
            Else
                zEd.WriteMessage(vbLf + "Opération annulée par l'utulisateur.")
            End If

&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;En fait un formulaire s'affiche avec la liste de layers spécifiques de blocs que je veux exploser. Une fois les blocs explosés, je voudrais le layer des solides qui composent celui-ci soient le même que le layer du bloc.&lt;/P&gt;&lt;P&gt;J'ai besoin des solides pour une autre utilité.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;J'espère avoir été suffisament clair dans les détails.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Merci d'avance...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 14 Apr 2013 10:29:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-iterate-through-items-of-a-block-reference-in-dotnet/m-p/3871257#M50017</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-04-14T10:29:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to iterate through items of a block reference in Dotnet ?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-iterate-through-items-of-a-block-reference-in-dotnet/m-p/3871265#M50018</link>
      <description>&lt;P&gt;D'accord, c'est moi qui avait mal compris.&lt;/P&gt;&lt;P&gt;À la place de ExplodeToOwnerSpace(), il faut utiliser la méthode Explode() qui requiert un paramètre de type DBObjectCollection.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Pseudo code :&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Créer une nouvelle instance de DBObjectCollection&lt;/LI&gt;&lt;LI&gt;Parcourir l'espace objet comme tu le fais&lt;/LI&gt;&lt;LI&gt;Appeler Explode() pour chaque bloc à décomposer en lui passant l'intance de DBObjectCollection comme paramètre et effacer le bloc&lt;/LI&gt;&lt;LI&gt;Pour chaque objet contenu dans l'intance de DBObjectCollection, l'ajouter à l'espace objet et à la transaction (il est impératif d'appeler Dispose() si on ajoute pas l'objet)&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 14 Apr 2013 11:09:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-iterate-through-items-of-a-block-reference-in-dotnet/m-p/3871265#M50018</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2013-04-14T11:09:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to iterate through items of a block reference in Dotnet ?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-iterate-through-items-of-a-block-reference-in-dotnet/m-p/3871281#M50019</link>
      <description>Merci bcp&lt;BR /&gt;Je vais faire ça et je vous tiens au courant.&lt;BR /&gt;Merci aussi pour la réactivité.</description>
      <pubDate>Sun, 14 Apr 2013 11:47:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-iterate-through-items-of-a-block-reference-in-dotnet/m-p/3871281#M50019</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-04-14T11:47:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to iterate through items of a block reference in Dotnet ?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-iterate-through-items-of-a-block-reference-in-dotnet/m-p/3871304#M50020</link>
      <description>Grâce à vos explications, j'ai réussi à réaliser la 2ème étape de mon projet.&lt;BR /&gt;&lt;BR /&gt;Encore merci pour vos nombreuses contributions.&lt;BR /&gt;&lt;BR /&gt;En passant je me suis inscrit sur cadxp.com mais je ne peux toujours pas répondre ou commencer un sujet. Etant donné que vous faites partie du staff Pourriez-vous me dire le temps d'attente.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sun, 14 Apr 2013 14:52:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-iterate-through-items-of-a-block-reference-in-dotnet/m-p/3871304#M50020</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-04-14T14:52:02Z</dc:date>
    </item>
  </channel>
</rss>

