Пример #1
0
        updateSpreadsheet(ref double dblVolFill, ref double dblVolCut)
        {
            string strPath     = BaseObjs.docFullName;
            string strJN       = BaseObjs.jobNumber();
            string strFN       = string.Format("{0}EW.xlsx", strJN);
            string strFullPath = strPath + "\\" + strFN;

            SelectionSet objSSet = EW_Utility1.buildSSet22();

            if ((dblVolFill == 0))
            {
                bool     exists;
                ObjectId idSurfaceCUT  = Surf.getSurface("VOL_EXIST_BOT", out exists);
                ObjectId idSurfaceFILL = Surf.getSurface("VOL_BOT_SG", out exists);

                TinVolumeSurface objSurfaceFILL = (TinVolumeSurface)idSurfaceFILL.getEnt();
                TinVolumeSurface objSurfaceCUT  = (TinVolumeSurface)idSurfaceCUT.getEnt();

                dblVolCut  = objSurfaceFILL.GetVolumeProperties().UnadjustedCutVolume / 27;
                dblVolFill = objSurfaceFILL.GetVolumeProperties().UnadjustedFillVolume / 27;
                dblVolCut  = dblVolCut + objSurfaceCUT.GetVolumeProperties().UnadjustedCutVolume / 27;
                dblVolFill = dblVolFill + objSurfaceCUT.GetVolumeProperties().UnadjustedFillVolume / 27;
            }

            if (spreadSheetExists(strFullPath, dblVolFill, dblVolCut))
            {
                Excel_ext excl = new Excel_ext(true);
                excl.OpenFile(strFullPath, "");
                excl.FindExcelWorksheet("SUMMARY");

                Excel._Worksheet objWS = excl.excelWrkSht;

                objWS.Range["SUMMARY!volCUT"].Value  = dblVolCut;
                objWS.Range["SUMMARY!volFILL"].Value = dblVolFill;

                //objWS.Range["SUMMARY!AREA_BLDG"].Value = 0;

                excl.CloseFile(true, strFullPath, false);
                excl.excelAPP.Quit();
            }
            else
            {
                MessageBox.Show("Error copying EW spreadsheet");
            }

            objSSet = EW_Utility1.buildSSet8();
            if (objSSet != null && objSSet.Count > 0)
            {
                ObjectId[] ids = objSSet.GetObjectIds();
                for (int i = 0; i < ids.Length; i++)
                {
                    ids[i].delete();
                }
            }

            setupSpreadSheetMS(dblVolFill, dblVolCut);
        }
