<?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: Extract the location of the block (paper space, object space) in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/extract-the-location-of-the-block-paper-space-object-space/m-p/11348634#M2264</link>
    <description>&lt;P&gt;Thank you for your solution. I'll check that.&lt;/P&gt;&lt;P&gt;Indeed, my method select blocks with a selection filter based on their names.&lt;BR /&gt;This solution will not work with dynamics blocks ?&lt;BR /&gt;Why ?&lt;BR /&gt;&lt;BR /&gt;Thank you in advance&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 09 Aug 2022 12:08:21 GMT</pubDate>
    <dc:creator>NeoLitik</dc:creator>
    <dc:date>2022-08-09T12:08:21Z</dc:date>
    <item>
      <title>Extract the location of the block (paper space, object space)</title>
      <link>https://forums.autodesk.com/t5/vba-forum/extract-the-location-of-the-block-paper-space-object-space/m-p/11346289#M2262</link>
      <description>&lt;P&gt;Hi there.&lt;BR /&gt;I'm making a VBA code who extract blocks with a selection filter and write these informations in excel.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;please find here an extract from my code :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For i = 0 To GetSS_BlockName("CARTOUCHE").Count - 1&lt;BR /&gt;Set BlocRef = GetSS_BlockName("CARTOUCHE").Item(i)&lt;BR /&gt;If BlocRef.HasAttributes Then&lt;BR /&gt;Cells(1, Column).Value = acadDoc.Name&lt;BR /&gt;Cells(2, Column).Value = BlocRef.Name&lt;BR /&gt;Cells(3, Column).Value = BlocRef.Handle&lt;BR /&gt;Cells(4, Column).Value = &lt;STRONG&gt;BlocRef.Layouts&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For the last cells, i wish to extract the position of the block. I mean, if the block is in model space, or paper space. I didnt find an easy way to do this.&lt;BR /&gt;&lt;BR /&gt;Do you have an idea ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Aug 2022 12:25:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/extract-the-location-of-the-block-paper-space-object-space/m-p/11346289#M2262</guid>
      <dc:creator>NeoLitik</dc:creator>
      <dc:date>2022-08-08T12:25:55Z</dc:date>
    </item>
    <item>
      <title>Re: Extract the location of the block (paper space, object space)</title>
      <link>https://forums.autodesk.com/t5/vba-forum/extract-the-location-of-the-block-paper-space-object-space/m-p/11346477#M2263</link>
      <description>&lt;P&gt;Each AcadEntity (AcadBlockReference, in your case) has a property "OwnerID", which you use to decide which space the entity belongs to. Since this property only points to the owning AcadBlock, not directly to the layout, you'd be better to create a separate function to get entity's layout name with OwnerID as input. Something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Private Function GetEntityLayoutName(ownerId as LongPtr) As String&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;Dim layoutName As String&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;Dim lay As AcadLayout&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;If ownerId=ThisDrawing.ModelSpace.ObjectId Then&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; layoutName = "MODEL"&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;Else&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; For Each lay In ThisDrawing.Layouts&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;If lay.Block.ObjectId=ownerId Then&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; layoutName=lay.Name&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Exit For&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;End Id&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; Next&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;End If&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;GetEntityLayoutName = layoutName&lt;/P&gt;
