Example #1
0
        /// <summary>
        /// Collect the parameters and export
        /// </summary>
        /// <returns></returns>
        public override bool Export()
        {
            Transaction transaction = new Transaction(m_activeDoc, "Export_To_DWF");

            transaction.Start();
            bool exported = false;

            base.Export();

            //parameter : ViewSet views
            ViewSet views = new ViewSet();

            if (m_currentViewOnly)
            {
                views.Insert(m_activeDoc.ActiveView);
            }
            else
            {
                views = m_selectViewsData.SelectedViews;
            }

            // Export DWFx
            if (m_exportFormat == ExportFormat.DWFx)
            {
                DWFXExportOptions options = new DWFXExportOptions();
                options.ExportObjectData = m_exportObjectData;
                options.ExportingAreas   = m_exportAreas;
                options.MergedViews      = m_exportMergeFiles;
                options.ImageFormat      = m_dwfImageFormat;
                options.ImageQuality     = m_dwfImageQuality;
                exported = m_activeDoc.Export(m_exportFolder, m_exportFileName, views, options);
            }
            // Export DWF
            else
            {
                DWFExportOptions options = new DWFExportOptions();
                options.ExportObjectData = m_exportObjectData;
                options.ExportingAreas   = m_exportAreas;
                options.MergedViews      = m_exportMergeFiles;
                options.ImageFormat      = m_dwfImageFormat;
                options.ImageQuality     = m_dwfImageQuality;
                exported = m_activeDoc.Export(m_exportFolder, m_exportFileName, views, options);
            }
            transaction.Commit();

            return(exported);
        }
        private void Stream(ArrayList data, DWFXExportOptions dwf2dExpOptions)
        {
            data.Add(new Snoop.Data.ClassSeparator(typeof(DWFExportOptions)));

            data.Add(new Snoop.Data.String("Image format", dwf2dExpOptions.ImageFormat.ToString()));
            data.Add(new Snoop.Data.String("Image quality", dwf2dExpOptions.ImageQuality.ToString()));
            data.Add(new Snoop.Data.String("Paper format", dwf2dExpOptions.PaperFormat.ToString()));
            data.Add(new Snoop.Data.Bool("Portrait layout", dwf2dExpOptions.PortraitLayout));

            DWFXExportOptions dwfx2dExpOptions = dwf2dExpOptions as DWFXExportOptions;

            if (dwfx2dExpOptions != null)
            {
                Stream(data, dwfx2dExpOptions);
                return;
            }
        }
