Exemplo n.º 1
0
        public static void WrapUpOperations(Timer tm)
        {
            try
            {
                TotalDWGs = 0;
                MaxDWGs   = 0;
                MaxDXFs   = 0;
                tm.Stop();
                myTimer.Stop();
                myTimer.Enabled = false;
                myTimer.Tick   -= TimerEventProcessor;
                Application.SetSystemVariable("FILEDIA", 1);
                COMS.MessengerManager.AddLog("Stopped Watcher!");

                Application.SetSystemVariable("PROXYNOTICE", 1);
                Application.SetSystemVariable("PROXYGRAPHICS", 1);
                Application.SetSystemVariable("FILEDIA", 1);

                COMS.MessengerManager.AddLog("Set Exit Variables!");

                OpenandCloseDwgs.CloseDocuments();
            }
            catch (Exception ex)
            {
                COMS.MessengerManager.LogException(ex);
            }
        }
Exemplo n.º 2
0
        public static ObjectId GetArrowObjectId(string arrow, string newArrName)
        {
            var Return = ObjectId.Null;

            string oldArrName = Application.GetSystemVariable(arrow).ToString();

            Application.SetSystemVariable(arrow, newArrName);

            if (oldArrName.Length != 0)
            {
                Application.SetSystemVariable(arrow, oldArrName);
            }

            using (Transaction t = AC.DB.TransactionManager.StartTransaction())
            {
                var BT = t.GetObject(AC.DB.BlockTableId, OpenMode.ForWrite) as BlockTable;

                //ObjectId d = new ObjectId(new IntPtr(165522592));
                //var A = t.GetObject(d, OpenMode.ForRead) as BlockTableRecord;
                //MessageBox.Show(A.Name);

                Return = BT[newArrName];
                t.Commit();
            }

            return(Return);
        }
Exemplo n.º 3
0
        public static void ResetVars()
        {
            try
            {
                using (DatabaseCommands cmd = new DatabaseCommands())
                {
                    TotalDWGs = 0;
                    MaxDWGs   = 0;
                    MaxDXFs   = 0;
                    myTimer.Stop();
                    myTimer.Enabled = false;
                    myTimer.Tick   -= TimerEventProcessor;
                    COMS.MessengerManager.AddLog("Stopped Watcher!");

                    if (Active.Document != null)
                    {
                        Application.SetSystemVariable("FILEDIA", 1);
                        Application.SetSystemVariable("PROXYNOTICE", 1);
                        Application.SetSystemVariable("PROXYGRAPHICS", 1);
                        Application.SetSystemVariable("FILEDIA", 1);
                    }
                }
            }
            catch (Exception ex)
            {
                COMS.MessengerManager.LogException(ex);
            }
        }
Exemplo n.º 4
0
        private static bool SetMapScale(Document document)
        {
            // http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%202010%20User%20Documentation/index.html?url=WS1a9193826455f5ffa23ce210c4a30acaf-4fff.htm,topicNumber=d0e346024
            var dynmode = AcadApplication.GetSystemVariable("DYNMODE");

            AcadApplication.SetSystemVariable("DYNMODE", 2); // 2 means "Dimensional input on"

            int    defaultScale = 500;
            string strPrompt    = String.Format("\n设置绘图比例尺为1:<{0}>", defaultScale);
            var    pScaleOpts   = new PromptIntegerOptions(strPrompt)
            {
                AllowNone = true,
                AllowZero = false
            };

            var pScaleRes = document.Editor.GetInteger(pScaleOpts);

            AcadApplication.SetSystemVariable("DYNMODE", dynmode);
            if (pScaleRes.Status == PromptStatus.OK || pScaleRes.Status == PromptStatus.None)
            {
                double scale = defaultScale;
                if (pScaleRes.Status == PromptStatus.OK)
                {
                    scale = pScaleRes.Value;
                }
                MapScaleUtils.SetApplicationMapScale(scale);

                return(true);
            }
            return(false);
        }
Exemplo n.º 5
0
        private void LoadMyCui(string cuiFile)
        {
            Document doc        = Application.DocumentManager.MdiActiveDocument;
            object   oldCmdEcho = Application.GetSystemVariable("CMDECHO");

            Application.SetSystemVariable("CMDECHO", 0);
            doc.SendStringToExecute("(command \"_.CUILOAD\" \"" + cuiFile + "\")(setvar \"CMDECHO\" " + oldCmdEcho + ")(princ) ", false, false, false);
        }
Exemplo n.º 6
0
        MakePointEnt(Point3d pt, int colorIndex, Transaction tr, Database db)
        {
            short mode = (short)AcadApp.GetSystemVariable("pdmode");

            if (mode == 0)
            {
                AcadApp.SetSystemVariable("pdmode", 99);
            }

            using (DBPoint dbPt = new DBPoint(pt)) {
                dbPt.ColorIndex = colorIndex;
                MgdDbg.Utils.SymTbl.AddToCurrentSpace(dbPt, db, tr);
            }
        }
Exemplo n.º 7
0
        MakePointEnt(Point3d pt, int colorIndex, Transaction tr)
        {
            m_db = Utils.Db.GetCurDwg();

            short mode = (short)AcadApp.GetSystemVariable("pdmode");

            if (mode == 0)
            {
                AcadApp.SetSystemVariable("pdmode", 99);
            }

            using (DBPoint dbPt = new DBPoint(Utils.Db.WcsToUcs(pt))) {
                dbPt.ColorIndex = colorIndex;
                Utils.Db.TransformToWcs(dbPt, m_db);
                Utils.SymTbl.AddToCurrentSpace(dbPt, m_db, tr);
            }
        }
