<?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 VB.Net Explode block in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/vb-net-explode-block/m-p/6979085#M32136</link>
    <description>&lt;DIV class="lia-message-heading lia-component-message-header"&gt;
&lt;DIV class="lia-quilt-row lia-quilt-row-standard"&gt;
&lt;DIV class="lia-quilt-column lia-quilt-column-20 lia-quilt-column-left"&gt;
&lt;DIV class="lia-quilt-column-alley lia-quilt-column-alley-left"&gt;
&lt;DIV class="lia-message-subject"&gt;
&lt;P&gt;I am trying create a routine for AutoCAD 2015.&lt;/P&gt;
&lt;P&gt;I am using VSC 2013 with ObjectARX 2015.&lt;/P&gt;
&lt;/DIV&gt;
&lt;DIV class="lia-message-subject"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="lia-message-subject"&gt;The routine finds all block references in the drawing. Looks to see if there are nested blocks with attributes under the block. If all criteria are met explode the parent block.&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV id="messagebodydisplay_0" class="lia-message-body"&gt;
&lt;DIV class="lia-message-body-content"&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Public Shared Sub ExplodeNestedBlocks()&lt;BR /&gt;Dim doc As Document = Application.DocumentManager.MdiActiveDocument&lt;BR /&gt;doc.LockDocument()&lt;BR /&gt;Application.DocumentManager.MdiActiveDocument.Lock&lt;WBR /&gt;Document()&lt;BR /&gt;Dim ed As Editor = doc.Editor&lt;BR /&gt;Dim acTypValAr(0) As TypedValue&lt;BR /&gt;acTypValAr.SetValue(New TypedValue(DxfCode.Start, "INSERT"), 0)&lt;BR /&gt;Dim acSelFtr As SelectionFilter = New SelectionFilter(acTypValAr)&lt;BR /&gt;Dim trans As Transaction = Application.DocumentManager.MdiActiveDocument.Data&lt;WBR /&gt;base.TransactionManager.StartTransaction()&lt;BR /&gt;Dim acSSPrompt As PromptSelectionResult&lt;BR /&gt;acSSPrompt = ed.SelectAll(acSelFtr)&lt;BR /&gt;If acSSPrompt.Status = PromptStatus.OK Then&lt;BR /&gt;Dim acSSet As SelectionSet = acSSPrompt.Value&lt;BR /&gt;For Each Itm As SelectedObject In acSSet&lt;BR /&gt;Dim BlkRef As BlockReference = trans.GetObject(Itm.ObjectId, OpenMode.ForWrite, False, True)&lt;BR /&gt;Dim BlkRec As BlockTableRecord = trans.GetObject(BlkRef.BlockTableRecord, OpenMode.ForWrite, False, True)&lt;BR /&gt;If BlkRec.XrefStatus = XrefStatus.NotAnXref And _&lt;BR /&gt;BlkRef.IsAProxy = False And _&lt;BR /&gt;BlkRef.IsDynamicBlock = False And _&lt;BR /&gt;BlkRec.Explodable = True And _&lt;BR /&gt;BlkRec.HasAttributeDefinitions = False And _&lt;BR /&gt;BlkRec.IsAProxy = False And _&lt;BR /&gt;BlkRec.IsDependent = False And _&lt;BR /&gt;BlkRec.IsDynamicBlock = False And _&lt;BR /&gt;BlkRec.IsLayout = False Then&lt;BR /&gt;For Each ent In BlkRec&lt;BR /&gt;If ent.ObjectClass.DxfName = "INSERT" Then&lt;BR /&gt;Dim SubBlkRef As BlockReference = trans.GetObject(ent, OpenMode.ForWrite, False, True)&lt;BR /&gt;Dim SubBlkRec As BlockTableRecord = trans.GetObject(SubBlkRef.BlockTableRecord, OpenMode.ForWrite, False, True)&lt;BR /&gt;If SubBlkRec.HasAttributeDefinitions = True Then&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;lt;&amp;lt;EXPLODE BLKREF&amp;gt;&amp;gt; This is the part of the routine that escapes me right now. BlkRef.ExplodeToOwnerSpace and BlkRef.Explode do not seem to work.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;End If&lt;BR /&gt;End If&lt;BR /&gt;Next&lt;BR /&gt;End If&lt;BR /&gt;Next&lt;/P&gt;
&lt;P&gt;trans.Commit()&lt;/P&gt;
&lt;P&gt;&amp;nbsp;End If&lt;BR /&gt;End Sub&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance for any insight.&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
    <pubDate>Tue, 28 Mar 2017 16:27:57 GMT</pubDate>
    <dc:creator>Jedimaster</dc:creator>
    <dc:date>2017-03-28T16:27:57Z</dc:date>
    <item>
      <title>VB.Net Explode block</title>
      <link>https://forums.autodesk.com/t5/net-forum/vb-net-explode-block/m-p/6979085#M32136</link>
      <description>&lt;DIV class="lia-message-heading lia-component-message-header"&gt;
