<?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 know in wich space is a selected object ? in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/how-to-know-in-wich-space-is-a-selected-object/m-p/6045454#M9108</link>
    <description>&lt;P&gt;You can use AcadDocument.ActiveSpace to test what the current space the selection is performed, because you do selecting on screen, which only allows you select entities in current/active space (either model, or paper)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, you can do something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If ThisDrawing.ActiveSpace=AcModelSpace Then&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Set BlockRefObj=ThisDrawing.ModelSpace.Insert(....)&lt;/P&gt;
&lt;P&gt;Else&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;Set BlockRefObj=ThisDrawing.PaperSpace.Insert(....)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;End If&lt;/P&gt;</description>
    <pubDate>Thu, 18 Feb 2016 14:28:10 GMT</pubDate>
    <dc:creator>norman.yuan</dc:creator>
    <dc:date>2016-02-18T14:28:10Z</dc:date>
    <item>
      <title>How to know in wich space is a selected object ?</title>
      <link>https://forums.autodesk.com/t5/vba-forum/how-to-know-in-wich-space-is-a-selected-object/m-p/6045344#M9107</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;All is in the title...&lt;/P&gt;&lt;P&gt;I have to select blocks, then replace them by other blocks.&lt;/P&gt;&lt;P&gt;I select them by :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;FilterType(0) = 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;FilterData(0) = "Insert"&lt;/P&gt;&lt;P&gt;oSS.SelectOnScreen FilterType, FilterData&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is ok, I select only Block entities.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I replace blocks :&lt;/P&gt;&lt;P&gt;oBlock.delete&lt;/P&gt;&lt;P&gt;Set BlockRefObj = ThisDrawing.&lt;STRONG&gt;ModelSpace.&lt;/STRONG&gt;InsertBlock(insertionpoint, blockname, 1#, 1#, 1#, rotateAngle)&lt;/P&gt;&lt;P&gt;...but this always insert the block in ModelSpace.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I detect in wich space is the original block, so I can insert the new blocx using Modelspace or Papersace (i) ?&lt;/P&gt;</description>
      <pubDate>Thu, 18 Feb 2016 13:38:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/how-to-know-in-wich-space-is-a-selected-object/m-p/6045344#M9107</guid>
      <dc:creator>TONELLAL</dc:creator>
      <dc:date>2016-02-18T13:38:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to know in wich space is a selected object ?</title>
      <link>https://forums.autodesk.com/t5/vba-forum/how-to-know-in-wich-space-is-a-selected-object/m-p/6045454#M9108</link>
      <description>&lt;P&gt;You can use AcadDocument.ActiveSpace to test what the current space the selection is performed, because you do selecting on screen, which only allows you select entities in current/active space (either model, or paper)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, you can do something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If ThisDrawing.ActiveSpace=AcModelSpace Then&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Set BlockRefObj=ThisDrawing.ModelSpace.Insert(....)&lt;/P&gt;
&lt;P&gt;Else&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;Set BlockRefObj=ThisDrawing.PaperSpace.Insert(....)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;End If&lt;/P&gt;</description>
      <pubDate>Thu, 18 Feb 2016 14:28:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/how-to-know-in-wich-space-is-a-selected-object/m-p/6045454#M9108</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2016-02-18T14:28:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to know in wich space is a selected object ?</title>
      <link>https://forums.autodesk.com/t5/vba-forum/how-to-know-in-wich-space-is-a-selected-object/m-p/6045466#M9109</link>
      <description>&lt;P&gt;"... because you do selecting on screen, which only allows you select entities in current/active space&amp;nbsp;" :&lt;/P&gt;&lt;P&gt;This is exactly where my problem is : if you select All, you select in paperspace AND in modelspace...&lt;/P&gt;</description>
      <pubDate>Thu, 18 Feb 2016 14:34:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/how-to-know-in-wich-space-is-a-selected-object/m-p/6045466#M9109</guid>
      <dc:creator>TONELLAL</dc:creator>
      <dc:date>2016-02-18T14:34:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to know in wich space is a selected object ?</title>
      <link>https://forums.autodesk.com/t5/vba-forum/how-to-know-in-wich-space-is-a-selected-object/m-p/6045493#M9110</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;each entity has an OwnerID which points to the block which holds the object, that can be the blockdefinition called modelspace, it can also be the blockdefinition of every layout existing in the drawing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's see if that helps (code goes through "Point" objects in a selection set and places a new blockreference at the position of the point (and in the modelspace or layout(s) of that point(s).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Dim tEnt As AcadPoint