Exemplo n.º 8
0
        public void LoadMyCui()
        {
            var path       = ElectronTransferBll.Register.GetItemValue("CustomAutoCAD", "LOADER", false);
            var folderPath = path.Substring(0, path.LastIndexOf('\\'));
            var cuiPath    = Path.Combine(folderPath, "zhsc.cuix");

            var doc        = Application.DocumentManager.MdiActiveDocument;
            var oldCmdEcho = Application.GetSystemVariable("CMDECHO");
            var oldFileDia = Application.GetSystemVariable("FILEDIA");

            Application.SetSystemVariable("CMDECHO", 0);
            Application.SetSystemVariable("FILEDIA", 0);

            var mainCuiFile = (string)Application.GetSystemVariable("MENUNAME") + ".cuix";
            var str         = Path.GetFileNameWithoutExtension(mainCuiFile);

            if (str.ToLower() == "acad")
            {
                doc.SendStringToExecute(
                    "_.cuiunload "
                    + "acad"
                    + " ",
                    false, false, false);

                doc.SendStringToExecute(
                    "_.cuiload "
                    + cuiPath + " ",
                    false, false, false);
            }


            doc.SendStringToExecute(
                "(setvar \"FILEDIA\" "
                + oldFileDia
                + ")(princ) ",
                false, false, false
                );

            doc.SendStringToExecute(
                "(setvar \"CMDECHO\" "
                + oldCmdEcho
                + ")(princ) ",
                false, false, false
                );
        }
        public void Initialize()
        {
            try
            {
                CurrentDirectory = System.IO.Directory.GetCurrentDirectory();
                //bool verify = Verify();
                //if (!verify)
                //{
                //    System.Windows.MessageBox.Show("您的软件使用权已经过期.\n 请联系软件提供商.", "Error");
                //    return;
                //}

                Utility.ClearApplicationConfig();
                DataConfig.init_config_path();
                DataConfig.loadCustomConfig();
                loadConfigData();
                //初始化常量
                Constants.InitilizeConstant();
                //显示各控件
                showSolution();
                //关闭选项卡
                //closeRibbon();
                showTool();
                showAttrsEditor();
                //最后进行文件恢复
                restore();
                //测试截图
                Application.SetSystemVariable("NAVVCUBEDISPLAY", 0);
                Application.SetSystemVariable("NAVBARDISPLAY", 0);
                Object obj = Application.GetSystemVariable("DBLCLKEDIT");
                Application.SetSystemVariable("DBLCLKEDIT", 0);
            }
            catch (System.Exception e)
            {
                Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage(e.Message);
            }
        }
Exemplo n.º 10
0
 public PlotMultiPDF()
 {
     _bgp = (short)AcAp.GetSystemVariable("BACKGROUNDPLOT");
     AcAp.SetSystemVariable("BACKGROUNDPLOT", 0);
     Application.Publisher.CancelledOrFailedPublishing += Publisher_CancelledOrFailedPublishing;
 }
Exemplo n.º 11
0
        private static void TimerEventProcessor(Object sender,
                                                EventArgs myEventArgs)
        {
            try
            {
                PGA.DrawingManager.Commands.ForceCloseAllButActiveDocuments();


                using (DatabaseCommands commands = new DatabaseCommands())
                {
                    if (TotalDWGs == 0)
                    {
                        TotalDWGs = commands.DWGCountGenCadStk();
                    }
                    myTimer.Enabled = false;
                    if (MaxDWGs++ < TotalDWGs)
                    {
                        myTimer.Interval = 15000;

                        commands.InsertNotifications(String.Format("{0},{1},{2}", 2, MaxDWGs, TotalDWGs));
                        COMS.MessengerManager.AddLog("Starting Drawing Processing!");

                        var name = commands.GUgetNextDwg();

                        PGA.SV30MOffset.Program.InvokeProgressBar(name, MaxDWGs, TotalDWGs);

                        if (!String.IsNullOrEmpty(name))
                        {
                            commands.GUMarkCompleted(name);

                            Application.SetSystemVariable("FILEDIA", 0);
                            Application.SetSystemVariable("NOMUTT", 0);
                            Application.SetSystemVariable("CMDECHO", 0);

                            Program.OpenAutoCAD(name);
                            return;
                        }
                        else
                        {
                            COMS.MessengerManager.ShowMessageAndLog("No Files to Process!");
                            return;
                        }
                    }
                    else
                    {
                        if (MaxDWGs > 3 + TotalDWGs)
                        {
                            PGA.SV30MOffset.Program.SaveDwg();
                            PGA.DrawingManager.Commands.CloseDocuments();
                            ResetVars();
                        }
                    }
                    myTimer.Enabled = true;
                }
                COMS.MessengerManager.AddLog("Ending Timer Elasped...");
            }
            catch (ACADRT.Exception ex2)
            {
            }
            catch (Exception ex2)
            {
            }
        }