&lt;DIV class="lia-quilt-row lia-quilt-row-standard"&gt;
&lt;DIV class="lia-quilt-column lia-quilt-column-20 lia-quilt-column-left"&gt;
&lt;DIV class="lia-quilt-column-alley lia-quilt-column-alley-left"&gt;
&lt;DIV class="lia-message-subject"&gt;
&lt;P&gt;I am trying create a routine for AutoCAD 2015.&lt;/P&gt;
&lt;P&gt;I am using VSC 2013 with ObjectARX 2015.&lt;/P&gt;
&lt;/DIV&gt;
&lt;DIV class="lia-message-subject"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="lia-message-subject"&gt;The routine finds all block references in the drawing. Looks to see if there are nested blocks with attributes under the block. If all criteria are met explode the parent block.&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV id="messagebodydisplay_0" class="lia-message-body"&gt;
&lt;DIV class="lia-message-body-content"&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Public Shared Sub ExplodeNestedBlocks()&lt;BR /&gt;Dim doc As Document = Application.DocumentManager.MdiActiveDocument&lt;BR /&gt;doc.LockDocument()&lt;BR /&gt;Application.DocumentManager.MdiActiveDocument.Lock&lt;WBR /&gt;Document()&lt;BR /&gt;Dim ed As Editor = doc.Editor&lt;BR /&gt;Dim acTypValAr(0) As TypedValue&lt;BR /&gt;acTypValAr.SetValue(New TypedValue(DxfCode.Start, "INSERT"), 0)&lt;BR /&gt;Dim acSelFtr As SelectionFilter = New SelectionFilter(acTypValAr)&lt;BR /&gt;Dim trans As Transaction = Application.DocumentManager.MdiActiveDocument.Data&lt;WBR /&gt;base.TransactionManager.StartTransaction()&lt;BR /&gt;Dim acSSPrompt As PromptSelectionResult&lt;BR /&gt;acSSPrompt = ed.SelectAll(acSelFtr)&lt;BR /&gt;If acSSPrompt.Status = PromptStatus.OK Then&lt;BR /&gt;Dim acSSet As SelectionSet = acSSPrompt.Value&lt;BR /&gt;For Each Itm As SelectedObject In acSSet&lt;BR /&gt;Dim BlkRef As BlockReference = trans.GetObject(Itm.ObjectId, OpenMode.ForWrite, False, True)&lt;BR /&gt;Dim BlkRec As BlockTableRecord = trans.GetObject(BlkRef.BlockTableRecord, OpenMode.ForWrite, False, True)&lt;BR /&gt;If BlkRec.XrefStatus = XrefStatus.NotAnXref And _&lt;BR /&gt;BlkRef.IsAProxy = False And _&lt;BR /&gt;BlkRef.IsDynamicBlock = False And _&lt;BR /&gt;BlkRec.Explodable = True And _&lt;BR /&gt;BlkRec.HasAttributeDefinitions = False And _&lt;BR /&gt;BlkRec.IsAProxy = False And _&lt;BR /&gt;BlkRec.IsDependent = False And _&lt;BR /&gt;BlkRec.IsDynamicBlock = False And _&lt;BR /&gt;BlkRec.IsLayout = False Then&lt;BR /&gt;For Each ent In BlkRec&lt;BR /&gt;If ent.ObjectClass.DxfName = "INSERT" Then&lt;BR /&gt;Dim SubBlkRef As BlockReference = trans.GetObject(ent, OpenMode.ForWrite, False, True)&lt;BR /&gt;Dim SubBlkRec As BlockTableRecord = trans.GetObject(SubBlkRef.BlockTableRecord, OpenMode.ForWrite, False, True)&lt;BR /&gt;If SubBlkRec.HasAttributeDefinitions = True Then&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;lt;&amp;lt;EXPLODE BLKREF&amp;gt;&amp;gt; This is the part of the routine that escapes me right now. BlkRef.ExplodeToOwnerSpace and BlkRef.Explode do not seem to work.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;End If&lt;BR /&gt;End If&lt;BR /&gt;Next&lt;BR /&gt;End If&lt;BR /&gt;Next&lt;/P&gt;
&lt;P&gt;trans.Commit()&lt;/P&gt;
&lt;P&gt;&amp;nbsp;End If&lt;BR /&gt;End Sub&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance for any insight.&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Tue, 28 Mar 2017 16:27:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/vb-net-explode-block/m-p/6979085#M32136</guid>
      <dc:creator>Jedimaster</dc:creator>
      <dc:date>2017-03-28T16:27:57Z</dc:date>
    </item>
    <item>
      <title>Re : VB.Net Explode block</title>
      <link>https://forums.autodesk.com/t5/net-forum/vb-net-explode-block/m-p/6979143#M32137</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using ExplodeToOwnerSpace() method you do not have to add each component to the block reference owner space but you have to erase the block reference:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;BlkRef.ExplodeToOwnerSpace()
BlkRef.Erase()&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using Explode() method you have to add each component to the block owner space and erase it too.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;var objs = new DBObjectCollection();
br.Explode(objs);
var space = (BlockTableRecord)tr.GetObject(br.OwnerId, OpenMode.ForWrite);
foreach (DBObject obj in objs)
{
    space.AppendEntity((Entity)obj);
    tr.AddNewlyCreatedDBObject(obj, true);
}
br.Erase();&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Mar 2017 16:51:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/vb-net-explode-block/m-p/6979143#M32137</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2017-03-28T16:51:43Z</dc:date>
    </item>
  </channel>
</rss>