Example #3
0
        public Result RunRemotely(Document document)
        {
            FilteredElementCollector collector = new FilteredElementCollector(document);

            collector.OfClass(typeof(ViewSheet));

            ViewSet set = new ViewSet();

            foreach (View view in collector)
            {
                set.Insert(view);
            }
            DWFXExportOptions options = new DWFXExportOptions();

            options.MergedViews      = true;
            options.ImageQuality     = DWFImageQuality.High;
            options.ExportObjectData = true;

            document.Export(@"C:\RRBTest\", "TestExport.dwfx", set, options);
            return(Result.Succeeded);
        }
        /// <summary>
        /// Collect the parameters and export
        /// </summary>
        /// <returns></returns>
        public override bool Export()
        {
            Transaction transaction = new Transaction(m_activeDoc, "Export_To_DWF");
            transaction.Start();
            bool exported = false;
            base.Export();

            //parameter : ViewSet views
            ViewSet views = new ViewSet();
            if (m_currentViewOnly)
            {
                views.Insert(m_activeDoc.ActiveView);
            }
            else
            {
                views = m_selectViewsData.SelectedViews;
            }

            // Export DWFx
            if (m_exportFormat == ExportFormat.DWFx)
            {
                DWFXExportOptions options = new DWFXExportOptions();
                options.ExportObjectData = m_exportObjectData;
                options.ExportingAreas = m_exportAreas;
                options.MergedViews = m_exportMergeFiles;
                options.ImageFormat = m_dwfImageFormat;
                options.ImageQuality = m_dwfImageQuality;
                exported = m_activeDoc.Export(m_exportFolder, m_exportFileName, views, options);
            }
            // Export DWF
            else
            {
                DWFExportOptions options = new DWFExportOptions();
                options.ExportObjectData = m_exportObjectData;
                options.ExportingAreas = m_exportAreas;
                options.MergedViews = m_exportMergeFiles;
                options.ImageFormat = m_dwfImageFormat;
                options.ImageQuality = m_dwfImageQuality;
                exported = m_activeDoc.Export(m_exportFolder, m_exportFileName, views, options);
            }
            transaction.Commit();

            return exported;
        }
Example #5
0
        Result IExternalCommand.Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIApplication  uiapp       = commandData.Application;
            UIDocument     uidoc       = uiapp.ActiveUIDocument;
            Application    app         = uiapp.Application;
            Document       doc         = uidoc.Document;
            List <Element> titleBlocks = new FilteredElementCollector(doc)
                                         .OfCategory(BuiltInCategory.OST_TitleBlocks)
                                         .WhereElementIsNotElementType()
                                         .ToElements()
                                         .ToList();

            List <ElementId> elt  = uidoc.Selection.GetElementIds().ToList();
            List <Element>   beta = new List <Element>();

            foreach (ElementId i in elt)
            {
                beta.Add(doc.GetElement(i));
            }
            ViewSheet a;

            a = doc.GetElement(elt.First()) as ViewSheet;
            ViewSet b = new ViewSet();
            List <List <Element> > elementOnSheet = new List <List <Element> >();


            for (int i = 0; i < elt.Count(); i++)
            {
                List <Element> sheetEl = new List <Element>();
                foreach (Element e in new FilteredElementCollector(doc).OwnedByView(elt[i]))
                {
                    sheetEl.Add(e);
                }
                elementOnSheet.Add(sheetEl);
            }
            List <Element> titleOnSheet = new List <Element>();


            for (int i = 0; i < elt.Count(); i++)
            {
                titleOnSheet.Add(null);
                foreach (Element e in elementOnSheet[i])
                {
                    foreach (Element tb in titleBlocks)
                    {
                        if (e.Id == tb.Id)
                        {
                            titleOnSheet[i] = tb;
                        }
                    }
                }
            }

            List <int> formatA = new List <int>();
            List <int> kratn   = new List <int>();
            List <int> knign   = new List <int>();

            for (int i = 0; i < titleOnSheet.Count(); i++)
            {
                try
                {
                    formatA.Add(titleOnSheet[i].LookupParameter("Формат А").AsInteger());
                    kratn.Add(titleOnSheet[i].LookupParameter("Кратность").AsInteger());
                    knign.Add(titleOnSheet[i].LookupParameter("Книжная ориентация").AsInteger());
                }
                catch (Exception)
                {
                }
            }
            string namePrefix = "Export";
            //string nameOfExportDWFX = "AutoExport " + DateTime.Now.Hour.ToString() + "_" + DateTime.Now.Minute.ToString() + "_" + DateTime.Now.Second.ToString();
            List <string>    viewName = new List <string>();
            List <ViewSheet> listNum  = new List <ViewSheet>();

            foreach (ElementId i in elt)
            {
                b.Insert(doc.GetElement(i) as ViewSheet);
                listNum.Add(doc.GetElement(i) as ViewSheet);
            }

            PrintManager PrintMan = doc.PrintManager;
            //PaperSize myPaperSize;



            DWFXExportOptions options = new DWFXExportOptions();

            options.MergedViews = true;
            options.PaperFormat = ExportPaperFormat.ISO_A3;


            string dir = doc.PathName.Substring(0, doc.PathName.Length - doc.Title.Length - 4);

            string newPath = Path.GetTempPath();

            //string newPath = vmp.Substring(0, arr+1)+"PDF";
            for (int i = 0; i < listNum.Count(); i++)
            {
                viewName.Add(newPath + listNum[i].SheetNumber + listNum[i].Name + ".dwfx");
            }
            string fileName = newPath + namePrefix + ".dwfx";

            System.IO.DirectoryInfo printDir = System.IO.Directory.CreateDirectory(newPath);

            using (Transaction tr = new Transaction(doc, "MyExort"))

            {
                tr.Start();
                //PrintMan.PrintSetup.CurrentPrintSetting.PrintParameters.PaperSize = setPaperSize(doc);
                PrintMan.PrintSetup.CurrentPrintSetting.PrintParameters.PaperPlacement = PaperPlacementType.Center;
                //PrintMan.PrintSetup.CurrentPrintSetting.PrintParameters.MarginType = MarginType.;
                PrintMan.PrintSetup.CurrentPrintSetting.PrintParameters.ZoomType = ZoomType.Zoom;
                PrintMan.PrintSetup.CurrentPrintSetting.PrintParameters.Zoom     = 100;
                //PrintMan.PrintSetup.CurrentPrintSetting.PrintParameters.UserDefinedMarginX=titleOnSheet[0].
                //PrintMan.PrintSetup.Save();


                /*
                 *              foreach (ViewSheet i in listNum)
                 *              {
                 *                      ViewSet vSet = new ViewSet();
                 *                      vSet.Insert(i);
                 *
                 *                      doc.Export(newPath, i.SheetNumber + i.Name,vSet, options);
                 * }
                 */
                doc.Export(newPath.Substring(0, newPath.Length - 1), namePrefix, b, options);
                tr.Commit();
            }
            try
            {
                using (FileStream fs = File.Create(newPath + "printing.bpj"))
                {
                    //byte[] info = new UTF8Encoding(true).GetBytes(batchPrint(viewName, formatA, kratn, knign));
                    byte[] info = new UTF8Encoding(true).GetBytes(batchPrint(fileName));
                    fs.Write(info, 0, info.Length);
                }
            }
            catch (Exception)
            {
            }
            Environment.SetEnvironmentVariable("MYAPP", newPath.Substring(0, newPath.Length - 1), EnvironmentVariableTarget.User);
            Process.Start("DesignReview.exe", newPath + "printing.bpj");



            return(Result.Succeeded);
        }
      private void Stream(ArrayList data, DWFXExportOptions dwf2dExpOptions)
      {
         data.Add(new Snoop.Data.ClassSeparator(typeof(DWFExportOptions)));

         data.Add(new Snoop.Data.String("Image format", dwf2dExpOptions.ImageFormat.ToString()));
         data.Add(new Snoop.Data.String("Image quality", dwf2dExpOptions.ImageQuality.ToString()));
         data.Add(new Snoop.Data.String("Paper format", dwf2dExpOptions.PaperFormat.ToString()));
         data.Add(new Snoop.Data.Bool("Portrait layout", dwf2dExpOptions.PortraitLayout));

         DWFXExportOptions dwfx2dExpOptions = dwf2dExpOptions as DWFXExportOptions;
         if (dwfx2dExpOptions != null)
         {
            Stream(data, dwfx2dExpOptions);
            return;
         }
      }