Пример #2
0
        setupSpreadSheetMS(double dblVolCut = 0, double dblVolFill = 0)
        {
            bool boolIsOpen = false;

            if (dblVolFill == 0)
            {
                bool     exists;
                ObjectId idSurfaceCUT  = Surf.getSurface("VOL_EXIST_BOT", out exists);
                ObjectId idSurfaceFILL = Surf.getSurface("VOL_BOT_SG", out exists);

                TinVolumeSurface objSurfaceFILL = (TinVolumeSurface)idSurfaceFILL.getEnt();
                TinVolumeSurface objSurfaceCUT  = (TinVolumeSurface)idSurfaceCUT.getEnt();

                dblVolCut  = objSurfaceFILL.GetVolumeProperties().UnadjustedCutVolume / 27;
                dblVolFill = objSurfaceFILL.GetVolumeProperties().UnadjustedFillVolume / 27;
                dblVolCut  = dblVolCut + objSurfaceCUT.GetVolumeProperties().UnadjustedCutVolume / 27;
                dblVolFill = dblVolFill + objSurfaceCUT.GetVolumeProperties().UnadjustedFillVolume / 27;
            }

            string strPath     = BaseObjs.docFullName;
            string strJN       = BaseObjs.jobNumber();
            string strFN       = string.Format("{0}EW.xlsx", strJN);
            string strFullPath = strPath + "\\" + strFN;

            SelectionSet objSSet = EW_Utility1.buildSSet8();

            objSSet.eraseSelectedItems();

            objSSet = EW_Utility1.buildSSetTable();
            Table objTable = (Table)objSSet.GetObjectIds()[0].getEnt();

            Point3d varPntIns = objTable.Position;

            double dblWidth  = objTable.Width;
            double dblHeight = objTable.Height;

            double dblPntX = varPntIns.X + dblWidth + 10;
            double dblPntY = varPntIns.Y - 8;

            string strPntX = System.Math.Round(dblPntX, 2).ToString();
            string strPntY = System.Math.Round(dblPntY, 2).ToString();

            string strPntIns = string.Format("{0},{1}", strPntX, strPntY);

            Excel._Application objExcelApp = (Excel._Application)Microsoft.VisualBasic.Interaction.GetObject(null, "Excel.Application");
            Excel.Workbook     objWB       = null;
            Excel_ext          excl        = null;

            if (objExcelApp == null)
            {
                excl        = new Excel_ext();
                objExcelApp = excl.excelAPP;
            }
            else
            {
                for (int i = 1; i < objExcelApp.Workbooks.Count; i++)
                {
                    objWB = objExcelApp.Workbooks[i];
                    if (objWB.Name == strFN)
                    {
                        boolIsOpen = true;
                        break;
                    }
                }
            }

            objExcelApp.Visible = true;


            if (!boolIsOpen)
            {
                if (FileSystem.FileExists(strFullPath))
                {
                    objWB = objExcelApp.Workbooks.Open(strFullPath);
                }
                else
                {
                    FileSystem.CopyFile("R:\\TSet\\Template\\EARTHWORK\\0000EW.xlsx", strFullPath);
                    objWB = objExcelApp.Workbooks.Open(strFullPath);
                    string mess = string.Format("{0} not found.  A copy of the template has been created in {1}\nExiting...", strFN, strPath);
                    MessageBox.Show(mess);
                }
            }

            Excel.Worksheet objWS = objWB.Worksheets["SUMMARY"];
            objWS.Activate();
            objWS.Visible = Microsoft.Office.Interop.Excel.XlSheetVisibility.xlSheetVisible;

            objWS.Range["SUMMARY!volCUT"].Value     = dblVolCut;
            objWS.Range["SUMMARY!volFILL"].Value    = dblVolFill;
            objWS.Range["SUMMARY!JOB_NUMBER"].Value = BaseObjs.docName.Substring(1, 4);
            objWS.Range["EW_SUMMARY"].Copy();
            objExcelApp.Visible = true;

            BaseObjs._editor.Regen();

            BaseObjs._acadDoc.SendStringToExecute(string.Format("_pasteclip {0}\r", strPntIns), true, false, false);

            objSSet = EW_Utility1.buildSSet8();

            Autodesk.AutoCAD.DatabaseServices.Ole2Frame objAcadOle = null;
            if (objSSet == null || objSSet.Count == 0)
            {
                SelectionSet ss = BaseObjs._editor.SelectAll().Value;
                int          k  = ss.Count;
                ObjectId     id = ss.GetObjectIds()[k - 1];
                using (var tr = BaseObjs.startTransactionDb())
                {
                    objAcadOle            = (Ole2Frame)tr.GetObject(id, OpenMode.ForWrite);
                    objAcadOle.LockAspect = false;
                    objAcadOle.WcsHeight  = dblHeight;
                    objAcadOle.WcsWidth   = dblHeight / 2;
                    objAcadOle.Layer      = "ZZ_ZZ-SPREADSHEET";
                    tr.Commit();
                }
            }
            else
            {
                using (var tr = BaseObjs.startTransactionDb()){
                    objAcadOle            = (Ole2Frame)tr.GetObject(objSSet.GetObjectIds()[0], OpenMode.ForWrite);
                    objAcadOle.LockAspect = false;
                    objAcadOle.WcsHeight  = dblHeight;
                    objAcadOle.WcsWidth   = dblHeight / 2;
                    objAcadOle.Layer      = "ZZ_ZZ-SPREADSHEET";
                }
            }

            BaseObjs.acadActivate();
        }