&lt;P&gt;End Function&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then in your code:&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Cells(4, Column).Value =&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;GetEntityLayoutName(BlockRef.OwnerId)&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hopefully, your method&amp;nbsp;&lt;SPAN&gt;GetSS_BlockName() find targeted block references correctly (that is, if the block could be dynamic, you do not rely on block name as selection filter).&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Aug 2022 13:48:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/extract-the-location-of-the-block-paper-space-object-space/m-p/11346477#M2263</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2022-08-08T13:48:55Z</dc:date>
    </item>
    <item>
      <title>Re: Extract the location of the block (paper space, object space)</title>
      <link>https://forums.autodesk.com/t5/vba-forum/extract-the-location-of-the-block-paper-space-object-space/m-p/11348634#M2264</link>
      <description>&lt;P&gt;Thank you for your solution. I'll check that.&lt;/P&gt;&lt;P&gt;Indeed, my method select blocks with a selection filter based on their names.&lt;BR /&gt;This solution will not work with dynamics blocks ?&lt;BR /&gt;Why ?&lt;BR /&gt;&lt;BR /&gt;Thank you in advance&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2022 12:08:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/extract-the-location-of-the-block-paper-space-object-space/m-p/11348634#M2264</guid>
      <dc:creator>NeoLitik</dc:creator>
      <dc:date>2022-08-09T12:08:21Z</dc:date>
    </item>
    <item>
      <title>Re: Extract the location of the block (paper space, object space)</title>
      <link>https://forums.autodesk.com/t5/vba-forum/extract-the-location-of-the-block-paper-space-object-space/m-p/11348924#M2265</link>
      <description>&lt;P&gt;It has to do with the way dynamic blocks work. Whenever you change any configuration of the dynamic block, AutoCAD creates an anonymous block of the new configuration and sets it's EffectiveName property to the name of the original block. So if you are trying to select dynamic blocks by their name, you need to check each block for its EffectiveName property.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Search this forum for "EffectiveName".&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2022 14:05:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/extract-the-location-of-the-block-paper-space-object-space/m-p/11348924#M2265</guid>
      <dc:creator>Ed__Jobe</dc:creator>
      <dc:date>2022-08-09T14:05:21Z</dc:date>
    </item>
    <item>
      <title>Re: Extract the location of the block (paper space, object space)</title>
      <link>https://forums.autodesk.com/t5/vba-forum/extract-the-location-of-the-block-paper-space-object-space/m-p/11349121#M2266</link>
      <description>&lt;P&gt;Further to&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/14801"&gt;@Ed__Jobe&lt;/a&gt;&amp;nbsp;'s explanation, here is the way to do it, if you use SelectionSet with filter. That is, you cannot use block name as filter, if the targeted blocks could be dynamic blocks. Instead, you only use filter for "INSERT" (i.e. block references). Then you loop through the selection set to test is "EffectiveName" property:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Dim grpCode(0) As Integer&lt;/P&gt;
&lt;P&gt;Dim dataValue(0) As Variant&lt;/P&gt;
&lt;P&gt;grpCode(0)=0 : dataValue(0)="INSERT"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;'' Select ALL block references&lt;/P&gt;
&lt;P&gt;Dim ss As AcadSelectionSet&lt;/P&gt;
&lt;P&gt;Set ss=ThisDrawing.SelectionSets.Add("mySet")&lt;/P&gt;
&lt;P&gt;ss.Select ..,&amp;nbsp; ,&amp;nbsp; &amp;nbsp;, grpCode, dataValue&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;'' Find target blocks&lt;/P&gt;
&lt;P&gt;Dim blk As BlockReference&lt;/P&gt;
&lt;P&gt;For Each blk in ss&lt;/P&gt;
&lt;P&gt;&amp;nbsp; If UCase(blk.EffectiveName)="THE_BLOCK" Then&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; '' This is the block reference in interest, which has its name like "*Uxxxx"&lt;/P&gt;
&lt;P&gt;&amp;nbsp; End If&lt;/P&gt;
&lt;P&gt;Next&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HTH&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2022 15:26:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/extract-the-location-of-the-block-paper-space-object-space/m-p/11349121#M2266</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2022-08-09T15:26:41Z</dc:date>
    </item>
    <item>
      <title>Re: Extract the location of the block (paper space, object space)</title>
      <link>https://forums.autodesk.com/t5/vba-forum/extract-the-location-of-the-block-paper-space-object-space/m-p/11350722#M2267</link>
      <description>&lt;P&gt;thank you so much for your explanation&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Aug 2022 08:35:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/extract-the-location-of-the-block-paper-space-object-space/m-p/11350722#M2267</guid>
      <dc:creator>NeoLitik</dc:creator>
      <dc:date>2022-08-10T08:35:54Z</dc:date>
    </item>
  </channel>
</rss>

