<?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: Revit IExportContext failed to export linked models? in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/revit-iexportcontext-failed-to-export-linked-models/m-p/9710340#M32305</link>
    <description>&lt;P&gt;Thanks very much! Through comparison with the CustomExporterXML example, I am finally able to locate the error:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;public RenderNodeAction OnElementBegin(ElementId elementId)
{
    var elem = exportDocument.GetElement(elementId);
    if (elem == null)
    {
        return RenderNodeAction.Skip;
    }
    // ...
}&lt;/LI-CODE&gt;&lt;P&gt;The problem is that, when the exportDocument has links within itself, the element being exported may well be contained in a linked document and thus GetElement returns null, causing a skip. This is why I find that OnPolymesh is not invoked at all.&lt;/P&gt;&lt;P&gt;The correct way to do this, as far as I know, is to use Revit.ApplicationServices.Application.Documents property, which retrieves all documents in Revit (including linked ones). So GetElement method should be called on each of those documents:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;public static Element GetElementLinked(Revit.ApplicationServices.Application app, ElementId elemId)
{
    foreach (var doc in app.Documents)
    {
        var elem = doc.GetElement(elemId);
        if (elem != null) return elem;
    }
    return null;
}&lt;/LI-CODE&gt;&lt;P&gt;I hope this would help if anyone else bumps into the same problem...&lt;/P&gt;</description>
    <pubDate>Tue, 25 Aug 2020 11:48:33 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2020-08-25T11:48:33Z</dc:date>
    <item>
      <title>Revit IExportContext failed to export linked models?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/revit-iexportcontext-failed-to-export-linked-models/m-p/9709439#M32303</link>
      <description>&lt;P&gt;Hi, I'm developling an export plugin for Revit. The problem that I encountered is, in the {3D} view of a project, only elements of "RVT Links" are present, which are linked from other .rvt files. However the IExporterContext gives actually no polymesh, and the method OnPolymesh is not invoked at all. Is there a way to export these linked models?&lt;/P&gt;</description>
      <pubDate>Mon, 24 Aug 2020 23:44:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/revit-iexportcontext-failed-to-export-linked-models/m-p/9709439#M32303</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-08-24T23:44:35Z</dc:date>
    </item>
    <item>
      <title>Re: Revit IExportContext failed to export linked models?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/revit-iexportcontext-failed-to-export-linked-models/m-p/9709847#M32304</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;This below link contains the CustomExporter sample code.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://thebuildingcoder.typepad.com/blog/2013/07/graphics-pipeline-custom-exporter.html" target="_blank"&gt;https://thebuildingcoder.typepad.com/blog/2013/07/graphics-pipeline-custom-exporter.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For Revit 2021, You have to make some little changes to the CustomExporter code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I used CustomExporterXml code present in the above link to export the linked models and it worked fine for me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope the code works fine for polymesh too.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Aug 2020 06:29:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/revit-iexportcontext-failed-to-export-linked-models/m-p/9709847#M32304</guid>
      <dc:creator>naveen.kumar.t</dc:creator>
      <dc:date>2020-08-25T06:29:09Z</dc:date>
    </item>
    <item>
      <title>Re: Revit IExportContext failed to export linked models?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/revit-iexportcontext-failed-to-export-linked-models/m-p/9710340#M32305</link>
      <description>&lt;P&gt;Thanks very much! Through comparison with the CustomExporterXML example, I am finally able to locate the error:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;public RenderNodeAction OnElementBegin(ElementId elementId)
{
    var elem = exportDocument.GetElement(elementId);
    if (elem == null)
    {
        return RenderNodeAction.Skip;
    }
    // ...
}&lt;/LI-CODE&gt;&lt;P&gt;The problem is that, when the exportDocument has links within itself, the element being exported may well be contained in a linked document and thus GetElement returns null, causing a skip. This is why I find that OnPolymesh is not invoked at all.&lt;/P&gt;&lt;P&gt;The correct way to do this, as far as I know, is to use Revit.ApplicationServices.Application.Documents property, which retrieves all documents in Revit (including linked ones). So GetElement method should be called on each of those documents:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;public static Element GetElementLinked(Revit.ApplicationServices.Application app, ElementId elemId)
{
    foreach (var doc in app.Documents)
    {
        var elem = doc.GetElement(elemId);
        if (elem != null) return elem;
    }
    return null;
}&lt;/LI-CODE&gt;&lt;P&gt;I hope this would help if anyone else bumps into the same problem...&lt;/P&gt;</description>
      <pubDate>Tue, 25 Aug 2020 11:48:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/revit-iexportcontext-failed-to-export-linked-models/m-p/9710340#M32305</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-08-25T11:48:33Z</dc:date>
    </item>
    <item>
      <title>Re: Revit IExportContext failed to export linked models?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/revit-iexportcontext-failed-to-export-linked-models/m-p/9710373#M32309</link>
      <description>&lt;P&gt;I can't post a reply using that account, so it goes here...&lt;/P&gt;</description>
      <pubDate>Tue, 25 Aug 2020 12:03:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/revit-iexportcontext-failed-to-export-linked-models/m-p/9710373#M32309</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-08-25T12:03:11Z</dc:date>
    </item>
    <item>
      <title>Re: Revit IExportContext failed to export linked models?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/revit-iexportcontext-failed-to-export-linked-models/m-p/9710383#M32310</link>
      <description>&lt;P&gt;Thanks very much! I am finally able to locate the error by making comparison with the example you provide. The problem is caused by this (there may be typo in the code):&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;RenderNodeAction OnElementBegin(ElementId elementId) {
  var elem = exportDocument.GetElement(elementId);
  if (elem == null) return RenderNodeAction.Skip;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;So with linked models, the elementId may well refer to an element in a document linked to exportDocument, and when that is the case, exportDocument.GetElement will return null, causing these valid elements with geometry to be skipped.&lt;/P&gt;&lt;P&gt;The correct version should be (again there may be typo):&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;public static Element GetElementLink(Revit.ApplicationService.Application app, ElementId elemId) 
{
  foreach (Document doc in app.Documents) {
    var elem = doc.GetElement(elemId);
    if (elem != null) return elem;
  }
  return null;
}&lt;/LI-CODE&gt;&lt;P&gt;That is, to use Autodesk.Revit.ApplicationService.Application.Documents property to get all linked documents, and get the element there. Hope this would help!&lt;/P&gt;</description>
      <pubDate>Tue, 25 Aug 2020 12:08:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/revit-iexportcontext-failed-to-export-linked-models/m-p/9710383#M32310</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-08-25T12:08:48Z</dc:date>
    </item>
  </channel>
</rss>