Exemplo n.º 12
0
        public void StartLayoutSplitterStart()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db  = HostApplicationServices.WorkingDatabase;
            Editor   ed  = Application.DocumentManager.MdiActiveDocument.Editor;


            Application.SetSystemVariable("TILEMODE", 1);
            Zoom(new Point3d(), new Point3d(), new Point3d(), 1.01075);
            Application.SetSystemVariable("SAVEFIDELITY", 0);
            Application.SetSystemVariable("REGENMODE", 0);
            ed.CurrentUserCoordinateSystem = Matrix3d.Identity;

            PromptStringOptions prefixOptions = new PromptStringOptions("Enter Prefix :");
            PromptResult        prefixResult  = ed.GetString(prefixOptions);

            if (prefixResult.Status != PromptStatus.OK)
            {
                return;
            }
            PromptStringOptions sufixOptions = new PromptStringOptions("\n\rEnter Sufix :");
            PromptResult        sufixResult  = ed.GetString(sufixOptions);

            if (sufixResult.Status != PromptStatus.OK)
            {
                return;
            }

            string selectedFolder = GetFolder();// Името на каталога в който ще се запсват файловете

            if (selectedFolder.Length < 2)
            {
                return;
            }
            selectedFolder  = selectedFolder.Replace(@"\", @"\\");
            selectedFolder += prefixResult.StringResult;

            Application.MainWindow.Visible = false;

            try
            {
                List <Pair <Pair <string, ObjectId>, ObjectIdCollection> > obcLIST = new
                                                                                     List <Pair <Pair <string, ObjectId>, ObjectIdCollection> >();
                #region прочита лейутите, селектира обектите от виевпортовете и ги запазва в масив
                using (doc.LockDocument())
                {
                    using (Transaction transaction = doc.TransactionManager.StartTransaction())
                    {
                        BlockTable blockTable = transaction.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;

                        // Open the Block table record Model space for write
                        BlockTableRecord blockTableRecord = transaction.GetObject(blockTable[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;


                        List <Pair <Pair <string, ObjectId>, List <Pair <Point3d, Point3d> > > > list = LayoutHelper.CreateArrayOfLayoutNamesAndViewportsDiagonals();
                        Application.SetSystemVariable("TILEMODE", 1);
                        foreach (Pair <Pair <string, ObjectId>, List <Pair <Point3d, Point3d> > > la in list)
                        {
                            ObjectIdCollection objcoll = new ObjectIdCollection();
                            foreach (Pair <Point3d, Point3d> diagonal in la.Second)
                            {
                                PromptSelectionResult prrr = ed.SelectCrossingWindow(diagonal.First, diagonal.Second);
                                if (prrr.Status == PromptStatus.OK)
                                {
                                    SelectionSet       acSSett     = prrr.Value;
                                    ObjectIdCollection acObjIdColl = new ObjectIdCollection(acSSett.GetObjectIds());
                                    if ((acObjIdColl != null) && (acObjIdColl.Count > 0))
                                    {
                                        foreach (ObjectId iid in acObjIdColl)
                                        {
                                            objcoll.Add(iid);
                                        }
                                    }
                                }
                            }
                            if (objcoll.Count > 0)
                            {
                                obcLIST.Add(new Pair <Pair <string, ObjectId>, ObjectIdCollection>(la.First, objcoll));
                            }
                        }
                        transaction.Commit();
                    }
                }//
                #endregion

                ObjectIdCollection kju = new ObjectIdCollection();
                #region прочитане на обектите от моделното пространство и складира ObjectIds в масив
                using (DocumentLock DocLock = doc.LockDocument())
                {
                    using (Transaction acTrans = db.TransactionManager.StartTransaction())
                    {
                        BlockTable acBlkTbl;
                        acBlkTbl = acTrans.GetObject(db.BlockTableId,
                                                     OpenMode.ForRead) as BlockTable;

                        // Open the Block table record Model space for write
                        BlockTableRecord acBlkTblRec;
                        acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace],
                                                        OpenMode.ForWrite) as BlockTableRecord;
                        foreach (ObjectId ig in acBlkTblRec)
                        {
                            kju.Add(ig);
                        }
                    }
                }
                #endregion


                #region export
                LayoutManager acLayoutMgr;
                acLayoutMgr = LayoutManager.Current;
                using (DocumentLock DocLock = doc.LockDocument())
                {
                    foreach (Pair <Pair <string, ObjectId>, ObjectIdCollection> item in obcLIST)
                    {
                        using (Transaction acTrans = db.TransactionManager.StartTransaction())
                        {
                            foreach (ObjectId ig in kju)
                            {
                                bool exist = false;
                                foreach (ObjectId igg in item.Second)
                                {
                                    if (igg == ig)
                                    {
                                        exist = true;
                                        break;
                                    }
                                }
                                if (!exist)
                                {
                                    Entity ent = null;
                                    try
                                    {
                                        ent = acTrans.GetObject(ig, OpenMode.ForWrite) as Entity;
                                    }
                                    catch { }
                                    if (ent != null)
                                    {
                                        ent.Erase();
                                    }
                                }
                            }

                            foreach (Pair <Pair <string, ObjectId>, ObjectIdCollection> it in obcLIST)
                            {
                                if (it.First.First != item.First.First)
                                {
                                    acLayoutMgr.DeleteLayout(it.First.First);
                                }
                            }
                            try
                            {
                                db.SaveAs(selectedFolder + item.First.First + sufixResult.StringResult + ".DWG", DwgVersion.Current);
                            }
                            catch
                            {
                            }
                        }
                    }
                }
                #endregion

                // MgdAcApplication.MainWindow.WindowState = Autodesk.AutoCAD.Windows.Window.State.Maximized;
                // MgdAcApplication.MainWindow.Visible = false;
            }
            catch
            {
                Application.MainWindow.Visible = true;
            }
            Application.MainWindow.Visible = true;
        }
Exemplo n.º 13
0
        private void SetSystemVariable(string name, string value, bool isReWrite)
        {
            object nameVar = null;

            try
            {
                nameVar = AutoCadApp.GetSystemVariable(name);
            }
            catch
            {
                return;
            }

            if (name.ToUpper() == "TRUSTEDPATHS")
            {
                var paths = value.Split(';').Select(p => Path.Combine(_localSettingsFolder, p));
                value = String.Join(";", paths);
                if (isReWrite)
                {
                    nameVar = value;
                }
                else
                {
                    nameVar = getOnlyExistsPaths(nameVar?.ToString(), "TRUSTEDPATHS");
                    if (string.IsNullOrEmpty(nameVar?.ToString()))
                    {
                        nameVar = value;
                    }
                    else
                    {
                        nameVar += ";" + value;
                    }
                }
                nameVar = getOnlyExistsPaths(nameVar?.ToString(), "TRUSTEDPATHS");
                try
                {
                    Log.Info("TRUSTEDPATHS = {0}", nameVar);
                }
                catch { }
            }
            else
            {
                if (isReWrite)
                {
                    nameVar = value;
                }
                else
                {
                    if ((nameVar == null) || (Convert.ToString(nameVar) == ""))
                    {
                        nameVar = value;
                    }
                    else if (!value.ToUpper().Contains((nameVar.ToString().Remove(nameVar.ToString().Length - 1, 1)).ToUpper()))
                    {
                        nameVar += ";" + value;
                    }
                }
            }

            try
            {
                AutoCadApp.SetSystemVariable(name, nameVar);
            }
            catch
            {
                try
                {
                    AutoCadApp.SetSystemVariable(name, Convert.ToInt16(nameVar));
                }
                catch (Exception ex)
                {
                    try
                    {
                        Log.Error(ex, $"SetSystemVariable {name}");
                    }
                    catch { }
                }
            }
        }