For Each tEnt In tSelSet
   Debug.Print ("")
   Dim tBlock As AcadBlock
   Set tBlock = ThisDrawing.ObjectIdToObject(tEnt.OwnerID)  'that is the owner (parent) of the point
   Dim tBlRef As AcadBlockReference
   Set tBlRef = tBlock.InsertBlock(tEnt.Coordinates, "NewBlockName", 1, 1, 1, 0)
Next&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- alfred -&lt;/P&gt;</description>
      <pubDate>Thu, 18 Feb 2016 14:42:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/how-to-know-in-wich-space-is-a-selected-object/m-p/6045493#M9110</guid>
      <dc:creator>Alfred.NESWADBA</dc:creator>
      <dc:date>2016-02-18T14:42:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to know in wich space is a selected object ?</title>
      <link>https://forums.autodesk.com/t5/vba-forum/how-to-know-in-wich-space-is-a-selected-object/m-p/6045686#M9111</link>
      <description>&lt;P&gt;Thanks Alfred !&lt;/P&gt;&lt;P&gt;I did something like this :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Space = ThisDrawing.ObjectIdToObject(tEnt.OwnerID)&lt;/P&gt;&lt;P&gt;If Space.Name = "*Paper_Space" Then&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set BlockRefObj = ThisDrawing.PaperSpace.InsertBlock(insertionpoint, blockname, 1#, 1#, 1#, rotateAngle)&lt;BR /&gt;Else&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set BlockRefObj = ThisDrawing.ModelSpace.InsertBlock(insertionpoint, blockname, 1#, 1#, 1#, rotateAngle)&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Alain&lt;/P&gt;</description>
      <pubDate>Thu, 18 Feb 2016 16:10:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/how-to-know-in-wich-space-is-a-selected-object/m-p/6045686#M9111</guid>
      <dc:creator>TONELLAL</dc:creator>
      <dc:date>2016-02-18T16:10:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to know in wich space is a selected object ?</title>
      <link>https://forums.autodesk.com/t5/vba-forum/how-to-know-in-wich-space-is-a-selected-object/m-p/6045707#M9112</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;FONT color="#000080"&gt;&amp;gt;&amp;gt; I did something like this [...]&lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Sorry, that might fail. If you have more than one layouts then the "ThisDrawing.Paperspace" points to the first/active layout,&lt;/P&gt;
&lt;P&gt;In case your blockreference is on layout3 your insertion would be done on layout1 instead of layout3&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That's why I suggested do use (using your variables) &lt;FONT color="#000080"&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;Space.InsertBlock....&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- alfred -&lt;/P&gt;</description>
      <pubDate>Thu, 18 Feb 2016 16:21:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/how-to-know-in-wich-space-is-a-selected-object/m-p/6045707#M9112</guid>
      <dc:creator>Alfred.NESWADBA</dc:creator>
      <dc:date>2016-02-18T16:21:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to know in wich space is a selected object ?</title>
      <link>https://forums.autodesk.com/t5/vba-forum/how-to-know-in-wich-space-is-a-selected-object/m-p/6045769#M9113</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Ok, not understood very well first time.&lt;/P&gt;&lt;P&gt;I noticed the problem if I have several layouts, but strangely it seems to function...&lt;/P&gt;</description>
      <pubDate>Thu, 18 Feb 2016 16:55:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/how-to-know-in-wich-space-is-a-selected-object/m-p/6045769#M9113</guid>
      <dc:creator>TONELLAL</dc:creator>
      <dc:date>2016-02-18T16:55:27Z</dc:date>
    </item>
  </channel>
</rss>

