<?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: VB.NET to select object in paperspace and get Layout name in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/vb-net-to-select-object-in-paperspace-and-get-layout-name/m-p/8341174#M24557</link>
    <description>&lt;P&gt;Sorry the text was not right&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. the object are in ModelSpace that can be seen in the Viewport on layout&lt;/P&gt;&lt;P&gt;I have large drawing with 10 or more Layout I need to select object in ModelSpace and get the layout name&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;see attachment&lt;BR /&gt;1. if I select Object 1 or 2 I get the name "Layout-A4-name1"&lt;BR /&gt;2. if I select Object 3 or 4 I get the name "Layout-A4-name2"&lt;BR /&gt;3. if I select Object 5 Nothing happens object 5 can not seen in the Viewport on layout&lt;/P&gt;</description>
    <pubDate>Wed, 17 Oct 2018 17:06:33 GMT</pubDate>
    <dc:creator>Sgear</dc:creator>
    <dc:date>2018-10-17T17:06:33Z</dc:date>
    <item>
      <title>VB.NET to select object in paperspace and get Layout name</title>
      <link>https://forums.autodesk.com/t5/net-forum/vb-net-to-select-object-in-paperspace-and-get-layout-name/m-p/8339952#M24555</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;somtime I have 5 Layout or more&lt;/P&gt;&lt;P&gt;is it poseble in VB.NET to select object in paperspace and get Layout name if the Object ar in any Viewport&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Sgear&lt;/P&gt;</description>
      <pubDate>Wed, 17 Oct 2018 09:16:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/vb-net-to-select-object-in-paperspace-and-get-layout-name/m-p/8339952#M24555</guid>
      <dc:creator>Sgear</dc:creator>
      <dc:date>2018-10-17T09:16:05Z</dc:date>
    </item>
    <item>
      <title>Re: VB.NET to select object in paperspace and get Layout name</title>
      <link>https://forums.autodesk.com/t5/net-forum/vb-net-to-select-object-in-paperspace-and-get-layout-name/m-p/8340510#M24556</link>
      <description>&lt;P&gt;You may want to clarify this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;...if the Object ar in any Viewport&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you say "Viewport", I assume it is a Viewport opened on given layout (PaperSpace).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does "Objects are in any Viewport" mean objects in ModelSpace that can be seen in the Viewport on layout? If so, these objects are in ModelSpace obviously.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or Do you mean objects actually in the PaperSpace of the layout but happen to sit in the area where a Viewport covers. In this case, why even mention Viewport? It has nothing to do with finding these objects' layout name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But since you say "&lt;SPAN&gt;select object in paperspace and get Layout name", you can find any entity's layout name (including "Model" for ModelSpace, like this&amp;nbsp; extension method (not tested):&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Public static string GetEntityLayoutName(this ObjectId entId)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; var layoutName="";&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; using (var tran = entId.Database.TransactionManager.StartTransaction())&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; {&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; var ent = (Entity) tran.GetObject(entId, OpenMode.ForRead);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; var owner = (BlockTableRecord)tran.GetObject(ent.OwnerId, OpenMode.ForRead);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; If (owner.IsLayout)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; {&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; var layout = (Layout)tran.GetObject(owner.LayoutId, OpenMode.ForRead);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; layoutName = layout.LayoutName;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; tran.Commit();&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; return layoutName;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Oct 2018 13:21:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/vb-net-to-select-object-in-paperspace-and-get-layout-name/m-p/8340510#M24556</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2018-10-17T13:21:29Z</dc:date>
    </item>
    <item>
      <title>Re: VB.NET to select object in paperspace and get Layout name</title>
      <link>https://forums.autodesk.com/t5/net-forum/vb-net-to-select-object-in-paperspace-and-get-layout-name/m-p/8341174#M24557</link>
      <description>&lt;P&gt;Sorry the text was not right&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. the object are in ModelSpace that can be seen in the Viewport on layout&lt;/P&gt;&lt;P&gt;I have large drawing with 10 or more Layout I need to select object in ModelSpace and get the layout name&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;see attachment&lt;BR /&gt;1. if I select Object 1 or 2 I get the name "Layout-A4-name1"&lt;BR /&gt;2. if I select Object 3 or 4 I get the name "Layout-A4-name2"&lt;BR /&gt;3. if I select Object 5 Nothing happens object 5 can not seen in the Viewport on layout&lt;/P&gt;</description>
      <pubDate>Wed, 17 Oct 2018 17:06:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/vb-net-to-select-object-in-paperspace-and-get-layout-name/m-p/8341174#M24557</guid>
      <dc:creator>Sgear</dc:creator>
      <dc:date>2018-10-17T17:06:33Z</dc:date>
    </item>
    <item>
      <title>Re: VB.NET to select object in paperspace and get Layout name</title>
      <link>https://forums.autodesk.com/t5/net-forum/vb-net-to-select-object-in-paperspace-and-get-layout-name/m-p/8341495#M24558</link>
      <description>&lt;P&gt;So, your goal is to identify/select entities in MOdalSpace which can be seen from a Viewport on a paperspace layout . In this case, how many layouts, how many viewpoers on these layouts does not matter, as long as you can identify entities with a given Viewport (I say this because in your original post you mention "5 Layouts or more" and also emphasized in next reply with "large drawing with 10 or more layouts).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, basically, for any given paperspace viewport, you need to find its corner coordinates (be it rectangle or non-rectangle) in PaperSpace, and then translate them into ModelSpace coordinate, thus you'll have points for a window/closed polygon in ModelSpace. Now, you can find which entities are enclosed inside it. YOu can use Editor.SelectWindow[CrossingPolygon]() to select entities (you need to switch AutoCAD to ModelSpace), or you can write code to test if an entity is inside the window/plygon.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I do have a post quite a few years ago on how to select Entities in ModelSpace through a paperspace viewport:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://drive-cad-with-code.blogspot.com/2014/03/selecting-entities-in-modelspace.html" target="_blank"&gt;https://drive-cad-with-code.blogspot.com/2014/03/selecting-entities-in-modelspace.html&lt;/A&gt;&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>Wed, 17 Oct 2018 19:01:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/vb-net-to-select-object-in-paperspace-and-get-layout-name/m-p/8341495#M24558</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2018-10-17T19:01:46Z</dc:date>
    </item>
  </channel>
</rss>

