Quantcast
Channel: All Revit API Forum posts
Viewing all articles
Browse latest Browse all 67020

Re: Revit IExportContext failed to export linked models?

$
0
0

Thanks very much! Through comparison with the CustomExporterXML example, I am finally able to locate the error: 

public RenderNodeAction OnElementBegin(ElementId elementId) { var elem = exportDocument.GetElement(elementId); if (elem == null) { return RenderNodeAction.Skip; } // ... }

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.

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:

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; }

I hope this would help if anyone else bumps into the same problem...


Viewing all articles
Browse latest Browse all 67020

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>