Esempio n. 1
0
        setupSpreadSheetPS(string strFullPath, double dblHeight)
        {
            string strPath = BaseObjs.docFullName;
            string strJN   = BaseObjs.jobNumber();
            string strFN   = string.Format("{0}EW.xlsx", strJN);

            string strPntX = "24";
            string strPntY = "6";

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

            Excel_ext excl = new Excel_ext(true);

            excl.OpenFile(strFullPath, "");
            excl.FindExcelWorksheet("SUMMARY");
            Excel._Worksheet objWS = excl.excelWrkSht;

            objWS.Range["EW_SUMMARY"].Copy();
            excl.excelAPP.Visible = false;

            BaseObjs._acadDoc.SendStringToExecute(string.Format("_pasteclip {0}\r", strPntIns), true, false, false);
            SelectionSet ss = BaseObjs._editor.SelectAll().Value;
            int          k  = ss.Count;
            ObjectId     id = ss.GetObjectIds()[k - 1];

            using (var tr = BaseObjs.startTransactionDb()){
                Autodesk.AutoCAD.DatabaseServices.Ole2Frame objAcadOle = (Ole2Frame)tr.GetObject(id, OpenMode.ForWrite);
                objAcadOle.LockAspect = false;
                objAcadOle.WcsHeight  = dblHeight;
                objAcadOle.WcsWidth   = dblHeight / 2;
                tr.Commit();
            }
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        getExcelData()
        {
            ObjectId[] ids  = default(ObjectId[]);
            Polyline   poly = default(Polyline);

            try
            {
                SelectionSet objSSet = EW_Utility1.buildSSetGradingLim();
                switch (objSSet.Count)
                {
                case 0:
                    MessageBox.Show("0 Items found on layer GRADING LIMIT - Exiting...");
                    break;

                case 1:
                    poly         = (Polyline)objSSet.GetObjectIds()[0].getEnt();
                    dblAREA_SITE = poly.Area;
                    break;

                default:
                    ids = objSSet.GetObjectIds();
                    for (int i = 0; i < ids.Length; i++)
                    {
                        poly          = (Polyline)ids[i].getEnt();
                        dblAREA_SITE += poly.Area;
                    }
                    break;
                }

                objSSet = EW_Utility1.buildSSetTable();
                Autodesk.AutoCAD.DatabaseServices.Table objTable = (Table)objSSet.GetObjectIds()[0].getEnt();
                if (p.OX_LIMIT_H == 0)
                {
                    p.OX_LIMIT_H = double.Parse(objTable.Cells[20, 1].Value.ToString());
                }

                objSSet = EW_Utility1.buildSSet9();
                ids     = objSSet.GetObjectIds();
                for (int i = 0; i < ids.Length; i++)
                {
                    ObjectId idOff = ids[i].offset(p.OX_LIMIT_H);

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

                Excel_ext excl = new Excel_ext();
                Microsoft.Office.Interop.Excel.Workbook  objWB;
                Microsoft.Office.Interop.Excel.Worksheet objWS;

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

                excl.OpenFile(strFullPath, "");
                objWB = excl.excelWB;

                objWS = objWB.Worksheets["SUMMARY"];
                objWS.Activate();

                //objWS.Range("SUMMARY!AREA_SITE").Value = dblAREA_SITE

                //Try
                //    objRange = objWS.Range("SUMMARY!AREA_PAD")
                //Catch ex As Exception
                //End Try

                //If (objRange Is Nothing) Then
                //    objRange = objWS.Range("C7")
                //    objRange.Name = "AREA_PAD"
                //End If

                //objRange.Value = Format(dblAREA_PAD, "###,###.00")

                dblSHRINKAGE_FACTOR = objWS.Range["SUMMARY!shrinkageFactor"].Text;

                double lngVolCut  = objWS.Range["SUMMARY!volCUT"].Value;
                double lngVolFill = objWS.Range["SUMMARY!volFILL"].Value;

                double lngVolCutAdj = objWS.Range["SUMMARY!adjCUT"].Value;

                double dblVolCutShrink = lngVolCut * dblSHRINKAGE_FACTOR;

                dblVOL_CUT_ADJ_NET = lngVolCutAdj - (lngVolCut - dblVolCutShrink);//Net adjustment

                dblVOL_FILL_ADJ_NET = 0;

                excl.CloseFile(true, strFullPath, false);
            }
            catch (Exception)
            {
                MessageBox.Show("Error in getExcelData");
                return(false);
            }
            return(true);
        }
Esempio n. 4
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();
        }
Esempio n. 5
0
        addExcelWorkbook()
        {
            string strPath     = BaseObjs.docFullName;
            string strJN       = BaseObjs.jobNumber();
            string strFN       = string.Format("{0}EW.xlsx", strJN);
            string strFullPath = string.Format("{0}\\{1}", Path.GetDirectoryName(strPath), strFN);
            string mess        = string.Format("{0} exists. Overwrite existing file? Y/N", strFN);

            if (FileSystem.FileExists(strFullPath))
            {
                DialogResult varResponse = MessageBox.Show(mess, "File exists!", MessageBoxButtons.YesNo);

                switch (varResponse)
                {
                case DialogResult.Yes:

                    try {
                        FileSystem.DeleteFile(strFullPath);
                    } catch (Exception) {
                        MessageBox.Show("Error deleting existing file - good luck");
                        return;
                    }

                    FileSystem.CopyFile("R:\\TSet\\Template\\EARTHWORK\\0000EW.xlsx", strFullPath);
                    mess = string.Format("{0} created in {1} folder.", strFN, strPath);
                    MessageBox.Show(mess);

                    break;

                case DialogResult.No:

                    break;                            //do nothing
                }
            }
            else
            {
                FileSystem.CopyFile("R:\\TSet\\Template\\EARTHWORK\\0000EW.xlsx", strFullPath);
                mess = string.Format("{0} created in {1} folder.", strFN, strPath);
                MessageBox.Show(mess);
            }

            Excel_ext excl = new Excel_ext(true);

            excl.OpenFile(strFullPath, "");
            excl.FindExcelWorksheet("SUMMARY");
            Excel._Worksheet objWS = excl.excelWrkSht;

            ProjectData varProjectData = Misc.getProjectData(strJN);

            if (varProjectData.Name.ToString() != string.Empty)
            {
                objWS.Range["SUMMARY!SITE_NAME"].Value = varProjectData.Name;
                objWS.Range["SUMMARY!LOCATION"].Value  = varProjectData.Location;
                objWS.Range["SUMMARY!CLIENT"].Value    = varProjectData.Client;

                objWS.Range["SUMMARY!JOB_NUMBER"].Value  = varProjectData.Number;
                objWS.Range["SUMMARY!COORDINATOR"].Value = varProjectData.Coordinator;
                objWS.Range["SUMMARY!SOURCE"].Value      = BaseObjs.docName;
            }

            double dblAreaPad = 0;
            int    intCount   = 0;

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

            if (EW_Pub.OX_LIMIT_H == 0)
            {
                EW_Pub.OX_LIMIT_H = double.Parse(objTable.Cells[20, 1].Value.ToString());
            }

            objSSet = EW_Utility1.buildSSetBLDG_LIM();

            foreach (ObjectId idBldgLim in objSSet.GetObjectIds())
            {
                ObjectId idBldgLimOffset = idBldgLim.offset(EW_Pub.OX_LIMIT_H);

                if ((idBldgLimOffset.IsNull))
                {
                    intCount++;
                }
                else
                {
                    dblAreaPad = dblAreaPad + idBldgLimOffset.getArea();
                    idBldgLimOffset.delete();
                }
            }

            if (intCount > 0)
            {
                MessageBox.Show(string.Format("{0} Building Limit Area(s) failed.  Requires manual calculation.", intCount));
            }

            objWS.Range["SUMMARY!AREA_PAD"].Value = (int)dblAreaPad;

            double   dblAreaSite   = 0;
            Polyline objGradingLim = default(Polyline);

            objSSet       = EW_Utility1.buildSSetGradingLim();
            objGradingLim = (Polyline)objSSet.GetObjectIds()[0].getEnt();
            dblAreaSite   = objGradingLim.Area;

            objWS.Range["SUMMARY!AREA_SITE"].Value = (int)dblAreaSite;

            excl.CloseFile(true, strFullPath, false);
        }
Esempio n. 6
0
        setupCutSheet(List <string> strLayers)
        {
            string strProjNum = BaseObjs.jobNumber();

            string strDate = String.Format("{0}", DateTime.Today);

            string strFileName = string.Format("{0}_CutSheet{1}_{2}", strProjNum, strLayers, strDate);

            Microsoft.Office.Interop.Word.Document objCutSheet   = makeCutSheet(strFileName);
            Microsoft.Office.Interop.Word.Table    objWordTable1 = objCutSheet.Tables[1];

            Microsoft.Office.Interop.Word.Cell objCell = objWordTable1.Cell(6, 4);
            objCell.Range.InsertBefore(Convert.ToString(DateTime.Today));

            objCell = objWordTable1.Cell(7, 4);

            objCell.Range.InsertBefore(strProjNum);

            ProjectData varProjectData = Stake_GetProjectData.getProjectData(strProjNum);

            objCell = objWordTable1.Cell(8, 2);
            objCell.Range.InsertBefore(varProjectData.Name);

            objCell = objWordTable1.Cell(9, 2);
            objCell.Range.InsertBefore(varProjectData.Location);

            objCell = objWordTable1.Cell(10, 2);
            objCell.Range.InsertBefore(varProjectData.Coordinator);

            string strUserName = "";

            string strUser = Environment.UserName;

            switch (strUser)
            {
            case "john":
                strUserName = "******";
                break;

            case "luis":
                strUserName = "******";
                break;

            case "brianp":
                strUserName = "******";
                break;

            case "michael":
                strUserName = "******";
                break;

            case "briant":
                strUserName = "******";
                break;

            default:
                strUserName = strUser;
                break;
            }

            objCell = objWordTable1.Cell(9, 4);
            objCell.Range.InsertBefore(strUserName);

            return(objCutSheet);
        }
Esempio n. 7
0
        doCadOUT(string cmdName)
        {
            Object pickf = null;

            try
            {
                Document doc = BaseObjs._acadDoc;
                doc.save();
                pickf = Autodesk.AutoCAD.ApplicationServices.Core.Application.GetSystemVariable("PICKFIRST");

                Autodesk.AutoCAD.ApplicationServices.Core.Application.SetSystemVariable("PICKFIRST", 1);
                Autodesk.AutoCAD.ApplicationServices.Core.Application.SetSystemVariable("FILEDIA", 0);

                BaseObjs.sendCommand("plan w\r");

                DateTime dt = DateTime.Now;

                string path0   = BaseObjs.docFullName;
                string nameDwg = Path.GetFileName(path0);

                if (nameDwg.Substring(0, 1) == "$")
                {
                    DialogResult dr = MessageBox.Show("Temporary file is active.  Proceed?", "CADOUT", MessageBoxButtons.YesNo);
                    if (dr == DialogResult.No)
                    {
                        return;
                    }
                }
                string nameDir = Path.GetDirectoryName(path0);

                int numJob = int.Parse(BaseObjs.jobNumber(nameDwg));

                string path1 = "", path2 = "", path3 = "";

                if (nameDir.Substring(0, 1) == "N")
                {
                    if (numJob > 2599 && numJob < 2700)
                    {
                        path1 = string.Format("{0}\\EMAILOUT", path0.Substring(0, 17));
                        path2 = string.Format("{0}\\EMAIL-OUT", path1.Substring(0, 17));
                        path3 = string.Format("{0}\\EMAIL OUT", path1.Substring(0, 17));
                    }
                    else
                    {
                        path1 = string.Format("{0}\\EMAILOUT", path0.Substring(0, 7));
                        path2 = string.Format("{0}\\EMAIL-OUT", path1.Substring(0, 7));
                        path3 = string.Format("{0}\\EMAIL OUT", path1.Substring(0, 7));
                    }
                }
                else if (path0.Substring(0, 1) == "O")
                {
                    path1 = string.Format("{0}\\EMAILOUT", path0.Substring(0, 17));
                    path2 = string.Format("{0}\\EMAIL-OUT", path1.Substring(0, 17));
                    path3 = string.Format("{0}\\EMAIL OUT", path1.Substring(0, 17));
                }
                else
                {
                    path1 = string.Format("{0}\\EMAILOUT", path0.Substring(0, 7));
                    path2 = string.Format("{0}\\EMAIL-OUT", path1.Substring(0, 7));
                    path3 = string.Format("{0}\\EMAIL OUT", path1.Substring(0, 7));
                }

                bool fldr1 = Directory.Exists(path1);
                bool fldr2 = Directory.Exists(path2);
                bool fldr3 = Directory.Exists(path3);

                string nameTmp = "";
                string nameOut = "";
                string date    = string.Format("{0}-{1:00}-{2:00}", dt.Year, dt.Month, dt.Day);

                if (fldr1)
                {
                    if (!Directory.Exists(path1 + "\\" + date))
                    {
                        Directory.CreateDirectory(path1 + "\\" + date);
                    }

                    nameTmp = path1 + "\\" + date + "\\$" + nameDwg;
                    nameOut = path1 + "\\" + date + "\\" + nameDwg.Substring(0, nameDwg.Length - 4) + "_out.dwg";
                }
                else if (fldr2)
                {
                    if (!Directory.Exists(path2 + "\\" + date))
                    {
                        Directory.CreateDirectory(path2 + "\\" + date);
                    }
                    nameTmp = path2 + "\\" + date + "\\$" + nameDwg;
                    nameOut = path2 + "\\" + date + "\\" + nameDwg.Substring(0, nameDwg.Length - 4) + "_out.dwg";
                }
                else if (fldr3)
                {
                    if (!Directory.Exists(path3 + "\\" + date))
                    {
                        Directory.CreateDirectory(path3 + "\\" + date);
                    }
                    nameTmp = path3 + "\\" + date + "\\$" + nameDwg;
                    nameOut = path3 + "\\" + date + "\\" + nameDwg.Substring(0, nameDwg.Length - 4) + "_out.dwg";
                }
                else
                {
                    Directory.CreateDirectory(path1 + "\\" + date);
                    nameTmp = path1 + "\\" + date + "\\$" + nameDwg;
                    nameOut = path1 + "\\" + date + "\\" + nameDwg.Substring(0, nameDwg.Length - 4) + "_out.dwg";
                }

                bool fileExists = File.Exists(nameTmp);

                if (fileExists)                 //file exists - so delete and saveas
                {
                    File.Delete(nameTmp);
                    doc.saveas(nameTmp);
                }
                else                 //folder exists; file doesn't exist
                {
                    doc.saveas(nameTmp);
                }

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

                Dict.deleteDictionary("SearchDict");
                Dict.deleteDictionary("ObjectDict");

                if (cmdName == "cmdCOUT")
                {
                    doCleanup1();
                }
                if (cmdName == "cmdCOUTX")
                {
                    doCleanup2();
                }

                fileExists = File.Exists(nameOut);

                if (fileExists)                 //file exists - so delete and saveas
                {
                    File.Delete(nameOut);
                    doc.saveas(nameOut);
                }
                else                 //folder exists; file doesn't exist
                {
                    doc.saveas(nameOut);
                }

                File.Delete(nameTmp);

                MessageBox.Show(string.Format("File created at: {0}", nameOut), "FILE CREATED", MessageBoxButtons.OK);
            }
            catch (System.Exception ex)     {
                BaseObjs.writeDebug(string.Format("{0} CadOUT.cs: line: 180", ex.Message));
            }
            finally {
                Autodesk.AutoCAD.ApplicationServices.Core.Application.SetSystemVariable("PICKFIRST", pickf);
                Autodesk.AutoCAD.ApplicationServices.Core.Application.SetSystemVariable("FILEDIA", 1);
            }
        }