//--------------------------------------------------------------------------------------------------

        bool DoExport(string filename, IDrawingExporter exporter)
        {
            try
            {
                var projection   = new Ax3(_Viewport.EyePoint, _Viewport.GetViewDirection().Reversed(), _Viewport.GetRightDirection());
                var hlrEdgeTypes = HlrEdgeTypes.None;

                if (Settings.VisibleOutline)
                {
                    hlrEdgeTypes |= HlrEdgeTypes.VisibleSharp;
                    hlrEdgeTypes |= HlrEdgeTypes.VisibleOutline;
                }
                if (Settings.VisibleSmooth)
                {
                    hlrEdgeTypes |= HlrEdgeTypes.VisibleSmooth;
                }
                if (Settings.VisibleSewn)
                {
                    hlrEdgeTypes |= HlrEdgeTypes.VisibleSewn;
                }
                if (Settings.HiddenOutline)
                {
                    hlrEdgeTypes |= HlrEdgeTypes.HiddenSharp;
                    hlrEdgeTypes |= HlrEdgeTypes.HiddenOutline;
                }
                if (Settings.HiddenSmooth)
                {
                    hlrEdgeTypes |= HlrEdgeTypes.HiddenSmooth;
                }
                if (Settings.HiddenSewn)
                {
                    hlrEdgeTypes |= HlrEdgeTypes.HiddenSewn;
                }

                var source         = new TopoDSBrepSource(InteractiveContext.Current.WorkspaceController.VisualObjects.GetVisibleBReps().ToArray());
                var hlrBrepDrawing = HlrDrawing.Create(projection, hlrEdgeTypes, source);
                hlrBrepDrawing.UseTriangulation = Settings.UseTriangulation;

                var drawing = new Drawing();
                drawing.Add(hlrBrepDrawing);

                return(exporter.DoExport(filename, drawing));
            }
            catch (Exception e)
            {
                Messages.Exception("Exception while exporting line drawing from viewport.", e);
                return(false);
            }
        }
        //--------------------------------------------------------------------------------------------------

        #region Helper

        MemoryStream RunExporter(bool useTriangulation, Ax3 projection, DxfVersion version, DxfFlags flags, params Body[] bodies)
        {
            var hlrEdgeTypes = HlrEdgeTypes.VisibleSharp | HlrEdgeTypes.VisibleOutline | HlrEdgeTypes.VisibleSmooth
                               | HlrEdgeTypes.HiddenSharp | HlrEdgeTypes.HiddenOutline;

            IBrepSource[] sources        = bodies.Select(body => (IBrepSource) new BodyBrepSource(body)).ToArray();
            var           hlrBrepDrawing = HlrDrawing.Create(projection, hlrEdgeTypes, sources);

            hlrBrepDrawing.UseTriangulation = useTriangulation;

            var drawing = new Drawing();

            drawing.Add(hlrBrepDrawing);

            return(DxfDrawingExporter.Export(drawing, version, flags));
        }