Exemplo n.º 14
0
        public void PrintTT()
        {
            Document      acDoc     = Application.DocumentManager.MdiActiveDocument;
            Database      acCurDb   = acDoc.Database;
            Editor        ed        = Application.DocumentManager.MdiActiveDocument.Editor;
            List <String> imagelist = new List <String>();

            string directory = @"D:\";//磁盘路径
            string MediaName = comboBoxMedia.SelectedItem.ToString().Replace(" ", "_").Replace("毫米", "MM").Replace("英寸", "Inches").Replace("像素", "Pixels");

            try
            {
                if (PlotFactory.ProcessPlotState == ProcessPlotState.NotPlotting)
                {
                    using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
                    {
                        int flag = 0;
                        //获取当前布局管理器变量
                        LayoutManager acLayoutMgr = LayoutManager.Current;
                        //获取当前布局变量
                        Layout acLayout = (Layout)acTrans.GetObject(acLayoutMgr.GetLayoutId(acLayoutMgr.CurrentLayout), OpenMode.ForRead);
                        //Layout acLayout = (Layout)acTrans.GetObject(acLayoutMgr.GetLayoutId(acLayoutMgr.CurrentLayout), OpenMode.ForWrite);
                        //获取当前布局的打印信息
                        PlotInfo acPlInfo = new PlotInfo()
                        {
                            Layout = acLayout.ObjectId
                        };



                        //提示用户输入打印窗口的两个角点
                        PromptPointResult resultp = ed.GetPoint("\n指定第一个角点");
                        if (resultp.Status != PromptStatus.OK)
                        {
                            return;
                        }
                        Point3d basePt = resultp.Value;
                        resultp = ed.GetCorner("指定对角点", basePt);
                        if (resultp.Status != PromptStatus.OK)
                        {
                            return;
                        }
                        Point3d cornerPt = resultp.Value;

                        //选择实体对象
                        // PromptSelectionOptions result1 = new PromptSelectionOptions();

                        SelectionFilter frameFilter = new SelectionFilter(
                            new TypedValue[]
                            { new TypedValue(0, "LWPOLYLINE"),
                              new TypedValue(90, 4),
                              new TypedValue(70, 1) });


                        PromptSelectionResult selectedFrameResult = ed.SelectWindow(basePt, cornerPt, frameFilter);
                        // PromptSelectionResult selectedFrameResult = ed.GetSelection(result1, frameFilter);
                        PromptSelectionResult selectedFrameResult1 = ed.SelectAll(frameFilter);
                        if (selectedFrameResult.Status == PromptStatus.OK)
                        {
                            List <ObjectId> selectedObjectIds = new List <ObjectId>(selectedFrameResult.Value.GetObjectIds());
                            List <ObjectId> resultObjectIds   = new List <ObjectId>(selectedFrameResult.Value.GetObjectIds());
                            RemoveInnerPLine(acTrans, ref selectedObjectIds, ref resultObjectIds);
                            foreach (ObjectId frameId in resultObjectIds)
                            {
                                Polyline framePline = acTrans.GetObject(frameId, OpenMode.ForRead) as Polyline;
                                framePline.Highlight();
                            }


                            PlotSettings acPlSet = new PlotSettings(acLayout.ModelType);
                            acPlSet.CopyFrom(acLayout);
                            //着色打印选项,设置按线框进行打印
                            acPlSet.ShadePlot = PlotSettingsShadePlotType.Wireframe;
                            PlotSettingsValidator acPlSetVdr = PlotSettingsValidator.Current;
                            //打印比例
                            //用户标准打印
                            acPlSetVdr.SetUseStandardScale(acPlSet, true);
                            acPlSetVdr.SetStdScaleType(acPlSet, StdScaleType.ScaleToFit);

                            //居中打印
                            acPlSetVdr.SetPlotCentered(acPlSet, true);
                            //调用GetPlotStyleSheetList之后才可以使用SetCurrentStyleSheet
                            System.Collections.Specialized.StringCollection sc = acPlSetVdr.GetPlotStyleSheetList();
                            //设置打印样式表
                            if (comboBoxStyleSheet.SelectedItem.ToString() == "无")
                            {
                                acPlSetVdr.SetCurrentStyleSheet(acPlSet, "acad.ctb");
                            }

                            else
                            {
                                acPlSetVdr.SetCurrentStyleSheet(acPlSet, comboBoxStyleSheet.SelectedItem.ToString());
                            }

                            //选择方向
                            if (radioButtonHorizontal.Checked)
                            {
                                //横向
                                acPlSetVdr.SetPlotConfigurationName(acPlSet, "DWG To PDF.pc3", MediaName);
                                acPlSetVdr.SetPlotRotation(acPlSet, PlotRotation.Degrees090);
                            }

                            //竖向
                            if (radioButtonVertical.Checked)
                            {
                                acPlSetVdr.SetPlotConfigurationName(acPlSet, "DWG To PDF.pc3", MediaName);//获取打印图纸尺寸ComboxMedia
                                acPlSetVdr.SetPlotRotation(acPlSet, PlotRotation.Degrees000);
                            }
                            PlotProgressDialog acPlProgDlg = new PlotProgressDialog(false, resultObjectIds.Count, true);
                            string             imagename   = "";
                            string[]           files       = new string[] { };
                            List <string>      listfile    = new List <string>();
                            foreach (var frame in resultObjectIds)
                            {
                                if (!Directory.Exists(directory))
                                {
                                    Directory.CreateDirectory(directory);
                                }
                                flag++;

                                Entity ent = acTrans.GetObject(frame, OpenMode.ForRead) as Entity;

                                imagename = string.Format("{0}-{1}.pdf", frame, flag);
                                //imagelist.Add(directory + imagename);
                                listfile.Add(directory + imagename);


                                //设置是否使用打印样式
                                acPlSet.ShowPlotStyles = true;
                                //设置打印区域
                                Extents3d extents3d = ent.GeometricExtents;

                                Extents2d E2d = new Extents2d(extents3d.MinPoint.X, extents3d.MinPoint.Y, extents3d.MaxPoint.X, extents3d.MaxPoint.Y);
                                acPlSetVdr.SetPlotWindowArea(acPlSet, E2d);
                                acPlSetVdr.SetPlotType(acPlSet, Autodesk.AutoCAD.DatabaseServices.PlotType.Window);
                                //重载和保存打印信息
                                acPlInfo.OverrideSettings = acPlSet;
                                //验证打印信息设置,看是否有误
                                PlotInfoValidator acPlInfoVdr = new PlotInfoValidator();
                                acPlInfoVdr.MediaMatchingPolicy = MatchingPolicy.MatchEnabled;
                                acPlInfoVdr.Validate(acPlInfo);

                                while (PlotFactory.ProcessPlotState != ProcessPlotState.NotPlotting)
                                {
                                    continue;
                                }
                                #region BackUpCode

                                //保存App的原参数
                                short bgPlot = (short)Application.GetSystemVariable("BACKGROUNDPLOT");
                                //设定为前台打印,加快打印速度
                                Application.SetSystemVariable("BACKGROUNDPLOT", 0);
                                PlotEngine acPlEng1 = PlotFactory.CreatePublishEngine();
                                // acPlProgDlg.set_PlotMsgString(PlotMessageIndex.DialogTitle, "图片输出");
                                // acPlProgDlg.set_PlotMsgString(PlotMessageIndex.CancelSheetButtonMessage, "取消输出");
                                //acPlProgDlg.set_PlotMsgString(PlotMessageIndex.SheetProgressCaption, "输出进度");
                                acPlProgDlg.LowerPlotProgressRange = 0;
                                acPlProgDlg.UpperPlotProgressRange = 100;
                                acPlProgDlg.PlotProgressPos        = 0;
                                acPlProgDlg.OnBeginPlot();
                                acPlProgDlg.IsVisible = true;
                                acPlEng1.BeginPlot(acPlProgDlg, null);
                                acPlEng1.BeginDocument(acPlInfo, "", null, 1, true, directory + imagename);
                                //  acPlProgDlg.set_PlotMsgString(PlotMessageIndex.Status, string.Format("正在输出文件"));
                                acPlProgDlg.OnBeginSheet();
                                acPlProgDlg.LowerSheetProgressRange = 0;
                                acPlProgDlg.UpperSheetProgressRange = 100;
                                acPlProgDlg.SheetProgressPos        = 0;
                                PlotPageInfo acPlPageInfo = new PlotPageInfo();
                                acPlEng1.BeginPage(acPlPageInfo, acPlInfo, true, null);
                                acPlEng1.BeginGenerateGraphics(null);
                                acPlEng1.EndGenerateGraphics(null);
                                acPlEng1.EndPage(null);
                                acPlProgDlg.SheetProgressPos = 100;
                                acPlProgDlg.OnEndSheet();
                                acPlEng1.EndDocument(null);
                                acPlProgDlg.PlotProgressPos = 100;
                                acPlProgDlg.OnEndPlot();
                                acPlEng1.EndPlot(null);
                                acPlEng1.Dispose();
                                acPlEng1.Destroy();
                                Application.SetSystemVariable("BACKGROUNDPLOT", bgPlot);

                                #endregion
                            }


                            files = listfile.ToArray();
                            PlotConfig config = PlotConfigManager.CurrentConfig;
                            //获取去除扩展名后的文件名(不含路径)
                            string fileName = SymbolUtilityServices.GetSymbolNameFromPathName(acDoc.Name, "dwg");
                            //定义保存文件对话框
                            PromptSaveFileOptions opt = new PromptSaveFileOptions("文件名")
                            {
                                //保存文件对话框的文件扩展名列表
                                Filter           = "*" + config.DefaultFileExtension + "|*" + config.DefaultFileExtension,
                                DialogCaption    = "浏览打印文件",                            //保存文件对话框的标题
                                InitialDirectory = @"D:\",                              //缺省保存目录
                                InitialFileName  = fileName + "-" + acLayout.LayoutName //缺省保存文件名
                            };
                            //根据保存对话框中用户的选择,获取保存文件名
                            PromptFileNameResult result = ed.GetFileNameForSave(opt);
                            if (result.Status != PromptStatus.OK)
                            {
                                return;
                            }
                            fileName = result.StringResult;

                            //string fileName = @"D:\输出.pdf";
                            PdfDocumentBase docx = PdfDocument.MergeFiles(files);
                            docx.Save(fileName, FileFormat.PDF);
                            System.Diagnostics.Process.Start(fileName);



                            //保存App的原参数
                            short bgPlot1 = (short)Application.GetSystemVariable("BACKGROUNDPLOT");
                            //设定为前台打印,加快打印速度
                            Application.SetSystemVariable("BACKGROUNDPLOT", 0);
                            PlotEngine acPlEng = PlotFactory.CreatePublishEngine();
                            acPlProgDlg.set_PlotMsgString(PlotMessageIndex.DialogTitle, "图片输出");
                            acPlProgDlg.set_PlotMsgString(PlotMessageIndex.CancelSheetButtonMessage, "取消输出");
                            acPlProgDlg.set_PlotMsgString(PlotMessageIndex.SheetProgressCaption, "输出进度");
                            acPlProgDlg.LowerPlotProgressRange = 0;
                            acPlProgDlg.UpperPlotProgressRange = 100;
                            acPlProgDlg.PlotProgressPos        = 0;
                            acPlProgDlg.OnBeginPlot();
                            acPlProgDlg.IsVisible = true;
                            acPlEng.BeginPlot(acPlProgDlg, null);
                            acPlEng.BeginDocument(acPlInfo, "", null, 1, true, directory + imagename);
                            acPlProgDlg.set_PlotMsgString(PlotMessageIndex.Status, string.Format("正在输出文件"));
                            acPlProgDlg.OnBeginSheet();
                            acPlProgDlg.LowerSheetProgressRange = 0;
                            acPlProgDlg.UpperSheetProgressRange = 100;
                            acPlProgDlg.SheetProgressPos        = 0;
                            PlotPageInfo acPlPageInfo1 = new PlotPageInfo();
                            acPlEng.BeginPage(acPlPageInfo1, acPlInfo, true, null);
                            acPlEng.BeginGenerateGraphics(null);
                            acPlEng.EndGenerateGraphics(null);
                            acPlEng.EndPage(null);
                            acPlProgDlg.SheetProgressPos = 100;
                            acPlProgDlg.OnEndSheet();
                            acPlEng.EndDocument(null);
                            acPlProgDlg.PlotProgressPos = 100;
                            acPlProgDlg.OnEndPlot();
                            acPlEng.EndPlot(null);
                            acPlEng.Dispose();
                            acPlEng.Destroy();
                            Application.SetSystemVariable("BACKGROUNDPLOT", bgPlot1);

                            acPlProgDlg.Dispose();
                            acPlProgDlg.Destroy();

                            for (int i = 0; i < files.Length; i++)
                            {
                                File.Delete(files[i]);
                            }
                        }
                        while (PlotFactory.ProcessPlotState != ProcessPlotState.NotPlotting)
                        {
                            continue;
                        }
                        //MessageBox.Show("打印完成!");
                    }
                }
                else
                {
                    ed.WriteMessage("\n另一个打印进程正在进行中.");
                }
            }



            catch (System.Exception)
            {
                throw;
            }
        }
