<?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 dwg import option - SetLayerSelection doesn't work in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/dwg-import-option-setlayerselection-doesn-t-work/m-p/7999349#M50125</link>
    <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;I am trying to set the dwg's layers to import into Revit by using 'SetLayerSelection'.&lt;/P&gt;&lt;P&gt;But it doesn't work with the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// DWG Import Options&lt;BR /&gt;DWGImportOptions dwgImportOption = new DWGImportOptions();&lt;BR /&gt;ICollection&amp;lt;string&amp;gt; layerSelection = new List&amp;lt;string&amp;gt;() { "layername" };&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;dwgImportOption.ColorMode = Autodesk.Revit.DB.ImportColorMode.BlackAndWhite;&lt;BR /&gt;dwgImportOption.CustomScale = 0.0;&lt;BR /&gt;dwgImportOption.Unit = Autodesk.Revit.DB.ImportUnit.Millimeter;&lt;BR /&gt;dwgImportOption.OrientToView = true;&lt;BR /&gt;dwgImportOption.Placement = Autodesk.Revit.DB.ImportPlacement.Origin;&lt;BR /&gt;dwgImportOption.ThisViewOnly = false;&lt;BR /&gt;dwgImportOption.SetLayerSelection( layerSelection );&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would highly appreciate if you could support me.&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
    <pubDate>Mon, 14 May 2018 07:37:03 GMT</pubDate>
    <dc:creator>Eri.Myalitsin</dc:creator>
    <dc:date>2018-05-14T07:37:03Z</dc:date>
    <item>
      <title>dwg import option - SetLayerSelection doesn't work</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/dwg-import-option-setlayerselection-doesn-t-work/m-p/7999349#M50125</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;I am trying to set the dwg's layers to import into Revit by using 'SetLayerSelection'.&lt;/P&gt;&lt;P&gt;But it doesn't work with the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// DWG Import Options&lt;BR /&gt;DWGImportOptions dwgImportOption = new DWGImportOptions();&lt;BR /&gt;ICollection&amp;lt;string&amp;gt; layerSelection = new List&amp;lt;string&amp;gt;() { "layername" };&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;dwgImportOption.ColorMode = Autodesk.Revit.DB.ImportColorMode.BlackAndWhite;&lt;BR /&gt;dwgImportOption.CustomScale = 0.0;&lt;BR /&gt;dwgImportOption.Unit = Autodesk.Revit.DB.ImportUnit.Millimeter;&lt;BR /&gt;dwgImportOption.OrientToView = true;&lt;BR /&gt;dwgImportOption.Placement = Autodesk.Revit.DB.ImportPlacement.Origin;&lt;BR /&gt;dwgImportOption.ThisViewOnly = false;&lt;BR /&gt;dwgImportOption.SetLayerSelection( layerSelection );&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would highly appreciate if you could support me.&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Mon, 14 May 2018 07:37:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/dwg-import-option-setlayerselection-doesn-t-work/m-p/7999349#M50125</guid>
      <dc:creator>Eri.Myalitsin</dc:creator>
      <dc:date>2018-05-14T07:37:03Z</dc:date>
    </item>
    <item>
      <title>Re: dwg import option - SetLayerSelection doesn't work</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/dwg-import-option-setlayerselection-doesn-t-work/m-p/8019719#M50126</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There was the same problem as mentioned on this article:&lt;/P&gt;&lt;P&gt;&lt;A href="http://thebuildingcoder.typepad.com/blog/2015/12/au-ioc-banks-and-not-to-delete-while-iterating.html" target="_blank"&gt;http://thebuildingcoder.typepad.com/blog/2015/12/au-ioc-banks-and-not-to-delete-while-iterating.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="error.jpg" style="width: 387px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/503603i2823912BA928DE8B/image-size/large?v=v2&amp;amp;px=999" role="button" title="error.jpg" alt="error.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following code made the error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;// View in current document
FilteredElementCollector coll = new FilteredElementCollector(doc);
coll.OfClass(typeof(View));

foreach(Element e in coll)
{     			
    if (e.Name == "Z0")
    {
        View view = e as View;
        imported = doc.Import(m_fileName, dwgImportOption, view, out elementId);
    }
}&lt;/PRE&gt;&lt;P&gt;Solution was like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;// View in current document
FilteredElementCollector coll = new FilteredElementCollector(doc);
var viewIds = coll.OfClass(typeof(View)).ToElementIds();

foreach(var id in viewIds)
{
    var view = doc.GetElement(id) as View;
    if (view.Name == "Z0")
    {
        imported = doc.Import(m_fileName, dwgImportOption, view, out elementId);
    }
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 May 2018 02:08:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/dwg-import-option-setlayerselection-doesn-t-work/m-p/8019719#M50126</guid>
      <dc:creator>Eri.Myalitsin</dc:creator>
      <dc:date>2018-05-23T02:08:47Z</dc:date>
    </item>
  </channel>
</rss>

