コード例 #1
0
ファイル: cmdUC1.cs プロジェクト: 15831944/EM
        updateControl()
        {
            myForms.updateCNTL fmUpdateCNTL = Grading_Palette.gPalette.pUpdateCNTL;

            string path = Path.GetDirectoryName(BaseObjs.docFullName);
            string name = BaseObjs.docName;
            string file = "";

            if (fmUpdateCNTL.TARGETDWGNAME == "" || fmUpdateCNTL.TARGETDWGNAME == null)
            {
                try
                {
                    file = FileManager.getFilesWithEditor("Select Control Drawing for Transfer.", "GETFILE", "Drawing (*.dwg)|*.dwg", path, "Message");
                    if (file == null)
                    {
                        return;
                    }
                }
                catch (System.Exception ex)
                {
                    BaseObjs.writeDebug(ex.Message + " cmdUC1.cs: line: 30");
                }
                path = Path.GetDirectoryName(file);
                name = Path.GetFileName(file);
            }
            else
            {
                path = fmUpdateCNTL.TARGETDWGPATH;
                name = fmUpdateCNTL.TARGETDWGNAME;
            }

            Grading_Palette.gPalette.showPalettes(vis: true, index: 5);
            Grading_Palette.gPalette.pGrading.Initialize_Form();

            int fileStatus = FileManager.getFileStatus(string.Format("{0}{1}{2}", path, @"\", name));

            switch (fileStatus)
            {
            case (int)filestatus.isOpenLocalReadOnly:
                return;

            case (int)filestatus.isOpenLocal:      //set file active
                fmUpdateCNTL.isOpen = true;
                break;

            case (int)filestatus.isLocked:
                return;

            case (int)filestatus.isAvailable:      //open the file
                fmUpdateCNTL.TARGETDWGPATH = path;
                fmUpdateCNTL.TARGETDWGNAME = name;
                try
                {
                    Grading_Palette.setfocus("Update CNTL");
                    fmUpdateCNTL.Focusable = true;
                    fmUpdateCNTL.IsEnabled = true;
                    fmUpdateCNTL.Focus();
                    fmUpdateCNTL.lblTarDwg.Content = name;
                }
                catch (System.Exception ex)
                {
                    BaseObjs.writeDebug(ex.Message + " cmdUC1.cs: line: 70");
                }
                Grading_Palette.gPalette.pGrading.Focus();
                break;
            }
        }
コード例 #2
0
        executeCmdUC(List <string> layers)
        {
            myForms.updateCNTL fmUpdateCNTL = Grading_Palette.gPalette.pUpdateCNTL;

            string nameTAR      = fmUpdateCNTL.TARGETDWGNAME;
            string pathTAR      = fmUpdateCNTL.TARGETDWGPATH;
            string path_nameTAR = string.Format("{0}{1}{2}", pathTAR, @"\", nameTAR);

            int k = layers.Count;

            TypedValue[] TVs = new TypedValue[k + 2];
            TVs.SetValue(new TypedValue((int)DxfCode.Operator, "<OR"), 0);
            for (int i = 0; i < k; i++)
            {
                TVs.SetValue(new TypedValue((int)DxfCode.LayerName, layers[i]), i + 1);
            }
            TVs.SetValue(new TypedValue((int)DxfCode.Operator, "OR>"), k + 1);
            SelectionSet ss = Base_Tools45.Select.buildSSet(TVs, true);

            if (ss == null)
            {
                Autodesk.AutoCAD.ApplicationServices.Core.Application.ShowAlertDialog("There are no targeted objects as this time.  Exiting...");
                return;
            }
            ObjectId[] idsSS = ss.GetObjectIds();


            Document acDoc   = BaseObjs._acadDoc;
            Database acDbCUR = acDoc.Database;

            Document acDocTAR = FileManager.getDoc(path_nameTAR, Grading_Palette.gPalette.pGrading.isOpen);

            if (acDocTAR == null)
            {
                return;
            }
            Database acDbTAR = acDocTAR.Database;

            bool success = FileManager.transferObjects(idsSS, acDbCUR, acDbTAR);

            if (success)
            {
                acDocTAR.CloseAndSave(path_nameTAR);
                Application.DocumentManager.MdiActiveDocument = acDoc;
                using (BaseObjs._acadDoc.LockDocument())
                {
                    foreach (ObjectId id in idsSS)
                    {
                        try
                        {
                            id.delete();
                        }
                        catch (System.Exception ex)
                        {
                            BaseObjs.writeDebug(ex.Message + " cmdUC2.cs: line: 60");
                        }
                    }
                }
            }
            Grading_Palette.setfocus("Grading Tools");
        }