Exemplo n.º 15
0
        public void CreateViewportFromModelStart()
        {
            using (Transaction transaction = _doc.Database.TransactionManager.StartTransaction())
            {
                #region Switch to model space

                Application.SetSystemVariable("TILEMODE", 1);

                #endregion

                #region Get View Rectangle Pts from model space

                PromptPointOptions VportRectangleOpts =
                    new PromptPointOptions("\nSpecify rectangle describing the desired view : \n");
                PromptPointResult VportRectangleRes = _doc.Editor.GetPoint(VportRectangleOpts);
                if (VportRectangleRes.Status != PromptStatus.OK)
                {
                    return;
                }

                Point3d      CornerPt = VportRectangleRes.Value;
                RectangleJig Recjig   = new RectangleJig(CornerPt);
                if (_doc.Editor.Drag(Recjig).Status == PromptStatus.Cancel)
                {
                    return;
                }

                Polyline          ViewPline    = Recjig.Polyline;
                Point3dCollection ViewPlinePts = GeometryUtility.GetPointsFromPolyline(ViewPline);
                if (ViewPlinePts.Count == 5)
                {
                    ViewPlinePts.RemoveAt(4);
                }

                #endregion

                #region Calculate View height

                double viewHeight = Math.Abs(ViewPlinePts[0].Y - ViewPlinePts[2].Y);

                #endregion

                #region Calculate View width

                double viewWidth = Math.Abs(ViewPlinePts[0].X - ViewPlinePts[2].X);

                #endregion

                #region Calculate View Center Pt

                double baseWidth = ViewPlinePts[0].X;
                if (ViewPlinePts[0].X > ViewPlinePts[2].X)
                {
                    baseWidth = ViewPlinePts[2].X;
                }

                double baseHeight = ViewPlinePts[0].Y;
                if (ViewPlinePts[0].Y > ViewPlinePts[2].Y)
                {
                    baseHeight = ViewPlinePts[2].Y;
                }
                Point2d ViewCenterPt = new Point2d(
                    baseWidth + (Math.Abs(ViewPlinePts[0].X - ViewPlinePts[2].X) / 2),
                    baseHeight + (Math.Abs(ViewPlinePts[0].Y - ViewPlinePts[2].Y) / 2));

                #endregion

                #region Select Paper Space

                PromptKeywordOptions PaperSpaceOpts = new PromptKeywordOptions("");
                PaperSpaceOpts.Message   = "\nChose paper space : ";
                PaperSpaceOpts.AllowNone = false;

                Layout currLayout;
                // Open the Block table for read
                BlockTable       Bt            = transaction.GetObject(_doc.Database.BlockTableId, OpenMode.ForRead) as BlockTable;
                BlockTableRecord BtrModelSpace =
                    (BlockTableRecord)transaction.GetObject(Bt[BlockTableRecord.ModelSpace], OpenMode.ForRead);
                foreach (ObjectId BtrId in Bt)
                {
                    BlockTableRecord Btr = (BlockTableRecord)transaction.GetObject(BtrId, OpenMode.ForRead);
                    if (Btr.IsLayout && Btr.ObjectId != BtrModelSpace.ObjectId)
                    {
                        currLayout = (Layout)transaction.GetObject(Btr.LayoutId, OpenMode.ForRead);
                        PaperSpaceOpts.Keywords.Add(currLayout.LayoutName);
                    }
                }
                PromptResult PaperSpaceRes = _doc.Editor.GetKeywords(PaperSpaceOpts);
                LayoutManager.Current.CurrentLayout = PaperSpaceRes.StringResult;

                #endregion

                var keywordSelectionResult =
                    _editorHelper.PromptForKeywordSelection(
                        "\nSpecify rectangle describing viewport or base point with scale factor",
                        new[] { "Rectangle", "Base point" },
                        false,
                        "Rectangle");
                if (keywordSelectionResult.Status != PromptStatus.OK)
                {
                    return;
                }

                var viewportHeight      = 0.0;
                var viewportWidth       = 0.0;
                var CenterPt            = new Point3d();
                var viewportCustomScale = 0.0;

                if (keywordSelectionResult.StringResult == "Rectangle")
                {
                    #region Get Viewport Rectangle Pts

                    VportRectangleOpts = new PromptPointOptions("\nSpecify rectangle describing the viewport : \n");
                    VportRectangleRes  = _doc.Editor.GetPoint(VportRectangleOpts);

                    if (VportRectangleRes.Status != PromptStatus.OK)
                    {
                        return;
                    }

                    CornerPt = VportRectangleRes.Value;
                    Recjig   = new RectangleJig(CornerPt);
                    if (_doc.Editor.Drag(Recjig).Status == PromptStatus.Cancel)
                    {
                        return;
                    }

                    Polyline          ViewportPline    = Recjig.Polyline;
                    Point3dCollection ViewportPlinePts = GeometryUtility.GetPointsFromPolyline(ViewportPline);
                    GeometryUtility.RemoveDuplicate(ViewportPlinePts);

                    if (ViewportPlinePts.Count == 5)
                    {
                        ViewportPlinePts.RemoveAt(4);
                    }

                    #endregion

                    #region Calculate Viewport height

                    viewportHeight = Math.Abs(ViewportPlinePts[0].Y - ViewportPlinePts[2].Y);

                    #endregion

                    #region Calculate Viewport width

                    viewportWidth = Math.Abs(ViewportPlinePts[0].X - ViewportPlinePts[2].X);

                    #endregion

                    #region Calculate Viewport Center Pt

                    baseWidth = ViewportPlinePts[0].X;
                    if (ViewportPlinePts[0].X > ViewportPlinePts[2].X)
                    {
                        baseWidth = ViewportPlinePts[2].X;
                    }

                    baseHeight = ViewportPlinePts[0].Y;
                    if (ViewportPlinePts[0].Y > ViewportPlinePts[2].Y)
                    {
                        baseHeight = ViewportPlinePts[2].Y;
                    }
                    CenterPt = new Point3d(
                        baseWidth + (Math.Abs(ViewportPlinePts[0].X - ViewportPlinePts[2].X) / 2),
                        baseHeight + (Math.Abs(ViewportPlinePts[0].Y - ViewportPlinePts[2].Y) / 2),
                        0.0);

                    #endregion

                    #region Calculate Viewport Custom Scale

                    viewportCustomScale = viewportHeight / viewHeight;

                    #endregion
                }
                else
                {
                    #region Get Viewport Base Point

                    var viewportBasePoint = _editorHelper.PromptForPoint("\nSpecify bottom left point of viewport : ");
                    if (viewportBasePoint.Status != PromptStatus.OK)
                    {
                        return;
                    }

                    #endregion

                    #region Get ViewportCustomScale

                    var scaleFactorResult = _editorHelper.PromptForDouble("\nSpecify viewport scale factor : ", 1.0);
                    if (scaleFactorResult.Status != PromptStatus.OK)
                    {
                        return;
                    }
                    if (scaleFactorResult.Value <= 0)
                    {
                        _editorHelper.WriteMessage("\nSpecified scale factor is incorrect !\n");
                    }
                    viewportCustomScale = scaleFactorResult.Value;

                    #endregion

                    #region Calculate Viewport height

                    viewportHeight = viewHeight * viewportCustomScale;

                    #endregion

                    #region Calculate Viewport width

                    viewportWidth = viewWidth * viewportCustomScale;

                    #endregion

                    #region Calculate Viewport Center Pt

                    CenterPt = new Point3d(viewportBasePoint.Value.X + viewportWidth / 2,
                                           viewportBasePoint.Value.Y + viewportHeight / 2, 0);

                    #endregion
                }

                #region create viewport

                var Vport = new Viewport
                {
                    ViewCenter  = ViewCenterPt,
                    CenterPoint = CenterPt,
                    Height      = viewportHeight,
                    Width       = viewportWidth,
                    CustomScale = viewportCustomScale
                };

                #endregion

                #region Insert viewport into paper space

                BlockTableRecord PaperSpaceBtr = new BlockTableRecord();
                foreach (ObjectId BtrId in Bt)
                {
                    BlockTableRecord Btr = (BlockTableRecord)transaction.GetObject(BtrId, OpenMode.ForRead);
                    if (Btr.IsLayout && Btr.ObjectId != BtrModelSpace.ObjectId)
                    {
                        currLayout = (Layout)transaction.GetObject(Btr.LayoutId, OpenMode.ForRead);
                        if (currLayout.LayoutName == PaperSpaceRes.StringResult)
                        {
                            PaperSpaceBtr =
                                (BlockTableRecord)
                                transaction.GetObject(Bt[BlockTableRecord.PaperSpace], OpenMode.ForWrite);
                        }
                    }
                }

                if (PaperSpaceBtr == null)
                {
                    _doc.Editor.WriteMessage("Error getting the selected layout");
                }
                // Add the new object to the block table record and the transaction
                PaperSpaceBtr.AppendEntity(Vport);

                transaction.AddNewlyCreatedDBObject(Vport, true);

                // Enable the viewport
                Vport.On = true;

                // Set the new viewport current via an imported ObjectARX function
#if acad2012
                SetCurrentVPort2010(Vport.UnmanagedObject);
#endif
#if acad2013
                SetCurrentVPort2013(Vport.UnmanagedObject);
#endif
#if bcad
                SetCurrentVPortBCad(Vport.UnmanagedObject);
#endif

                #endregion

                transaction.Commit();
            }
        }