Example #7
0
        public override bool Export()
        {
            Transaction transaction = new Transaction(this.m_activeDoc, "Export_To_DWF");

            transaction.Start();
            bool result = false;

            base.Export();
            ViewSet viewSet  = new ViewSet();
            ViewSet viewSet2 = new ViewSet();

            if (this.m_currentViewOnly)
            {
                viewSet.Insert(this.m_activeDoc.ActiveView);
            }
            else
            {
                viewSet = this.m_selectViewsData.SelectedViews;
            }
            foreach (View view in viewSet)
            {
                ViewSheet viewSheet = (ViewSheet)view;
                viewSet2.Insert(viewSheet);
                Parameter parameter = viewSheet.get_Parameter("SEQUENCE#");
                if (this.m_exportFormat == ExportFormat.DWFx)
                {
                    this.m_exportFileName = string.Concat(new string[]
                    {
                        viewSheet.SheetNumber,
                        " - ",
                        viewSheet.Name,
                        " - ",
                        this.StoreNumber,
                        ".dwfx"
                    });
                    DWFXExportOptions dWFXExportOptions = new DWFXExportOptions();
                    dWFXExportOptions.ExportObjectData = this.m_exportObjectData;
                    dWFXExportOptions.ExportingAreas   = this.m_exportAreas;
                    dWFXExportOptions.MergedViews      = this.m_exportMergeFiles;
                    dWFXExportOptions.ImageFormat      = this.m_dwfImageFormat;
                    dWFXExportOptions.ImageQuality     = this.m_dwfImageQuality;
                    result = this.m_activeDoc.Export(this.m_exportFolder, this.m_exportFileName, viewSet2, dWFXExportOptions);
                }
                else
                {
                    this.m_exportFileName = string.Concat(new string[]
                    {
                        parameter.AsString(),
                        " - ",
                        viewSheet.SheetNumber,
                        " ",
                        viewSheet.Name,
                        " - ",
                        this.StoreNumber,
                        ".dwf"
                    });
                    DWFExportOptions dWFExportOptions = new DWFExportOptions();
                    dWFExportOptions.ExportObjectData = this.m_exportObjectData;
                    dWFExportOptions.ExportingAreas   = this.m_exportAreas;
                    dWFExportOptions.MergedViews      = this.m_exportMergeFiles;
                    dWFExportOptions.ImageFormat      = this.m_dwfImageFormat;
                    dWFExportOptions.ImageQuality     = this.m_dwfImageQuality;
                    result = this.m_activeDoc.Export(this.m_exportFolder, this.m_exportFileName, viewSet2, dWFExportOptions);
                }
                viewSet2.Erase(view);
            }
            transaction.Commit();
            return(result);
        }