Exemplo n.º 16
0
Arquivo: Ac.cs Projeto: 15831944/Geo7
 public static void SetSystemVariable(string name, object value)
 {
     AcApp.SetSystemVariable(name, value);
 }
Exemplo n.º 17
0
        private void comboUnits_SelectedIndexChanged(object sender, EventArgs e)
        {
            RMS = bakRMS;
            ComboBox cb = (ComboBox)sender;
            int      N  = 0;
            double   k  = 1.0;

            switch (cb.Text)
            {
            case "Inches":
                N = 1;
                k = 25.4;
                break;

            case "Feet":
                N = 2;
                k = 12.0 * 25.4;
                break;

            case "Millimeters":
                N = 4;
                k = 1.0;
                break;

            case "Centimeters":
                N = 5;
                k = 10.0;
                break;

            case "Meters":
                N = 6;
                k = 1000.0;
                break;

            case "Decimeters":
                N = 14;
                k = 100.0;
                break;

            default:
                break;
            }
            RMS.Density      = Convert.ToDouble(tableRegDescr.TableModel.Rows[15].Cells[1].Data);
            RMS.LinearVolume = bakRMS.Area * k * k / (1000.0 * 1000.0);

            //MessageBox.Show(RMS.LinearVolume.ToString());

            RMS.G = RMS.Density * RMS.LinearVolume;

            Application.SetSystemVariable("INSUNITS", N);

            tableRegDescr.TableModel.Rows[0].Cells[1].Data  = RMS.Area;
            tableRegDescr.TableModel.Rows[1].Cells[1].Data  = RMS.Iy;
            tableRegDescr.TableModel.Rows[2].Cells[1].Data  = RMS.WyUpper;
            tableRegDescr.TableModel.Rows[3].Cells[1].Data  = RMS.WyLower;
            tableRegDescr.TableModel.Rows[4].Cells[1].Data  = RMS.DUpper;
            tableRegDescr.TableModel.Rows[5].Cells[1].Data  = RMS.DLower;
            tableRegDescr.TableModel.Rows[6].Cells[1].Data  = RMS.Iyy;
            tableRegDescr.TableModel.Rows[7].Cells[1].Data  = RMS.Iz;
            tableRegDescr.TableModel.Rows[8].Cells[1].Data  = RMS.WzRight;
            tableRegDescr.TableModel.Rows[9].Cells[1].Data  = RMS.WzLeft;
            tableRegDescr.TableModel.Rows[10].Cells[1].Data = RMS.DRight;
            tableRegDescr.TableModel.Rows[11].Cells[1].Data = RMS.DLeft;
            tableRegDescr.TableModel.Rows[12].Cells[1].Data = RMS.Izz;
            tableRegDescr.TableModel.Rows[13].Cells[1].Data = RMS.Imin;
            tableRegDescr.TableModel.Rows[14].Cells[1].Data = RMS.Imax;


            for (int i = 0; i < 15; i++)
            {
                tableRegDescr.TableModel.Rows[i].Cells[2].Text = cb.Text;
            }

            tableRegDescr.TableModel.Rows[16].Cells[1].Data = RMS.G;
            tableRegDescr.TableModel.Rows[17].Cells[1].Data = RMS.G;

            if (radioKg.Checked == true)
            {
                k = 1.0;
            }
            if (radioG.Checked == true)
            {
                k = 1.0 / 1000.0;
            }
            if (radioT.Checked == true)
            {
                k = 1000.0;
            }
            tableRegDescr.TableModel.Rows[18].Cells[1].Data = RMS.G * 9.80665 * k;
        }
Exemplo n.º 18
0
        public static ResultDTO plotTest(string id, string file, string fileID, bool isSnap = false)
        {
            try
            {
                Document doc = Application.DocumentManager.Open(file, false);
                Application.DocumentManager.MdiActiveDocument = doc;

                PlotSettings ps     = null; //声明增强型打印设置对象
                Layout       layout = null; //当前布局对象
                bool         isTile = AppConfig.GetAppSettings("ViewMode").ToLower().Trim() == "tilepicviewer";
                using (Transaction trans = doc.Database.TransactionManager.StartTransaction())
                {
                    LayoutManager lm = LayoutManager.Current;//获取当前布局管理器
                    layout = (Layout)GetLayoutId(doc.Database, lm.CurrentLayout).GetObject(OpenMode.ForRead);

                    ps = new PlotSettings(layout.ModelType);
                    ps.CopyFrom(layout);//从已有打印设置中获取打印设置

                    //0.更新打印设备、图纸尺寸和打印样式表信息
                    PlotSettingsValidator validator = PlotSettingsValidator.Current;
                    validator.RefreshLists(ps);
                    //1.设置打印驱动
                    string plotConfigurationName = AppConfig.GetAppSettings("Printer");
                    if (isSnap)
                    {
                        plotConfigurationName = "PublishToWeb JPG.pc3";
                    }
                    validator.SetPlotConfigurationName(ps, plotConfigurationName, null);

                    //2.设置打印纸张
                    StringCollection cMNameLst = validator.GetCanonicalMediaNameList(ps);
                    string           mediaName = AppConfig.GetAppSettings("CanonicalMediaName");
                    if (isSnap)
                    {
                        mediaName = "VGA (480.00 x 640.00 像素)";
                    }
                    bool             isHas = false;
                    StringCollection canonicalMediaNames = validator.GetCanonicalMediaNameList(ps);
                    foreach (string canonicalMediaName in canonicalMediaNames)
                    {
                        string localeMediaName = validator.GetLocaleMediaName(ps, canonicalMediaName);
                        if (localeMediaName == mediaName)
                        {
                            validator.SetCanonicalMediaName(ps, canonicalMediaName);
                            isHas = true;
                            break;
                        }
                    }
                    if (!isHas)
                    {
                        throw new System.Exception("纸张:" + mediaName + "不存在!");
                    }
                    //3.设置打印样式表
                    string plotStyleSheet = AppConfig.GetAppSettings("PlotStyleSheet");
                    validator.SetCurrentStyleSheet(ps, plotStyleSheet);

                    validator.SetPlotType(ps, Autodesk.AutoCAD.DatabaseServices.PlotType.Extents);
                    validator.SetPlotCentered(ps, true);
                    validator.SetUseStandardScale(ps, true);
                    validator.SetStdScaleType(ps, StdScaleType.ScaleToFit);//设置打印时布满图纸

                    validator.SetPlotRotation(ps, PlotRotation.Degrees000);
                    trans.Commit();
                }

                PlotConfig config = PlotConfigManager.CurrentConfig;
                doc = AcadApp.DocumentManager.MdiActiveDocument;
                Editor ed = doc.Editor;
                //获取去除扩展名后的文件名(不含路径)
                string fileName = SymbolUtilityServices.GetSymbolNameFromPathName(doc.Name, "dwg");
                //存放在同目录下
                var basePath = AppConfig.GetAppSettings("CacheViewFilePath");
                if (!basePath.EndsWith("\\"))
                {
                    basePath += "\\";
                }

                int    num  = Convert.ToInt32(fileID) / 1000 + 1;
                string root = basePath + "Dwg\\" + string.Format("{0}", num.ToString("D8")) + "\\";
                if (!isTile)
                {
                    root = Path.Combine(basePath, string.Format("{0}", num.ToString("D8")) + "\\");
                }
                if (!Directory.Exists(@root))
                {
                    Directory.CreateDirectory(@root);
                }

                fileName = root + id + config.DefaultFileExtension;
                if (!isTile || isSnap)
                {
                    fileName = root + fileID + config.DefaultFileExtension;
                }

                //为了防止后台打印问题,必须在调用打印API时设置BACKGROUNDPLOT系统变量为0
                short backPlot = (short)AcadApp.GetSystemVariable("BACKGROUNDPLOT");
                AcadApp.SetSystemVariable("BACKGROUNDPLOT", 0);

                PlotEngine plotEngine = PlotFactory.CreatePublishEngine(); //创建一个打印引擎
                PlotInfo   pi         = new PlotInfo();                    //创建打印信息
                pi.Layout           = layout.ObjectId;                     //要打印的布局
                pi.OverrideSettings = ps;                                  //使用ps中的打印设置

                //验证打印信息是否有效
                PlotInfoValidator piv = new PlotInfoValidator();
                piv.MediaMatchingPolicy = MatchingPolicy.MatchEnabled;
                piv.Validate(pi);

                PlotPageInfo ppi = new PlotPageInfo();
                plotEngine.BeginPlot(null, null);
                plotEngine.BeginDocument(pi, doc.Name, null, 1, true, fileName);
                plotEngine.BeginPage(ppi, pi, true, null);
                plotEngine.BeginGenerateGraphics(null);
                plotEngine.EndGenerateGraphics(null);
                plotEngine.EndPage(null);
                plotEngine.EndDocument(null);
                plotEngine.EndPlot(null);

                plotEngine.Destroy();//销毁打印引擎

                //恢复BACKGROUNDPLOT系统变量的值
                AcadApp.SetSystemVariable("BACKGROUNDPLOT", backPlot);

                doc.CloseAndDiscard();

                if (!File.Exists(fileName))
                {
                    throw new System.Exception("打印文件生成失败!");
                }

                ResultDTO reVal = new ResultDTO();
                if (isTile && !isSnap)//如果是图片就切图
                {
                    var img = new ZoomifyImage(fileName, 1024);
                    img.Zoomify(root + id + "\\");

                    reVal.status        = true;
                    reVal.DirectoryPath = "/" + id + "/";
                    reVal.ZoomLevel     = img.ZoomLevels - 1;
                }
                else
                {
                    reVal.status = true;
                }

                try
                {
                    //强制删除过程打印文件
                    if (File.Exists(file) && !isSnap)
                    {
                        File.Delete(file);
                    }
                }
                catch { }

                return(reVal);
            }
            catch (System.Exception e)
            {
                return(new ResultDTO
                {
                    status = false,
                    ErrInfo = e.Message,
                    FileName = file
                });
            }
        }