Exemplo n.º 1
0
        private void cmdMakeAlign_Click(object sender, EventArgs e)
        {
            BaseObjs.acadActivate();
            bool addCurves = false;

            if (cbxAddCurves.Checked)
            {
                addCurves = true;
            }

            nameLayer = string.Format("{0}-{1}-{2}", tbxType.Text, cbxLineLat.SelectedItem.ToString().ToUpper(), tbxIndex.Text);
            idLayer   = Layer.manageLayers(nameLayer);

            nameStyle      = cbxAlignStyle.SelectedItem.ToString();
            nameStyleLabel = cbxAlignLabelSetStyles.SelectedItem.ToString();

            string nameAlign = MNP_Align.makeAlign(nameLayer, nameLayer, nameStyle, nameStyleLabel, addCurves);

            ToolStripStatusLabel1.Text = string.Format("ACTIVE ALIGNMENT: {0}", nameAlign);
            int    idx   = 0;
            string index = tbxIndex.Text;

            if (index.isInteger(out idx))
            {
                idx  += 1;
                index = idx.ToString();
            }
            else
            {
                index.getStringIncrement();
            }

            tbxIndex.Text = index;
        }
Exemplo n.º 2
0
        private void gotoPoint(Button btn)
        {
            Entity entX = null;

            using (BaseObjs._acadDoc.LockDocument())
            {
                Handle h = btn.Content.ToString().stringToHandle();
                entX = h.getEnt();

                pnt = (CogoPoint)entX;
                Point3d         pnt3dIns = pnt.Location;
                ViewTableRecord vtr      = new ViewTableRecord();
                vtr.CenterPoint = new Point2d(pnt3dIns.X, pnt3dIns.Y);
                vtr.Height      = 30;
                vtr.Width       = 50;
                BaseObjs._editor.SetCurrentView(vtr);

                pnt.Highlight();
                BaseObjs.acadActivate();

                ObjectId[] idsPntArr = new ObjectId[] { pnt.ObjectId };

                List <ObjectId> idPnt = Base_Tools45.Select.getEntityatPoint(pnt3dIns, typeof(CogoPoint), "*");
                ed.SelectionAdded += ed_SelectionAdded;
                proceed            = true;
            }
        }
Exemplo n.º 3
0
        private void cmdProfileView_Click(object sender, EventArgs e)
        {
            BaseObjs.acadActivate();

            idProfileBandSetStyle = Prof_Style.getProfileViewBandSetStyle();

            if (cbxProfileStyleDE.SelectedIndex == -1)
            {
                Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("Please select Profile Style: ");
                return;
            }

            if (cbxProfileViewStyle.SelectedIndex == -1)
            {
                Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("Please select Profile View Style: ");
                return;
            }

            idProfileStyleDE    = Prof_Style.getProfileStyle(cbxProfileStyleDE.SelectedItem.ToString());
            idProfileStyleEX    = Prof_Style.getProfileStyle(cbxProfileStyleEX.SelectedItem.ToString());
            idProfileLabelSetDE = Prof_Style.getProfileLabelSetStyle(cbxProfileLabelSetDE.SelectedItem.ToString());
            idProfileLabelSetEX = Prof_Style.getProfileLabelSetStyle(cbxProfileLabelSetEX.SelectedItem.ToString());
            idProfileViewStyle  = Prof_Style.getProfileViewStyle(cbxProfileViewStyle.SelectedItem.ToString());

            idProfileView = MNP_Profile.makeProfile(idAlign);
        }
Exemplo n.º 4
0
        private void cmdGetNumeric_Click(System.Object eventSender, System.EventArgs eventArgs)
        {
            BaseObjs.acadActivate();
            Entity  ent         = null;
            Point3d pnt3dPicked = Pub.pnt3dO;

            try
            {
                string msg = string.Format("\nSelect the {0}1{1} grid line:\n", 34.asciiToString(), 34.asciiToString());
                ent = Base_Tools45.Select.selectEntity(typeof(Line), msg, "", out pnt3dPicked);
                if (ent == null)
                {
                    return;
                }
            }
            catch (System.Exception)
            {
                return;
            }

            Line  objGridNumeric1 = (Line)ent;
            Color color           = new Color();

            color = Color.FromColorIndex(Autodesk.AutoCAD.Colors.ColorMethod.ByBlock, 3);
            objGridNumeric1.ObjectId.changeProp(LineWeight.ByLayer, color);

            GRIDNUMERIC.Add(objGridNumeric1.Handle);
            int i = objGridNumeric1.Layer.IndexOf("GRID");

            string strName = objGridNumeric1.Layer.Substring(i);

            Stake_Grid.setupGrid(objGridNumeric1.ObjectId, strName, "NUMERIC");

            Stake_Dict.updateDictGRIDsWithBldgName(GRIDNUMERIC, strName, "NUMERIC");
        }
Exemplo n.º 5
0
        private void cmdGridAdd_Click(System.Object eventSender, System.EventArgs eventArgs)
        {
            BaseObjs.acadActivate();

            ObjectId idLineX   = Stake_Grid.addToGroup();
            string   nameLayer = idLineX.getLayer();

            int    i    = nameLayer.IndexOf("GRID");
            string name = nameLayer.Substring(i);

            ResultBuffer rb = idLineX.getXData("GRID");

            if (rb == null)
            {
                return;
            }
            TypedValue[] tvs    = rb.AsArray();
            int          result = 0;
            string       typ    = "";

            if (tvs[1].Value.ToString().isInteger(out result))
            {
                GRIDNUMERIC.Add(idLineX.getHandle());
                typ = "NUMERIC";
            }
            else
            {
                GRIDALPHA.Add(idLineX.getHandle());
                typ = "ALPHA";
            }

            Stake_Dict.updateDictGRIDs(name, typ, "ADD", idLineX, idLineX.getHandle().ToString());
        }
Exemplo n.º 6
0
        CreateProfileViewPrelim(Alignment objAlign)
        {
            ObjectId id = ObjectId.Null;

            ProfileView objProfileView      = null;
            ObjectId    idPViewStyle        = ObjectId.Null;
            ObjectId    idPViewBandSetStyle = ObjectId.Null;

            Debug.Print("CreateProfileViewPrelim - Line 28");


            try {
                idPViewStyle        = Prof_Style.getProfileViewStyle("WALL");
                idPViewBandSetStyle = Prof_Style.getProfileViewBandSetStyle("WALL");
            } catch (Autodesk.AutoCAD.Runtime.Exception) {
                idPViewStyle        = Prof_Style.getProfileViewStyle("Standard");
                idPViewBandSetStyle = Prof_Style.getProfileViewBandSetStyle("Standard");
            }

            PromptStatus ps       = default(PromptStatus);
            Point3d      pnt3dIns = default(Point3d);

            try {
                BaseObjs.acadActivate();
                pnt3dIns = UserInput.getPoint("Select insertion point for Profile View", out ps, osMode: 0);
            } catch (Autodesk.AutoCAD.Runtime.Exception) {
                objAlign.Erase();
                return(ObjectId.Null);
            }

            string strLayer = string.Format("{0}-PROFILEVIEW", objAlign.Name);

            Layer.manageLayers(strLayer);

            Debug.Print("CreateProfileViewPrelim - Line 74");


            try {
                objProfileView = Prof.addProfileView(objAlign.ObjectId, pnt3dIns, idPViewBandSetStyle, idPViewStyle);
            } catch (Autodesk.AutoCAD.Runtime.Exception ex) {
                Application.ShowAlertDialog(ex.ToString());
            }

            TypedValue[] tvs = new TypedValue[2] {
                new TypedValue(1001, "WALLDESIGN"),
                new TypedValue(1005, objProfileView.Handle)
            };

            objProfileView.ObjectId.setXData(tvs, "WALLDESIGN");

            tvs = new TypedValue[2] {
                new TypedValue(1001, "BRKLINE"),
                new TypedValue(1005, 0)
            };

            objProfileView.ObjectId.setXData(tvs, "BRKLINE");

            return(objProfileView.ObjectId);
        }
Exemplo n.º 7
0
        private void cmdGridDelete_Click(System.Object eventSender, System.EventArgs eventArgs)
        {
            BaseObjs.acadActivate();

            Point3d pnt3d = Pub.pnt3dO;
            Entity  ent   = Base_Tools45.Select.selectEntity(typeof(Line), "Select Grid LINE to delete:", "", out pnt3d);

            if (ent == null)
            {
                return;
            }

            Line objLineX = (Line)ent;

            int    n       = objLineX.Layer.IndexOf("GRID");
            string strName = objLineX.Layer.Substring(n);

            ResultBuffer rb = objLineX.ObjectId.getXData("GRID");

            TypedValue[] tvs = rb.AsArray();

            string strType = "";
            string strVal  = tvs[1].Value.ToString();
            int    res     = 0;

            if (strVal.isInteger(out res))
            {
                strType = "NUMERIC";

                for (int i = 1; i <= GRIDNUMERIC.Count; i++)
                {
                    if (objLineX.Handle == GRIDNUMERIC[i])
                    {
                        GRIDNUMERIC.RemoveAt(i);
                    }
                }
            }
            else
            {
                strType = "ALPHA";

                for (int i = 1; i <= GRIDALPHA.Count; i++)
                {
                    if (objLineX.Handle == GRIDALPHA[i])
                    {
                        GRIDALPHA.RemoveAt(i);
                    }
                }
            }

            Stake_Dict.updateDictGRIDs(strName, strType, "DELETE", objLineX.ObjectId, objLineX.Handle.ToString());

            objLineX.ObjectId.delete();
        }
Exemplo n.º 8
0
 private void cmdGradeDock_Click(object sender, System.Windows.RoutedEventArgs e)
 {
     BaseObjs.acadActivate();
     try
     {
         Base_Tools45.Grading_Dock.gradeDock(Convert.ToDouble(txtDockWidth.Text), Convert.ToDouble(lbxWallThickness.SelectedValue));
     }
     catch (System.Exception ex)
     {
         BaseObjs.writeDebug(string.Format("{0} GradeDock.xaml.cs: line: 54", ex.Message));
     }
 }
Exemplo n.º 9
0
 private void cmdGetDockLimits_Click(object sender, System.Windows.RoutedEventArgs e)
 {
     BaseObjs.acadActivate();
     try
     {
         Base_Tools45.Grading_Dock.getDockLimits(int.Parse(lbxDockCount.SelectedValue.ToString()));
     }
     catch (System.Exception ex)
     {
         BaseObjs.writeDebug(string.Format("{0} GradeDock.xaml.cs: line: 41", ex.Message));
     }
 }
Exemplo n.º 10
0
        printPntDictionary()
        {
            BaseObjs.acadActivate();

            ObjectId idCogoPnt = Base_Tools45.C3D.CgPnt.selectPointEntity("", osMode: 8);

            bool     exists  = false;
            ObjectId idDictM = Dict.getNamedDictionary(apps.lnkBrks3, out exists);

            ObjectId idDictPnt = Dict.getSubEntry(idDictM, idCogoPnt.getHandle().ToString());

            if (idDictPnt == ObjectId.Null)
            {
                Autodesk.AutoCAD.ApplicationServices.Core.Application.ShowAlertDialog("Point does not have a Dictionary");
                return;
            }

            List <DBDictionaryEntry> entries = idDictPnt.getDictEntries();

            if (entries.Count == 0)
            {
                Autodesk.AutoCAD.ApplicationServices.Core.Application.ShowAlertDialog("Point Dictionary is empty.");
                return;
            }

            string output = string.Empty;

            foreach (DBDictionaryEntry entry in entries)
            {
                ObjectId idDictX = Dict.getSubEntry(idDictPnt, entry.Key);

                ResultBuffer rb2 = Dict.getXRec(idDictX, "Offset");
                TypedValue[] tvs = rb2.AsArray();
                output = string.Format("{0}  Offset: {1}", entry.Key, tvs[0].Value.ToString());

                rb2    = Dict.getXRec(idDictX, "DeltaZ");
                tvs    = rb2.AsArray();
                output = string.Format("{0}\r{1}  DeltaZ: {2}", output, entry.Key, tvs[0].Value.ToString());

                rb2    = Dict.getXRec(idDictX, "HandleFL");
                tvs    = rb2.AsArray();
                output = string.Format("{0}\r{1}  HandleFL: {2}", output, entry.Key, tvs[0].Value.ToString());

                rb2    = Dict.getXRec(idDictX, "Beg");
                tvs    = rb2.AsArray();
                output = string.Format("{0}\r{1}  Begin Sta.: {2}", output, entry.Key, tvs[0].Value.ToString());

                rb2    = Dict.getXRec(idDictX, "End");
                tvs    = rb2.AsArray();
                output = string.Format("{0}\r{1}  End Sta.: {2}", output, entry.Key, tvs[0].Value.ToString());
                MessageBox.Show(output);
            }
        }
Exemplo n.º 11
0
        addEntToList()
        {
            BaseObjs.acadActivate();
            string  layer       = "";
            Point3d pnt3dPicked = Pub.pnt3dO;
            Entity  ent         = Base_Tools45.Select.selectEntity(typeof(Entity), "Select Entity (to get layer)", "No Entity Selected. Exiting... ", out pnt3dPicked);

            if (ent != null)
            {
                layer = ent.Layer;
            }
            return(layer);
        }
Exemplo n.º 12
0
        selectAlign(string message, string reject, out Point3d pnt3dPicked, out string nameAlign)
        {
            ObjectId idAlign = ObjectId.Null;

            BaseObjs.acadActivate();
            PromptEntityOptions peos = new PromptEntityOptions(message);

            peos.SetRejectMessage(reject);
            peos.AddAllowedClass(typeof(Alignment), false);
            peos.AllowNone = false;
            nameAlign      = string.Empty;

            PromptEntityResult per = BaseObjs._editor.GetEntity(peos);

            pnt3dPicked = per.PickedPoint;

            switch (per.Status)
            {
            case PromptStatus.Cancel:
            case PromptStatus.Error:
                break;

            case PromptStatus.OK:

                try
                {
                    using (Transaction tr = BaseObjs.startTransactionDb())
                    {
                        Alignment align = (Alignment)tr.GetObject(per.ObjectId, OpenMode.ForRead);
                        nameAlign = align.Name;
                        idAlign   = align.ObjectId;
                        tr.Commit();
                    }
                }
                catch (System.Exception ex)
                {
                    BaseObjs.writeDebug(string.Format("{0} Align.cs: line: 256", ex.Message));
                }
                break;
            }
            return(idAlign);
        }
Exemplo n.º 13
0
        private void cmdSelectGrid_Click(System.Object eventSender, System.EventArgs eventArgs)
        {
            BaseObjs.acadActivate();
            bool   escape;
            string xRefPath = "";
            Entity obj      = xRef.getEntity("Select feature to stake:", out escape, out xRefPath);

            ObjectId idGuideline = ObjectId.Null;

            if (obj.GetType().Name != "Line")
            {
                Application.ShowAlertDialog("Grid Lines need to be simple Acad Lines, not Polylines, etc. - exiting...");
                return;
            }
            else
            {
                idGuideline = Stake_GetGuidelines.getGuidelines(obj);

                string strLayerName = idGuideline.getLayer();

                int intPos = strLayerName.IndexOf("|");
                strLayerName = strLayerName.Substring(intPos + 1);

                if (!Stake_Main.testClass("BLDG", strLayerName))
                {
                    return;
                }

                Stake_Forms.sForms.fStake.NameStakeObject = strLayerName;
            }

            Stake_GetNestedObjects.copyGRID((Stake_Forms.sForms.fStake.XRefDbModelSpace));//XrefDbModelSpace is source of grid selected

            idGuideline.delete();

            Stake_Forms.sForms.fStake.Hide();
            Application.ShowModelessDialog(Application.MainWindow.Handle, Stake_Forms.sForms.fGrid, false);
        }
Exemplo n.º 14
0
        private void cmdSetPoint_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            boolSetPointAtCenter = false;
            bool escape = true;

            Point3d pnt3dTAR = Pub.pnt3dO;

            BaseObjs.acadActivate();
            Object osMode = SnapMode.getOSnap();

            SnapMode.setOSnap((int)osModes.PER);

            double slope = Convert.ToDouble(cmbSlope.SelectedValue);

            if (slope != 0.0)
            {
                pnt3dTAR = Grading_Floor.getPoint("Select Building Edge in Direction of Increasing Slope", Centroid, out escape);
            }

            Grading_Floor.AVG(idBldgLim, Centroid, slope, Convert.ToDouble(txtPadElev.Text), boolSetPointAtCenter, pnt3dTAR);
            idBldgLim.delete();
            SnapMode.setOSnap((int)osMode);
        }
Exemplo n.º 15
0
 private void btnSelPnts_Click(object sender, System.Windows.RoutedEventArgs e)
 {
     if ((bool)tp1.IsChecked)
     {
         using (BaseObjs._acadDoc.LockDocument())
         {
             BaseObjs.acadActivate();
             BaseObjs._acadDoc.SendStringToExecute("TP1\r", true, false, false);
         }
         //-----------------------------------------------------------------------------------------------------------
     }
     else if ((bool)tp2.IsChecked)
     {
         using (BaseObjs._acadDoc.LockDocument())
         {
             BaseObjs.acadActivate();
             BaseObjs._acadDoc.SendStringToExecute("TP2\r", true, false, false);
         }
         //-----------------------------------------------------------------------------------------------------------
     }
     else if ((bool)tp3.IsChecked)
     {
         using (BaseObjs._acadDoc.LockDocument())
         {
             BaseObjs.acadActivate();
             BaseObjs._acadDoc.SendStringToExecute("TP3\r", true, false, false);
         }
     }
     else if ((bool)tp4.IsChecked)
     {
         using (BaseObjs._acadDoc.LockDocument())
         {
             BaseObjs.acadActivate();
             BaseObjs._acadDoc.SendStringToExecute("TP4\r", true, false, false);
         }
     }
 }
Exemplo n.º 16
0
        private void btnSelectBrklineEx_Click(System.Object sender, System.EventArgs e)
        {
            BaseObjs.acadActivate();

            ObjectId idPoly3d  = ObjectId.Null;
            string   strPrompt = null;

            strPrompt = "Select 3dPolyline Exist Reference:";

            try
            {
                Point3d    pnt3d  = Point3d.Origin;
                Polyline3d poly3d = (Polyline3d)Base_Tools45.Select.selectEntity(typeof(Polyline3d), strPrompt, "3dPolyline Selection failed.", out pnt3d);
                idPoly3d = poly3d.ObjectId;
            }
            catch (Autodesk.AutoCAD.Runtime.Exception)
            {
                return;
            }

            BRKLINE_EXIST_HANDLE = idPoly3d.Handle.ToString();
            ALGNENTDATA          = wd.getAlgnEntData(ACTIVEALIGN);
            List <staOffElev> sOffs = wd.convert3dPolyToPnt_Data(ACTIVEALIGN, ALGNENTDATA, idPoly3d, "EXIST");
        }
Exemplo n.º 17
0
 private void btn_BuildWallProfiles_Click(object sender, EventArgs e)
 {
     BaseObjs.acadActivate();
     wdl.wallDesignLimits(ACTIVEPROFILEVIEW, "WDE");
 }
Exemplo n.º 18
0
        cmdSections(ObjectId idAlign, double dblOffR, double dblOffL)
        {
            ObjectId idSectionStyleEXIST   = default(ObjectId);
            ObjectId idSectionStyleEXIST90 = default(ObjectId);
            ObjectId idSectionStyleCPNT    = default(ObjectId);
            ObjectId idSectionStyleSG      = default(ObjectId);
            ObjectId idSectionStyleOX      = default(ObjectId);
            ObjectId idSectionStyleOXg     = default(ObjectId);
            ObjectId idSectionStyleBOT     = default(ObjectId);
            ObjectId idSectionStyleMID     = default(ObjectId);

            ObjectIdCollection idsSurface = new ObjectIdCollection();

            bool     exists         = false;
            ObjectId idSurfaceEXIST = Surf.getSurface("EXIST", out exists);

            if (!exists)
            {
                Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("Surface EXIST is missing - exiting!");
                return;
            }
            else
            {
                idsSurface.Add(idSurfaceEXIST);
                idSectionStyleEXIST = Sect_Style.getSectionStyleId("EXIST");
            }

            ObjectId idSurfaceEXIST90 = Surf.getSurface("EXIST90", out exists);

            if (!exists)
            {
                //  MsgBox "Surface EXIST is missing - exiting!"
                //  Exit Sub
            }
            else
            {
                idsSurface.Add(idSurfaceEXIST90);
                idSectionStyleEXIST90 = Sect_Style.getSectionStyleId("EXIST90");
            }

            ObjectId idSurfaceCPNT = Surf.getSurface("CPNT-ON", out exists);

            if (!exists)
            {
                //  MsgBox "Surface CPNT-ON is missing - exiting!"
                //  Exit Sub
            }
            else
            {
                idsSurface.Add(idSurfaceCPNT);
                idSectionStyleCPNT = Sect_Style.getSectionStyleId("CPNT");
            }

            ObjectId idSurfaceSG = Surf.getSurface("SG", out exists);

            if (!exists)
            {
            }
            else
            {
                idsSurface.Add(idSurfaceSG);
                idSectionStyleSG = Sect_Style.getSectionStyleId("SG");
            }

            ObjectId idSurfaceOX = Surf.getSurface("OX", out exists);

            if (!exists)
            {
            }
            else
            {
                idsSurface.Add(idSurfaceOX);
                idSectionStyleOX = Sect_Style.getSectionStyleId("OX");
            }

            ObjectId idSurfaceOXg = Surf.getSurface("OXg", out exists);

            if (!exists)
            {
            }
            else
            {
                idsSurface.Add(idSurfaceOXg);
                idSectionStyleOXg = Sect_Style.getSectionStyleId("OXg");
            }

            ObjectId idSurfaceBOT = Surf.getSurface("BOT", out exists);

            if (!exists)
            {
            }
            else
            {
                idsSurface.Add(idSurfaceBOT);
                idSectionStyleBOT = Sect_Style.getSectionStyleId("BOT");
            }

            if (idSectionStyleBOT == ObjectId.Null)
            {
                EW_Utility1.copyEWstyles();
            }

            ObjectId idSurfaceMID = Surf.getSurface("MIDGRADE", out exists);

            if (!exists)
            {
            }
            else
            {
                idsSurface.Add(idSurfaceMID);
                idSectionStyleMID = Sect_Style.getSectionStyleId("EXIST90");
            }

            idAlign.removeSampleLineGroups();
            ObjectId idSLG = idAlign.addSampleLineGroupAndSampleLines("EW");

            idSLG.removeSampledSurfaces();

            idSLG.addSurfaceToSample(idsSurface);

            idAlign.addSections(idSLG, dblOffL, dblOffR);

            ObjectId idGroupPlotStyle             = ObjectId.Null;
            GroupPlotStyleCollection grpPltStyles = BaseObjs._civDoc.Styles.GroupPlotStyles;

            if (!grpPltStyles.Contains("EW"))
            {
                EW_Utility1.copyEWstyles();
                idGroupPlotStyle = BaseObjs._civDoc.Styles.GroupPlotStyles["EW"];
            }

            SampleLineStyleCollection sampleLineStyles = BaseObjs._civDoc.Styles.SampleLineStyles;
            ObjectId idSampleLineStyle = sampleLineStyles["Standard"];

            SectionLabelSetStyleCollection sectionLabelSetStyles = BaseObjs._civDoc.Styles.LabelSetStyles.SectionLabelSetStyles;

            double dblWidth  = 0;
            double dblHeight = 0;

            Autodesk.AutoCAD.DatabaseServices.Table objTable = default(Autodesk.AutoCAD.DatabaseServices.Table);

            SelectionSet objSSet = default(SelectionSet);

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

            Point3d varPntIns = objTable.Position;

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

            Point3d dblPntBase = new Point3d(varPntIns.X + dblWidth + 600, varPntIns.Y - dblHeight, 0);

            SectionViewStyle objSectionViewStyle = Sect_Style.getSectionViewStyle("EW");

            if (objSectionViewStyle == null)
            {
                EW_Utility1.copyEWstyles();
                objSectionViewStyle = objSectionViewStyle = Sect_Style.getSectionViewStyle("EW");
            }

            SectionViewBandSetStyle objSectionViewBandSetStyle = Sect_Style.getSectionViewBandSetStyle("Standard");

            double dblOffX = 0;
            double dblOffY = 0;

            bool boolFirstPass = false;

            boolFirstPass = true;

            dblOffX = 0;
            dblOffY = 0;

            Point3d dblPntIns = Pub.pnt3dO;

            int j = 0;
            ObjectIdCollection idsSampleLine = idSLG.getSampleLineIDs();

            using (var tr = BaseObjs.startTransactionDb()) {
                for (int i = 0; i < idsSampleLine.Count; i += 5)
                {
                    SampleLine sl = (SampleLine)tr.GetObject(idsSampleLine[i], OpenMode.ForRead);

                    dblPntIns = new Point3d(dblPntBase.X + i / 5 * dblOffX, dblPntBase.Y, 0);
                    int k = -1;

                    while (j < idsSampleLine.Count)
                    {
                        k = k + 1;

                        ObjectId    idSectionView  = SectionView.Create(string.Format("SV-{0}", j), sl.ObjectId, dblPntIns);
                        SectionView objSectionView = (SectionView)tr.GetObject(idSectionView, OpenMode.ForWrite);
                        if (boolFirstPass)
                        {
                            dblOffX       = System.Math.Abs(objSectionView.OffsetLeft) + objSectionView.OffsetRight + 30;
                            boolFirstPass = false;
                        }

                        Extents3d ext3d = (Extents3d)objSectionView.Bounds;

                        dblOffY = ext3d.MaxPoint.Y - ext3d.MinPoint.Y + 30;

                        dblPntIns      = new Point3d(dblPntIns.X, dblPntIns.Y + dblOffY, 0);//increment Y after placing first section in column
                        objSectionView = null;

                        j = j + 1;

                        if (k == 4)
                        {
                            break;
                        }
                    }
                }

                tr.Commit();
            }

            BaseObjs.acadActivate();

            return;
        }
Exemplo n.º 19
0
        public static Boolean SG(double slope, string surfTAR, string surfDES)
        {
            Boolean boolDoFirst = true;
            Boolean success     = false;

            List <Point3d> pnts3d   = new List <Point3d>();
            List <Point3d> pnts3dB1 = new List <Point3d>();
            List <Point3d> pnts3dB2 = new List <Point3d>();
            List <Point3d> pnts3dD  = new List <Point3d>();
            List <Point3d> pnts3dR  = new List <Point3d>();

            Point3d pnt3dA, pnt3dB, pnt3dC;

            BaseObjs.acadActivate();

            ObjectId idPoly3d = Select.getBrkLine("\nSelect 3D Polyline Reference: ");

            try
            {
                if (idPoly3d != ObjectId.Null)
                {
                    pnts3d = idPoly3d.getCoordinates3dList();
                    int intSide = SG_Utility.getSide(pnts3d);

                    if (pnts3d.Count > 2)
                    {
                        for (int i = 0; i < pnts3d.Count - 2; i++)
                        {
                            pnt3dA = pnts3d[i + 0];
                            pnt3dB = pnts3d[i + 1];
                            pnt3dC = pnts3d[i + 2];

                            success = setupSlope(intSide, pnt3dA, pnt3dB, pnt3dC, slope, ref boolDoFirst, surfTAR, surfDES, ref pnts3dB1, ref pnts3dB2, ref pnts3dD, ref pnts3dR);
                        }

                        pnt3dB = pnts3d[pnts3d.Count - 2];
                        pnt3dC = pnts3d[pnts3d.Count - 1];

                        success = setupSlope(intSide, pnt3dB, pnt3dC, slope, ref boolDoFirst, surfTAR, surfDES, ref pnts3dB1, ref pnts3dB2, ref pnts3dD, ref pnts3dR);
                    }
                    else
                    {
                        pnt3dA  = pnts3d[0];
                        pnt3dB  = pnts3d[1];
                        success = setupSlope(intSide, pnt3dA, pnt3dB, slope, ref boolDoFirst, surfTAR, surfDES, ref pnts3dB1, ref pnts3dB2, ref pnts3dD, ref pnts3dR);
                    }
                }
            }
            catch (SystemException)
            {
                success = false;
            }
            ObjectId           idPoly3dX  = ObjectId.Null;
            ObjectIdCollection idsPoly3dX = new ObjectIdCollection();

            using (BaseObjs._acadDoc.LockDocument())
            {
                try
                {
                    //idPoly3dX = pnts3dR.addPoly3d("CPNT-BRKLINE");
                    //idsPoly3dX.Add(idPoly3dX);

                    idPoly3dX = pnts3dB1.addPoly3d("CPNT-BRKLINE");
                    idsPoly3dX.Add(idPoly3dX);

                    idPoly3dX = pnts3dB2.addPoly3d("CPNT-BRKLINE");
                    idsPoly3dX.Add(idPoly3dX);

                    idPoly3dX = pnts3dD.addPoly3d("CPNT-BRKLINE");
                    idsPoly3dX.Add(idPoly3dX);
                }
                catch (System.Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            } bool exists = false;

            if (idPoly3dX != ObjectId.Null)
            {
                DialogResult result;
                result = MessageBox.Show("Add Slope Breaklines to Design Surface? \nYes to add to surface: " + surfDES
                                         + "\nNo to keep Breaklines, but not add to surface."
                                         + "\nCancel to dispose of Breaklines.",
                                         "Slope Breaklines",

                                         System.Windows.Forms.MessageBoxButtons.YesNoCancel);
                switch (result)
                {
                case DialogResult.Yes:
                    TinSurface surf = (TinSurface)Surf.getTinSurface(surfDES, out exists);
                    surf.BreaklinesDefinition.AddStandardBreaklines(idsPoly3dX, 1.0, 1.0, 0.0, 0.0);
                    success = true;
                    break;

                case DialogResult.No:
                    success = true;
                    break;

                case DialogResult.Cancel:
                    success = false;
                    break;
                }
            }
            else
            {
                success = false;
            }

            return(success);
        }
Exemplo n.º 20
0
        private void cmdSelectBldgLimits_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            BaseObjs.acadActivate();
            Polyline poly      = null;
            string   nameLayer = "";
            ObjectId idBlkRef  = ObjectId.Null;

            using (BaseObjs._acadDoc.LockDocument())
            {
                try
                {
                    idBldgLim = Grading_GetNestedObject.getBldgLimit(out nameLayer, out idBlkRef);
                    if (idBldgLim == ObjectId.Null)
                    {
                        return;
                    }
                }
                catch (System.Exception ex)
                {
                    BaseObjs.writeDebug(string.Format("{0} GradeFloor.xaml.cs: line: 117", ex.Message));
                }

                Entity ent = idBldgLim.getEnt();

                if (ent is PolylineVertex3d)
                {
                    PolylineVertex3d v        = (PolylineVertex3d)idBldgLim.getEnt();
                    ObjectId         idPoly3d = v.OwnerId;
                    poly = (Polyline)Conv.poly3d_Poly(idPoly3d, "0").getEnt();
                }
                else if (ent is Polyline3d)
                {
                    poly = (Polyline)Conv.poly3d_Poly(idBldgLim, "0").getEnt();
                    idBldgLim.delete();
                    Autodesk.AutoCAD.ApplicationServices.Core.Application.ShowAlertDialog("Selected Object was a 3d Polyline and has been deleted!!");
                }
                else if (ent is Polyline)
                {
                    poly = (Polyline)idBldgLim.getEnt();
                }
                else if (ent is Polyline2d)
                {
                    Polyline2d poly2d = (Polyline2d)ent;
                    ObjectId   idPoly = Conv.poly2dToPoly(poly2d);
                    poly = (Polyline)idPoly.getEnt();
                }
                else if (ent is Line)
                {
                    SelectionSet ss = Select.buildSSet(new TypedValue[] { new TypedValue(8, nameLayer) });
                    if (ss != null && ss.Count > 0)
                    {
                    }
                    else
                    {
                        ObjectIdCollection ids      = xRef.getXRefEntsByLayer(idBlkRef, nameLayer);
                        List <ObjectId>    idsLines = new List <ObjectId>();
                        foreach (ObjectId id in ids)
                        {
                            idsLines.Add(id);
                        }
                        ObjectId idPoly = Misc.rebuildLWPoly(idsLines);
                        if (idPoly == ObjectId.Null)
                        {
                            Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("Failed to build Building Inner Boundary from xRef segments.\nUser needs to build polyline.");
                            return;
                        }
                        else
                        {
                            poly = (Polyline)idPoly.getEnt();
                        }
                    }
                }

                if (poly == null)
                {
                    return;
                }

                Centroid  = poly.getCentroid();
                idBldgLim = poly.ObjectId;
            }

            try
            {
                AverageElevation = Grading_Floor.getAverageElev(idBldgLim, chkShowPoints.IsChecked.Value, lstBox1.SelectedValue.ToString());
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(string.Format("{0} GradeFloor.xaml.cs: line: 146", ex.Message));
            }

            lblAvePadElev.Content = AverageElevation.ToString("#,###.00");
            double dblPadElev = AverageElevation + Convert.ToDouble(txtElevDiff.Text);

            lblPadElev.Content = dblPadElev.ToString("#,###.00");
            txtPadElev.Text    = string.Format("{0:#,###.00}", lblPadElev.Content);
        }
Exemplo n.º 21
0
        BC1(string nameCmd)
        {
            List <double> userInput  = null;
            Polyline3d    poly3dFL   = null;
            ObjectId      idPoly3dFL = ObjectId.Null;

            int side;

            Point3d pnt3dBEG = Pub.pnt3dO;
            Point3d pnt3dEND = Pub.pnt3dO;
            Point3d pnt3dX   = Pub.pnt3dO;

            List <ObjectId> idsCgPnt = new List <ObjectId>();
            ObjectId        idPoly   = ObjectId.Null;
            bool            escape   = false;

            try
            {
                userInput = cmdBC.getUserInput(nameCmd);
                if (userInput == null)
                {
                    return;
                }

                BaseObjs.acadActivate();

                if (Grading_Palette.gPalette.pGrading.optBRKLINE.IsChecked == true)
                {
                    Point3d pnt3dPick;
                    Entity  ent = Select.selectEntity(typeof(Polyline3d), "Select Brkline:", "Brkline selection failed.", out pnt3dPick);
                    poly3dFL   = (Polyline3d)ent;                                   //this 3dPoly is from points and is linked to the points with "lnkBrks" !!!!!!!!!!!!!!!!!!!!!!!!!!
                    idPoly3dFL = poly3dFL.ObjectId;
                    ResultBuffer rb = idPoly3dFL.getXData(null);
                    if (rb == null)
                    {
                        return;
                    }
                    TypedValue[]        tvsAll = rb.AsArray();
                    List <string>       nameApps;
                    List <TypedValue[]> tvsLst = tvsAll.parseXData(out nameApps);

                    if (nameApps.Contains(apps.lnkBrks) || nameApps.Contains(apps.lnkBrks2))
                    {
                        foreach (TypedValue[] tvs in tvsLst)
                        {
                            if (tvs[0].Value.ToString() == apps.lnkBrks)
                            {
                                idPoly3dFL.clearXData(apps.lnkBrks);
                                tvs.SetValue(new TypedValue(1001, apps.lnkBrks2), 0);     //link end points to FL upgraded from brkline
                                idPoly3dFL.setXData(tvs, apps.lnkBrks2);
                            }
                            else if (tvs[0].Value.ToString() == apps.lnkBrks2)
                            {
                                idPoly3dFL.clearXData(apps.lnkBrks3);                     //clear old link data if exists - endpoints should be same
                            }
                        }
                    }
                }
                else if (Grading_Palette.gPalette.pGrading.optPNTS.IsChecked == true)
                {
                    try
                    {
                        string prompt1 = "\nSelect first point (Esc to quit): ";
                        string prompt2 = "\nSelect next point (Enter to exit/Esc to quit: ";

                        idsCgPnt = getPoints(prompt1, prompt2);

                        idPoly3dFL = BrkLine.makeBreakline(apps.lnkBrks2, "BC", out idPoly, idsCgPnt);         //this 3dPoly is from points and is linked to the points with "lnkBrks2"    OK.
                    }
                    catch (System.Exception ex)
                    {
                        BaseObjs.writeDebug(ex.Message + " cmdBC1.cs: line: 79");
                    }
                }

                try
                {
                    using (Transaction tr = BaseObjs.startTransactionDb())
                    {
                        poly3dFL = (Polyline3d)tr.GetObject(idPoly3dFL, OpenMode.ForRead);

                        pnt3dBEG = idsCgPnt[0].getCogoPntCoordinates();
                        pnt3dEND = idsCgPnt[1].getCogoPntCoordinates();

                        PromptStatus ps;
                        string       prompt = "\nPick point Back of Curb adjacent to first segment";
                        pnt3dX = UserInput.getPoint(prompt, pnt3dBEG, out escape, out ps, osMode: 0);
                        if (pnt3dX == Pub.pnt3dO || escape)
                        {
                            return;
                        }
                        if (pnt3dX.isRightSide(pnt3dBEG, pnt3dEND))
                        {
                            side = 1;
                        }
                        else
                        {
                            side = -1;
                        }

                        double offH1 = 0.5 * side;
                        double offV1 = userInput[0] + 0.0208;
                        double offH2 = userInput[1] * side;
                        double offV2 = userInput[2] * userInput[1];

                        List <Handle> handles = new List <Handle>();


                        ObjectId idPoly3dTC = buildCurbFeature(offH1, offV1, idPoly3dFL, idPoly3dFL, false, ref handles, side);        // collect handles from TC, BB, CgPnt, GT
                        Grading_Dict.addBrksToPntXDict(idPoly3dFL, idPoly3dTC, offH1, offV1, 0.0, -1.0);

                        ObjectId idPoly3dBB = buildCurbFeature(offH2, offV2, idPoly3dFL, idPoly3dTC, true, ref handles, side);
                        Grading_Dict.addBrksToPntXDict(idPoly3dFL, idPoly3dBB, offH1 + offH2, offV1 + offV2, 0.0, -1.0);

                        ObjectId idPolyBB = idPoly3dBB.addPoly("GB");
                        handles.Add(idPolyBB.getHandle());

                        if (nameCmd == "cmdBG")
                        {
                            double offH3 = userInput[3] * side * -1;
                            double offV3 = userInput[4];

                            ObjectId idPoly3dLP = buildCurbFeature(offH3, offV3, idPoly3dFL, idPoly3dFL, true, ref handles, side);
                            Grading_Dict.addBrksToPntXDict(poly3dFL.ObjectId, idPoly3dLP, offH3, offV3, 0.0, -1.0);

                            ObjectId idPolyGT = idPoly3dLP.addPoly("Gutter");
                            handles.Add(idPolyGT.getHandle());
                        }

                        idPoly3dFL.setXData(handles, apps.lnkBrks3);

                        tr.Commit();
                    }
                }
                catch (System.Exception ex)
                {
                    BaseObjs.writeDebug(ex.Message + " cmdBC1.cs: line: 140");
                }
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " cmdBC1.cs: line: 145");
            }
        }
Exemplo n.º 22
0
        deleteGridAlign()
        {
            BaseObjs.acadActivate();

            Point3d  pnt3dPick = Pub.pnt3dO;
            string   nameAlign = "";
            ObjectId idAlign   = Align.selectAlign("Select Alignment: ", "", out pnt3dPick, out nameAlign);

            if (idAlign == ObjectId.Null)
            {
                return;
            }

            if (nameAlign.Contains("GRID"))
            {
                ResultBuffer rb = idAlign.getXData("STAKE");
                if (rb == null)
                {
                    return;
                }

                TypedValue[] tvs    = rb.AsArray();
                uint         numBeg = uint.Parse(tvs[1].Value.ToString());
                uint         numEnd = uint.Parse(tvs[2].Value.ToString());

                ObjectId idCgPnt = ObjectId.Null;
                for (int i = (int)numBeg; i <= (int)numEnd; i++)
                {
                    uint lngPntNum = (uint)i;
                    try
                    {
                        idCgPnt = Autodesk.Civil.ApplicationServices.CivilApplication.ActiveDocument.CogoPoints.GetPointByPointNumber(lngPntNum);
                        idCgPnt.delete();
                    }
                    catch (System.Exception)
                    {
                    }
                }

                string nameLayer = tvs[3].Value.ToString();

                tvs = new TypedValue[8];
                tvs.SetValue(new TypedValue((int)DxfCode.Operator, "<OR"), 0);
                tvs.SetValue(new TypedValue((int)DxfCode.Start, RXClass.GetClass(typeof(Polyline)).DxfName), 1);
                tvs.SetValue(new TypedValue((int)DxfCode.Start, RXClass.GetClass(typeof(Line)).DxfName), 2);
                tvs.SetValue(new TypedValue((int)DxfCode.Start, RXClass.GetClass(typeof(DBText)).DxfName), 3);
                tvs.SetValue(new TypedValue((int)DxfCode.Start, RXClass.GetClass(typeof(BlockReference)).DxfName), 4);
                tvs.SetValue(new TypedValue((int)DxfCode.Start, RXClass.GetClass(typeof(Dimension)).DxfName), 5);
                tvs.SetValue(new TypedValue((int)DxfCode.Operator, "OR>"), 6);
                tvs.SetValue(new TypedValue((int)DxfCode.LayerName, nameLayer), 7);

                SelectionSet ss  = Select.buildSSet(tvs);
                ObjectId[]   ids = ss.GetObjectIds();
                foreach (ObjectId id in ids)
                {
                    id.delete();
                }

                Dict.deleteDictionary(nameAlign);

                nameLayer = string.Format("STAKE-BLDG-{0}-LABEL", nameAlign);

                tvs[7] = new TypedValue((int)DxfCode.LayerName, nameLayer);
                ss     = Select.buildSSet(tvs);
                ids    = ss.GetObjectIds();
                foreach (ObjectId id in ids)
                {
                    id.delete();
                }

                updateControls((nameAlign));

                idAlign.delete();
            }
        }
Exemplo n.º 23
0
        BD(double B1Width, double B1Slope,
           double B2Width, double B2Slope,
           double gradeSlope, int interval,
           string surfTAR, string surfDES,
           int side          = 0,
           double elev       = 0.0,
           Polyline3d poly3d = null)
        {
            Boolean success = false;
            Boolean exists  = false;

            Boolean doB1 = fSG.boolB1;
            Boolean doB2 = fSG.boolB1;

            List <Point3d> pnts3d   = new List <Point3d>();
            List <Point3d> pnts3dB1 = new List <Point3d>();
            List <Point3d> pnts3dB2 = new List <Point3d>();
            List <Point3d> pnts3dDL = new List <Point3d>();
            List <Point3d> pnts3dRF = new List <Point3d>();

            Vector3d v3d = Vector3d.XAxis;

            Point3d pnt3dB;

            BaseObjs.acadActivate();

            ObjectId idPoly3dOrg = ObjectId.Null;
            ObjectId idPoly3d    = ObjectId.Null;
            ObjectId idPoly      = ObjectId.Null;

            if (poly3d == null)
            {
                idPoly3dOrg = Select.getBrkLine("\nSelect 3D Polyline Reference: ");
            }
            else
            {
                idPoly3dOrg = poly3d.ObjectId;
            }

            if (idPoly3dOrg == ObjectId.Null)
            {
                return(false);
            }

            ResultBuffer rb = idPoly3dOrg.getXData(apps.lnkBrks);

            if (rb == null)
            {
                return(false);
            }

            TypedValue[]    tvs        = rb.AsArray();
            List <ObjectId> idsCgPntRF = tvs.getObjectIdList();
            List <ObjectId> idsCgPntM  = null;

            ObjectId idCgPnt = ObjectId.Null;

            bool isClosed = idPoly3dOrg.checkIfClosed3d(false);

            if (!isClosed)
            {
                Application.ShowAlertDialog("Design reference Breakline is not closed. Exiting...");
                return(false);
            }
            Point3d pnt3dB1_Mb = Pub.pnt3dO, pnt3dB2_Mb = Pub.pnt3dO, pnt3dDL_Mb = Pub.pnt3dO, pnt3dRF_Mb = Pub.pnt3dO;
            Point3d pnt3dB1_Me = Pub.pnt3dO, pnt3dB2_Me = Pub.pnt3dO, pnt3dDL_Me = Pub.pnt3dO, pnt3dRF_Me = Pub.pnt3dO;
            Point3d pnt3dX = Pub.pnt3dO, pnt3dXA = Pub.pnt3dO, pnt3dXB = Pub.pnt3dO;

            uint   pntNum = 0;
            int    s = 0;
            double angle = 0.0, deflc = 0.0, delta = 0.0, slopeChk = 0.0;

            List <ANG_PT_PROP> angPtProps = new List <ANG_PT_PROP>();
            ANG_PT_PROP        angPtProp  = null;

            try
            {
                using (BaseObjs._acadDoc.LockDocument())
                {
                    pnts3d = idPoly3dOrg.getCoordinates3dList();

                    if (side == 0)
                    {
                        side = Geom.getSide(pnts3d);
                    }

                    angPtProps = pnts3d.getPoly3dAngPtProps();

                    int k = angPtProps.Count;
                    for (int i = 0; i < k; i++)
                    {
                        angPtProp = angPtProps[i];

                        pnt3dB = angPtProp.BEG;     //last point = first point

                        deflc = angPtProp.ANG_DEFLC;

                        if (i == 0)
                        {
                            pnts3dRF.Add(pnt3dB);       //add begin point
                        }
                        angle = getMidDeltaDirection(side, deflc, angPtProp.DIR_SEG1, angPtProp.DIR_SEG2, out s);


                        if (s == 0)
                        {
                            if (surfTAR == "")
                            {
                                pnt3dDL_Mb = getTargetElevation(elev, pnt3dB, angle, gradeSlope);
                            }
                            else
                            {
                                v3d        = new Vector3d(sMath.Cos(angle), sMath.Sin(angle), -gradeSlope);
                                pnt3dDL_Mb = getSlopeIntercept(surfTAR, pnt3dB, gradeSlope, v3d);
                            }

                            pnts3dDL.Add(pnt3dDL_Mb);

                            idCgPnt = pnt3dDL_Mb.setPoint(out pntNum);
                            BaseObjs.updateGraphics();

                            idsCgPntM = new List <ObjectId> {
                                idsCgPntRF[i], idCgPnt
                            };
                            idPoly3d = BrkLine.makeBreakline(apps.lnkSLP, "cmdBD", out idPoly, idsCgPntM);
                            BaseObjs.updateGraphics();
                        }
                        else if (s == -2 || s == 4)
                        {
                            getToeIntercept(side, angPtProp, surfTAR, elev, gradeSlope, doB1, B1Width, B1Slope, doB2, B2Width, B2Slope, ref pnt3dDL_Mb, ref pnt3dXA, ref pnt3dXB);

                            if (i == 0)
                            {
                                pnt3dDL_Me = pnt3dXB;
                            }
                            else
                            {
                                pnts3dRF.Add(pnt3dXB);
                                pnt3dXB.setPoint(out pntNum, "CPNT-ON");
                                BaseObjs.updateGraphics();
                            }

                            slopeChk = pnt3dDL_Mb.getSlope(pnt3dXB);
                            Debug.Print(slopeChk.ToString("0.0000"));

                            pnts3dRF.Add(pnt3dB);          //add RF Angle point

                            pnts3dRF.Add(pnt3dXA);
                            pnt3dXA.setPoint(out pntNum, "CPNT-ON");
                            BaseObjs.updateGraphics();

                            slopeChk = pnt3dDL_Mb.getSlope(pnt3dXA);
                            Debug.Print(slopeChk.ToString("0.0000"));

                            idCgPnt = pnt3dDL_Mb.setPoint(out pntNum, "CPNT-ON");
                            BaseObjs.updateGraphics();
                            idsCgPntM = new List <ObjectId> {
                                idsCgPntRF[i], idCgPnt
                            };
                            pnts3dDL.Add(pnt3dDL_Mb);

                            idPoly3d = BrkLine.makeBreakline(apps.lnkSLP, "cmdBD", out idPoly, idsCgPntM);
                            BaseObjs.updateGraphics();
                        }
                        else if (s == 2 || s == -4)
                        {
                            pnts3dRF.Add(pnt3dB);

                            double   anglePerp1 = angPtProp.DIR_SEG1 + PI / 2 * -side;
                            double   anglePerp2 = angPtProp.DIR_SEG2 + PI / 2 * -side;
                            Vector2d v2d1       = new Vector2d(sMath.Cos(anglePerp1), sMath.Sin(anglePerp1));
                            Vector2d v2d2       = new Vector2d(sMath.Cos(anglePerp2), sMath.Sin(anglePerp2));

                            delta = v2d1.GetAngleTo(v2d2);

                            List <double> angles = new List <double>();
                            angles.Add(anglePerp1);
                            double angleX = anglePerp1 + delta / 4 * side;
                            angles.Add(angleX);
                            angles.Add(angle);
                            angleX = angle + delta / 4 * side;
                            angles.Add(angleX);
                            angles.Add(anglePerp2);



                            foreach (double ang in angles)
                            {
                                angle = ang;
                                if (surfTAR != "")
                                {
                                    v3d        = new Vector3d(sMath.Cos(angle), sMath.Sin(angle), -gradeSlope);
                                    pnt3dDL_Mb = getSlopeIntercept(surfTAR, pnt3dB, gradeSlope, v3d);
                                }
                                else
                                {
                                    pnt3dDL_Mb = getTargetElevation(elev, pnt3dB, angle, gradeSlope);
                                }

                                pnts3dDL.Add(pnt3dDL_Mb);
                                idCgPnt = pnt3dDL_Mb.setPoint(out pntNum, "CPNT-ON");
                                BaseObjs.updateGraphics();

                                idsCgPntM = new List <ObjectId> {
                                    idsCgPntRF[i], idCgPnt
                                };

                                idPoly3d = BrkLine.makeBreakline(apps.lnkSLP, "cmdBD", out idPoly, idsCgPntM);
                                BaseObjs.updateGraphics();
                            }
                        }
                    }

                    pnts3dDL.Add(pnts3dDL[0]);  //complete point list with first point - for closure
                    if (pnt3dRF_Me != Pub.pnt3dO)
                    {
                        pnts3dRF.Add(pnt3dRF_Me);   //point on RF opposite DL back - first mid delta
                        pnt3dRF_Me.setPoint(out pntNum, "CPNT-ON");
                        BaseObjs.updateGraphics();
                    }

                    pnts3dRF.Add(pnts3dRF[0]);  //complete point list with first point - for closure
                }
            }
            catch (SystemException ex)
            {
                BaseObjs.writeDebug(ex.Message + " cmdBD.cs: line: 244");
                success = false;
            }
            ObjectId           idPoly3dX  = ObjectId.Null;
            ObjectIdCollection idsPoly3dX = new ObjectIdCollection();

            tvs = new TypedValue[13];
            tvs.SetValue(new TypedValue(1001, "lnkSLP"), 0);
            using (BaseObjs._acadDoc.LockDocument())
            {
                try
                {
                    idPoly3dOrg.handOverPoly3d2(pnts3dRF);

                    Handle hB1;
                    if (pnts3dB1.Count > 0)
                    {
                        idPoly3dX = pnts3dB1.addPoly3d("CPNT-BRKLINE"); //Lower Bench
                        idsPoly3dX.Add(idPoly3dX);
                        hB1 = idPoly3dX.getHandle();
                    }
                    else
                    {
                        B1Width = 0.0;
                        B1Slope = 0.0;
                        hB1     = "0".stringToHandle();
                    }
                    tvs.SetValue(new TypedValue(1000, B1Width), 1);
                    tvs.SetValue(new TypedValue(1000, B1Slope), 2);
                    tvs.SetValue(new TypedValue(1005, hB1), 3);

                    Handle hB2;
                    if (pnts3dB2.Count > 0)
                    {
                        idPoly3dX = pnts3dB2.addPoly3d("CPNT-BRKLINE"); //Top of Slope/Upper Bench
                        idsPoly3dX.Add(idPoly3dX);
                        hB2 = idPoly3dX.getHandle();
                    }
                    else
                    {
                        B2Width = 0.0;
                        B2Slope = 0.0;
                        hB2     = "0".stringToHandle();
                    }
                    tvs.SetValue(new TypedValue(1000, B2Width), 4);
                    tvs.SetValue(new TypedValue(1000, B2Slope), 5);
                    tvs.SetValue(new TypedValue(1005, hB2), 6);

                    Handle hDL;
                    idPoly3dX = pnts3dDL.addPoly3d("CPNT-BRKLINE"); //Top of Slope/Daylight (if no upper bench)
                    idsPoly3dX.Add(idPoly3dX);

                    hDL = idPoly3dX.getHandle();
                    tvs.SetValue(new TypedValue(1000, gradeSlope), 7);
                    tvs.SetValue(new TypedValue(1070, side), 8);
                    tvs.SetValue(new TypedValue(1000, interval), 9);
                    tvs.SetValue(new TypedValue(1005, hDL), 10);
                    tvs.SetValue(new TypedValue(1000, surfTAR), 11);
                    tvs.SetValue(new TypedValue(1000, surfDES), 12);

                    idPoly3dOrg.setXData(tvs, apps.lnkSLP);
                }
                catch (System.Exception ex)
                {
                    BaseObjs.writeDebug(ex.Message + " cmdBD.cs: line: 307");
                }
            }

            if (idPoly3dX != ObjectId.Null)
            {
                DialogResult result;
                result = MessageBox.Show(string.Format("Add Slope Breaklines to Design Surface? \nYes to add to surface: {0}\nNo to keep Breaklines, but not add to surface.\nCancel to dispose of Breaklines.", surfDES),
                                         "Slope Breaklines",
                                         System.Windows.Forms.MessageBoxButtons.YesNoCancel);
                switch (result)
                {
                case DialogResult.Yes:
                    TinSurface surf = Surf.getTinSurface(surfDES, out exists);
                    surf.BreaklinesDefinition.AddStandardBreaklines(idsPoly3dX, 1.0, 1.0, 0.0, 0.0);
                    success = true;
                    break;

                case DialogResult.No:
                    success = true;
                    break;

                case DialogResult.Cancel:
                    success = false;
                    break;
                }
            }
            else
            {
                success = false;
            }

            return(success);
        }
Exemplo n.º 24
0
Arquivo: cmdBC.cs Projeto: 15831944/EM
        BC(string nameCmd)
        {
            List <double> userInput  = null;
            Polyline3d    poly3dFL   = null;
            ObjectId      idPoly3dFL = ObjectId.Null;

            Point3d pnt3dBEG = Pub.pnt3dO;
            Point3d pnt3dEND = Pub.pnt3dO;
            Point3d pnt3dX   = Pub.pnt3dO;

            int side;

            bool escape = false;

            try
            {
                userInput = getUserInput(nameCmd);
                if (userInput == null)
                {
                    return;
                }

                BaseObjs.acadActivate();

                int snapMode = SnapMode.getOSnap();
                SnapMode.setOSnap(8);

                if (Grading_Palette.gPalette.pGrading.optBRKLINE.IsChecked == true)
                {
                    Point3d pnt3dPick;
                    Entity  ent = Select.selectEntity(typeof(Polyline3d), "Select Brkline:", "Brkline selection failed.", out pnt3dPick);
                    poly3dFL   = (Polyline3d)ent;                                   //this 3dPoly is from points and is linked to the points with "apps.lnkBrks" !!!!!!!!!!!!!!!!!!!!!!!!!!
                    idPoly3dFL = poly3dFL.ObjectId;
                    ResultBuffer rb = idPoly3dFL.getXData(null);
                    if (rb == null)
                    {
                        return;
                    }
                }
                else if (Grading_Palette.gPalette.pGrading.optPNTS.IsChecked == true)
                {
                    ObjectId idPoly = ObjectId.Null;
                    try
                    {
                        idPoly3dFL = BrkLine.makeBreakline(apps.lnkBrks2, "BC", out idPoly);         //this 3dPoly is from points and is linked to the points with "lnkBrks2"    OK.
                    }
                    catch (System.Exception ex)
                    {
                        BaseObjs.writeDebug(ex.Message + " cmdBC.cs: line: 58");
                    }
                }

                try
                {
                    using (Transaction tr = BaseObjs.startTransactionDb())
                    {
                        poly3dFL = (Polyline3d)tr.GetObject(idPoly3dFL, OpenMode.ForRead);
                        pnt3dBEG = poly3dFL.StartPoint;
                        pnt3dEND = poly3dFL.EndPoint;
                        PromptStatus ps;
                        pnt3dX = UserInput.getPoint("Pick point Back of Curb adjacent to segment", pnt3dBEG, out escape, out ps, osMode: 8);
                        if (pnt3dX == Pub.pnt3dO || escape)
                        {
                            SnapMode.setOSnap(snapMode);
                            return;
                        }
                        if (Geom.testRight(pnt3dBEG, pnt3dEND, pnt3dX) > 0)
                        {
                            side = -1;
                        }
                        else
                        {
                            side = 1;
                        }

                        double offH1 = 0.5 * 1.25 * side;
                        double offV1 = userInput[0] + 0.0208;
                        double offH2 = userInput[1] * side;
                        double offV2 = userInput[2] * userInput[1];

                        List <Handle> handles = new List <Handle>();

                        ObjectId idPoly3dTC = buildTCandBench(offH1, offV1, idPoly3dFL, idPoly3dFL, false, ref handles);        // collect handles from TC, BB, CgPnt, GT
                        Grading_Dict.addBrksToPntXDict(idPoly3dFL, idPoly3dTC, offH1, offV1, 0.0, -1.0);

                        ObjectId idPoly3dBB = buildTCandBench(offH2, offV2, idPoly3dFL, idPoly3dTC, true, ref handles);
                        Grading_Dict.addBrksToPntXDict(idPoly3dFL, idPoly3dBB, offH1 + offH2, offV1 + offV2, 0.0, -1.0);

                        ObjectId idPolyBB = idPoly3dBB.addPoly("GB");
                        idPoly3dBB.moveBottom();
                        handles.Add(idPolyBB.getHandle());
                        idPoly3dBB.moveToTop();

                        if (nameCmd == "cmdBG")
                        {
                            double offH3 = userInput[3] * side * -1;
                            double offV3 = userInput[4];

                            ObjectId idPoly3dLP = buildTCandBench(offH3, offV3, idPoly3dFL, idPoly3dFL, true, ref handles);
                            Grading_Dict.addBrksToPntXDict(poly3dFL.ObjectId, idPoly3dLP, offH3, offV3, 0.0, -1.0);

                            ObjectId idPolyGT = idPoly3dLP.addPoly("Gutter");
                            idPolyGT.moveBottom();
                            handles.Add(idPolyGT.getHandle());

                            idPoly3dLP.moveToTop();
                        }

                        idPoly3dFL.setXData(handles, apps.lnkBrks3);

                        SnapMode.setOSnap(snapMode);

                        tr.Commit();
                    }
                }
                catch (System.Exception ex)
                {
                    BaseObjs.writeDebug(ex.Message + " cmdBC.cs: line: 123");
                }
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " cmdBC.cs: line: 128");
            }
        }
Exemplo n.º 25
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();
        }
Exemplo n.º 26
0
        stakeMISC(string strCommand)
        {
            TinSurface objSurface = fStake.SurfaceCPNT;

            string       strLayer = fMisc.tbxLayer.Text;
            string       strDesc  = fMisc.tbxDesc0.Text + fMisc.tbxDescription.Text;
            PromptStatus ps;
            bool         escape;

            switch (strCommand)
            {
            case "InLine_Center":

                BaseObjs.acadActivate();

                Point3d pnt3dTar = UserInput.getPoint("\nSelect Target Point for Staking: ", out ps, osMode: 8);

                Point3d pnt3dPick = UserInput.getPoint("\nSelect Directional Point(any XY location): ", pnt3dTar, out escape, out ps, osMode: 8);

                double  dblAngDir1 = pnt3dTar.getDirection(pnt3dPick);
                Point3d pnt3dPolar = pnt3dTar.traverse(dblAngDir1, double.Parse(fMisc.cbxOffset.Text));

                double  dblElev = objSurface.FindElevationAtXY(pnt3dTar.X, pnt3dTar.Y);
                Point3d pnt3d   = new Point3d(pnt3dPolar.X, pnt3dPolar.Y, dblElev);

                Stake_Calc.setOffsetPointMISC(pnt3d, strLayer, strDesc);

                pnt3dPolar = pnt3dTar.traverse(dblAngDir1 + PI, double.Parse(fMisc.cbxOffset.Text));

                pnt3dPolar = pnt3dTar.traverse(dblAngDir1, double.Parse(fMisc.cbxOffset.Text));

                Stake_Calc.setOffsetPointMISC(pnt3d, strLayer, strDesc);

                break;

            case "InLine_Direction":

                BaseObjs.acadActivate();

                pnt3dTar = UserInput.getPoint("\nSelect Target Point for Staking: ", out ps, osMode: 8);

                pnt3dPick = UserInput.getPoint("\nSelect Directional Point(any XY location): ", pnt3dTar, out escape, out ps, osMode: 8);

                dblAngDir1 = pnt3dTar.getDirection(pnt3dPick);

                pnt3dPolar = pnt3dTar.traverse(dblAngDir1, double.Parse(fMisc.cbxOffset.Text));

                dblElev = objSurface.FindElevationAtXY(pnt3dTar.X, pnt3dTar.Y);
                pnt3d   = new Point3d(pnt3dPolar.X, pnt3dPolar.Y, dblElev);

                Stake_Calc.setOffsetPointMISC(pnt3d, strLayer, strDesc);

                if (double.Parse(fMisc.cbxOffsetDir.Text) == 0)
                {
                    Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("Direction Offset is 0 - revise....exiting");
                    return;
                }

                pnt3dPolar = pnt3dTar.traverse(dblAngDir1, double.Parse(fMisc.cbxOffset.Text) + double.Parse(fMisc.cbxOffsetDir.Text));

                pnt3d = new Point3d(pnt3dPolar.X, pnt3dPolar.Y, dblElev);

                strDesc = string.Format("{0}' O/S {1} @", double.Parse(fMisc.cbxOffset.Text) +
                                        double.Parse(fMisc.cbxOffsetDir.Text), fMisc.cbxObjType.Text);

                Stake_Calc.setOffsetPointMISC(pnt3d, strLayer, strDesc);

                break;

            case "Proj2Curb":

                BaseObjs.acadActivate();

                pnt3dTar = UserInput.getPoint("\nSelect Target Point for Staking: ", out ps, osMode: 8);
                string xRefPath = "";
                Entity ent      = xRef.getEntity("\nSelect Adjacent Curb:", out escape, out xRefPath);

                Point3d pnt3dInt0 = getRadial_Perpendicular(pnt3dTar, ent);

                ent.ObjectId.delete();

                dblAngDir1 = pnt3dTar.getDirection(pnt3dInt0);

                pnt3dPolar = pnt3dInt0.traverse(dblAngDir1 + PI / 2, double.Parse(fMisc.cbxOffset.Text));

                dblElev = objSurface.FindElevationAtXY(pnt3dInt0.X, pnt3dInt0.Y);
                dblElev = dblElev + double.Parse(fMisc.cbxCurbHeight.Text) / 12;
                pnt3d   = new Point3d(pnt3dPolar.X, pnt3dPolar.Y, dblElev);

                Stake_Calc.setOffsetPointMISC(pnt3d, strLayer, strDesc);

                pnt3dPolar = pnt3dInt0.traverse(dblAngDir1 - PI / 2, double.Parse(fMisc.cbxOffset.Text));

                pnt3d = new Point3d(pnt3dPolar.X, pnt3dPolar.Y, dblElev);

                Stake_Calc.setOffsetPointMISC(pnt3d, strLayer, strDesc);

                break;

            case "Proj2Bldg":

                BaseObjs.acadActivate();

                pnt3dTar = UserInput.getPoint("\nSelect Target Point for Staking: ", out ps, osMode: 8);
                Point3d pnt3dRef1 = UserInput.getPoint("Pick Point Perpendicular to Building: ", pnt3dTar, out escape, out ps, osMode: 8);
                dblAngDir1 = pnt3dTar.getDirection(pnt3dRef1);

                pnt3dPolar = pnt3dRef1.traverse(dblAngDir1 + PI / 2, double.Parse(fMisc.cbxOffset.Text));

                dblElev = objSurface.FindElevationAtXY(pnt3dRef1.X, pnt3dRef1.Y);
                pnt3d   = new Point3d(pnt3dPolar.X, pnt3dPolar.Y, dblElev);
                Stake_Calc.setOffsetPointMISC(pnt3d, strLayer, strDesc);

                pnt3dPolar = pnt3dRef1.traverse(dblAngDir1 - PI / 2, double.Parse(fMisc.cbxOffset.Text));

                pnt3d = new Point3d(pnt3dPolar.X, pnt3dPolar.Y, dblElev);
                Stake_Calc.setOffsetPointMISC(pnt3d, strLayer, strDesc);

                break;

            case "AP":

                BaseObjs.acadActivate();

                pnt3dTar = UserInput.getPoint("\nSelect Target Point for Staking: ", out ps, osMode: 8);

                pnt3dRef1 = UserInput.getPoint("\nSelect Adjacent Angle Point1: ", out ps, osMode: 1);
                Point3d pnt3dRef2  = UserInput.getPoint("\nSelect Adjacent Angle Point2: ", out ps, osMode: 1);
                Point3d varPntPick = UserInput.getPoint("\nSelect Side: ", out ps, osMode: 0);

                double dblAngDelta = Geom.getAngle3Points(pnt3dRef1, pnt3dTar, pnt3dRef2);

                dblAngDir1 = pnt3dRef1.getDirection(pnt3dTar);
                double dblAngDir2 = pnt3dTar.getDirection(pnt3dRef2);

                bool isRightHand = (pnt3dTar.isRightSide(pnt3dRef1, pnt3dRef2)) ? true : false;

                pnt3dPolar = varPntPick.traverse(dblAngDir1 + PI / 2, 10);

                List <Point3d> pnts3d1 = new List <Point3d> {
                    pnt3dRef1, pnt3dTar
                };
                List <Point3d> pnts3d2 = new List <Point3d> {
                    varPntPick, pnt3dPolar
                };

                List <Point3d> pnts3dInt = pnts3d1.intersectWith(pnts3d2, false, extend.both);

                if (pnts3dInt.Count == 0)
                {
                    return;
                }
                bool boolHit = false, boolIN = false;
                int  intSide = 0;

                //PICK POINT ADJACENT TO FIRST SEGMENT
                if (pnt3dTar.isRightSide(pnt3dRef1, varPntPick))
                {
                    //CCW
                    if (isRightHand)
                    {
                        boolIN  = true;
                        intSide = -1;
                        //CW
                    }
                    else
                    {
                        boolIN  = false;
                        intSide = -1;
                    }
                    boolHit = true;
                }
                else
                {     //RIGHT SIDE OF FIRST SEGMENT
                    //CCW
                    if (isRightHand)
                    {
                        boolIN  = false;
                        intSide = 1;
                    }
                    else
                    {
                        boolIN = true;
                        //CW
                        intSide = 1;
                    }
                    boolHit = true;
                }

                if (!boolHit)
                {
                    pnt3dPolar = varPntPick.traverse(dblAngDir2 + PI / 2, 10);
                    pnts3d1    = new List <Point3d> {
                        pnt3dRef2, pnt3dTar
                    };
                    pnts3d2 = new List <Point3d> {
                        varPntPick, pnt3dPolar
                    };

                    List <Point3d> pnts3dInt2 = pnts3d1.intersectWith(pnts3d2, false, extend.both);

                    //PICK POINT ADJACENT TO SECOND SEGMENT

                    //LEFT SIDE OF SECOND SEGMENT
                    if (pnt3dRef2.isRightSide(pnt3dTar, varPntPick))
                    {
                        //CCW
                        if (isRightHand)
                        {
                            boolIN  = true;
                            intSide = -1;
                            //CW
                        }
                        else
                        {
                            boolIN  = false;
                            intSide = -1;
                        }
                        //RIGHT SIDE OF SECOND SEGMENT
                    }
                    else
                    {
                        //CCW
                        if (isRightHand)
                        {
                            boolIN  = false;
                            intSide = 1;
                            //CW
                        }
                        else
                        {
                            boolIN  = true;
                            intSide = 1;
                        }
                    }
                }

                if (boolIN)
                {
                    pnt3dPolar = pnt3dTar.traverse(dblAngDir2 + dblAngDelta / 2 * intSide * -1, Convert.ToDouble(fMisc.cbxOffset.Text) / System.Math.Sin(dblAngDelta / 2));
                    dblElev    = objSurface.FindElevationAtXY(pnt3dTar.X, pnt3dTar.Y);
                    pnt3d      = new Point3d(pnt3dPolar.X, pnt3dPolar.Y, dblElev);
                    Stake_Calc.setOffsetPointMISC(pnt3d, strLayer, strDesc);
                }
                else
                {
                    pnt3dPolar = pnt3dTar.traverse(dblAngDir2 + ((3 * PI / 2 - dblAngDelta) * intSide * -1), Convert.ToDouble((fMisc.cbxOffset).Text));
                    //point opposite begin point of next segment
                    dblElev = objSurface.FindElevationAtXY(pnt3dTar.X, pnt3dTar.Y);

                    pnt3d = new Point3d(pnt3dPolar.X, pnt3dPolar.Y, dblElev);
                    Stake_Calc.setOffsetPointMISC(pnt3d, strLayer, strDesc);

                    pnt3dPolar = pnt3dTar.traverse(dblAngDir2 + (PI / 2 * intSide * -1), Convert.ToDouble((fMisc.cbxOffset).Text));
                    //point opposite begin point of next segment

                    pnt3d = new Point3d(pnt3dPolar.X, pnt3dPolar.Y, dblElev);
                    Stake_Calc.setOffsetPointMISC(pnt3d, strLayer, strDesc);
                }

                break;
            }
        }
Exemplo n.º 27
0
        private void btnCreateWallProfileView_Click(object sender, EventArgs e)
        {
            BaseObjs.acadActivate();

            this.ACTIVEPROFILEVIEW = wpv.CreateWallProfileView(ACTIVEALIGN, ALGNENTDATA, BrkLEFT, BrkRIGHT, "WDE");
        }
Exemplo n.º 28
0
        TP4()
        {
            gp.pnt3d1 = Pub.pnt3dO;
            gp.pnt3d2 = Pub.pnt3dO;
            ps        = PromptStatus.Cancel;
            object mode = 0;

            BaseObjs.acadActivate();
            Vector3d v3d = Vector3d.XAxis;

            try
            {
                elev = UserInput.getCogoPoint("\nPick Cogo Point 1: ", out idCgPnt1, ObjectId.Null, osMode: 8);
                if (elev == "")
                {
                    return;
                }
                else
                {
                    gp.pnt3d1 = idCgPnt1.getCogoPntCoordinates();
                }

                elev = UserInput.getCogoPoint("\nPick Cogo Point 2: ", out idCgPnt2, ObjectId.Null, osMode: 8);
                if (elev == "")
                {
                    return;
                }
                else
                {
                    gp.pnt3d2 = idCgPnt2.getCogoPntCoordinates();
                }

                mode = SnapMode.getOSnap();
                SnapMode.setOSnap(8);

                gp.pnt3dX = Pub.pnt3dO;
                gp.pnt3dT = Pub.pnt3dO;

                System.Windows.Forms.Keys mods = System.Windows.Forms.Control.ModifierKeys;
                bool shift   = (mods & System.Windows.Forms.Keys.Shift) > 0;
                bool control = (mods & System.Windows.Forms.Keys.Control) > 0;
                gp.shift = shift;

                gp.pnt3dT = gPnt.getPoint("\nSelect Target location (CogoPoint for xSlope and distance / pick side to enter xSlope and distance: ", "cmdTP");

                if (gp.pnt3dT == Pub.pnt3dO)
                {
                    return;
                }
                else if (gp.pnt3dT.Z == 0)
                {
                    gp.pnt3dX = gc.calcBasePnt3d(gp.pnt3dT, gp.pnt3d1, gp.pnt3d2);
                    if (gp.pnt3dX == Pub.pnt3dO)
                    {
                        return;
                    }

                    escaped = UserInput.getUserInputDoubleAsString("\nEnter Cross Slope (+ or -): ", out xSlope, xSlope);
                    if (escaped)
                    {
                        return;
                    }

                    escaped = UserInput.getUserInputDoubleAsString("\nEnter Width: ", out width, width);
                    if (escaped)
                    {
                        return;
                    }
                    double dist  = gp.pnt3d1.getDistance(gp.pnt3d2);
                    double distX = gp.pnt3d1.getDistance(gp.pnt3dX);

                    Point2d pnt2dX = gp.pnt3dX.Convert2d(BaseObjs.xyPlane);
                    Point2d pnt2dT = gp.pnt3dT.Convert2d(BaseObjs.xyPlane);
                    double  distT  = pnt2dX.GetDistanceTo(pnt2dT);

                    gp.pnt3dT = new Point3d(gp.pnt3dT.X, gp.pnt3dT.Y, gp.pnt3dX.Z + distT * double.Parse(xSlope));

                    v3d  = gp.pnt3dT - gp.pnt3dX;
                    v3d *= double.Parse(width) / distT;
                }
                else
                {
                    gp.pnt3dX = gc.calcBasePnt3d(gp.pnt3dT, gp.pnt3d1, gp.pnt3d2);
                    if (gp.pnt3dX == Pub.pnt3dO)
                    {
                        return;
                    }

                    CgPnt.setPoint(gp.pnt3dX, out pntNum, "CPNT-ON");

                    v3d = gp.pnt3dT - gp.pnt3dX;
                }
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " cmdTP.cs: line: 336");
            }
            finally
            {
                SnapMode.setOSnap((int)mode);
            }

            ObjectId idPoly   = ObjectId.Null;
            Point3d  pnt3d3   = idCgPnt2.getCogoPntCoordinates() + v3d;
            ObjectId idCgPnt3 = pnt3d3.setPoint(out pntNum);
            Point3d  pnt3d4   = idCgPnt1.getCogoPntCoordinates() + v3d;
            ObjectId idCgPnt4 = pnt3d4.setPoint(out pntNum);

            List <ObjectId> idCgPnts = new List <ObjectId> {
                idCgPnt1, idCgPnt2
            };

            BrkLine.makeBreakline(apps.lnkBrks, "cmdTP4", out idPoly, idCgPnts);

            idCgPnts = new List <ObjectId> {
                idCgPnt2, idCgPnt3
            };
            BrkLine.makeBreakline(apps.lnkBrks, "cmdTP4", out idPoly, idCgPnts);

            idCgPnts = new List <ObjectId> {
                idCgPnt3, idCgPnt4
            };
            BrkLine.makeBreakline(apps.lnkBrks, "cmdTP4", out idPoly, idCgPnts);

            idCgPnts = new List <ObjectId> {
                idCgPnt4, idCgPnt1
            };
            BrkLine.makeBreakline(apps.lnkBrks, "cmdTP4", out idPoly, idCgPnts);
        }
Exemplo n.º 29
0
        MCG()
        {
            object dynMode   = null;
            object dynPrompt = null;
            object osMode    = null;

            try
            {
                dynMode   = Application.GetSystemVariable("DYNMODE");
                dynPrompt = Application.GetSystemVariable("DYNPROMPT");

                Application.SetSystemVariable("DYNMODE", 3);
                Application.SetSystemVariable("DYNPROMPT", 1);

                osMode = SnapMode.getOSnap();
                SnapMode.setOSnap((int)osModes.NOD);

                string       descVal = "", descKey = "";
                Point3d      pnt3dPick;
                PromptStatus ps;
                CogoPoint    cgPnt;
                Entity       ent    = Select.selectEntity(typeof(CogoPoint), "\nSelect a point on the desired group or <CR> for Menu: ", "", out pnt3dPick, out ps);
                short        color  = 256;
                string       prompt = "";
                TypedValue[] tvs;

                switch (ps)
                {
                case PromptStatus.OK:
                    cgPnt   = (CogoPoint)ent;
                    descVal = cgPnt.RawDescription;
                    break;

                case PromptStatus.Cancel:
                    return;

                case PromptStatus.None:
                    bool     exists;
                    ObjectId idDict = Dict.getNamedDictionary("cmdMCG", out exists);
                    if (exists)
                    {
                        ResultBuffer rb = Dict.getXRec(idDict, "defaultCmd");
                        if (rb == null)
                        {
                            descVal = "CPNT-ON";
                        }
                        else
                        {
                            tvs     = rb.AsArray();
                            descVal = tvs[0].Value.ToString();
                        }
                    }
                    else
                    {
                        descVal = "CPNT-ON";
                    }
                    descKey = "O";
                    foreach (CgPnt_Group.pntGroupParams pntGrp in CgPnt_Group.pntGroups)
                    {
                        if (pntGrp.name == descVal)
                        {
                            descKey = pntGrp.key;
                            break;
                        }
                    }

                    bool escape;
                    prompt = string.Format("\nSelect [cpntJoin/cpntOn/cpntSt/cpntTrans/cpntMisc/utlSEw/utlSD/utlWat/utlMIsc/Cp/SPnt/Exist/eXit] <{0}> [J/O/S/T/M/SE/SD/W/MI/C/SP/E/X]", descVal);
                    escape = UserInput.getUserInputKeyword(descKey, out descKey, prompt, "J O S T M SE SD W MI C SP E X");
                    if (escape)
                    {
                        return;
                    }

                    if (descKey.ToUpper() == "X")
                    {
                        return;
                    }

                    exists = false;
                    foreach (CgPnt_Group.pntGroupParams pntGrp in CgPnt_Group.pntGroups)
                    {
                        if (pntGrp.key == descKey)
                        {
                            descVal = pntGrp.name;
                            color   = pntGrp.color;
                            exists  = true;
                            break;
                        }
                    }

                    if (!exists)
                    {
                        Application.ShowAlertDialog("Value entered is out of range. Exiting...");
                        return;
                    }

                    break;
                }
                Layer.manageLayers(descVal);
                ObjectId idPntLblStyle = Pnt_Style.getPntLabelStyle(descVal);
                ObjectId idPntStyle    = Pnt_Style.getPntStyle(descVal);

                Layer.manageLayer(descVal, color);

                prompt = string.Format("\nSelect Point(s) to be moved to group {0}\r", descVal);

                Editor ed = BaseObjs._editor;

                tvs = new TypedValue[1];
                Type type = typeof(CogoPoint);
                tvs.SetValue(new TypedValue((int)DxfCode.Start, RXClass.GetClass(type).DxfName), 0);

                SelectionFilter        filter = new SelectionFilter(tvs);
                PromptSelectionOptions pso    = new PromptSelectionOptions();
                pso.MessageForAdding            = prompt;
                pso.MessageForRemoval           = "\nRemove Items";
                pso.RejectObjectsOnLockedLayers = true;

                PromptSelectionResult psr = null;
                BaseObjs.acadActivate();

                psr = BaseObjs._editor.GetSelection(pso, filter);
                SelectionSet ss = psr.Value;

                if (ss != null && ss.Count > 0)
                {
                    ObjectId[] ids = ss.GetObjectIds();
                    try
                    {
                        using (Transaction tr = BaseObjs.startTransactionDb())
                        {
                            foreach (ObjectId id in ids)
                            {
                                CogoPoint cogoPnt = (CogoPoint)tr.GetObject(id, OpenMode.ForWrite);
                                cogoPnt.RawDescription = descVal;
                                cogoPnt.Layer          = descVal;
                                cogoPnt.LabelStyleId   = idPntLblStyle;
                                cogoPnt.StyleId        = idPntStyle;
                            }
                            tr.Commit();
                        }
                    }
                    catch (System.Exception ex)
                    {
                        BaseObjs.writeDebug(ex.Message + " cmdMCG.cs: line: 155");
                    }
                    CgPnt_Group.updatePntGroups();
                }
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " cmdMCG.cs: line: 162");
            }
            finally
            {
                SnapMode.setOSnap((int)osMode);
                Application.SetSystemVariable("DYNMODE", (Int16)dynMode);
                Application.SetSystemVariable("DYNPROMPT", (Int16)dynPrompt);
            }
        }
Exemplo n.º 30
0
        private void btn_Update_Click(object sender, EventArgs e)
        {
            ProfileView objProfileView = null;

            TypedValue[] tvs;
            try
            {
                BaseObjs.acadActivate();
                Point3d pnt3d = Point3d.Origin;
                objProfileView = (ProfileView)Base_Tools45.Select.selectEntity(typeof(ProfileView), "Select Profile View: ", "Profile View Selection failed", out pnt3d, out ps);
            }
            catch (Autodesk.AutoCAD.Runtime.Exception)
            {
                return;
            }

            string strHandleRIGHT = "";

            try
            {
                ResultBuffer rb = objProfileView.ObjectId.getXData("BRKRIGHT");
                tvs            = rb.AsArray();
                strHandleRIGHT = tvs[1].Value.ToString();
            }
            catch (Autodesk.AutoCAD.Runtime.Exception)
            {
            }

            string strHandleLEFT = "";

            try
            {
                ResultBuffer rb = objProfileView.ObjectId.getXData("BRKLEFT");
                tvs           = rb.AsArray();
                strHandleLEFT = tvs[1].Value.ToString();
            }
            catch (Autodesk.AutoCAD.Runtime.Exception)
            {
            }

            Polyline3d Poly3dRIGHT     = null;
            bool       boolUpdateRIGHT = false;

            try
            {
                Poly3dRIGHT = (Polyline3d)Base_Tools45.Db.handleToObject(strHandleRIGHT);
            }
            catch (Autodesk.AutoCAD.Runtime.Exception)
            {
                if ((Poly3dRIGHT == null))
                {
                    DialogResult dr = MessageBox.Show("The Breakline for the RIGHT side has been deleted.\n Would you like to select a new Design Reference Breakline for the RIGHT Side?",
                                                      "",
                                                      MessageBoxButtons.YesNo);
                    switch (dr)
                    {
                    case DialogResult.Yes:

                        try
                        {
                            strHandleRIGHT = selectBrkLine("RIGHT", objProfileView);

                            if (strHandleRIGHT != string.Empty)
                            {
                                Poly3dRIGHT     = (Polyline3d)Base_Tools45.Db.handleToObject(strHandleRIGHT);
                                boolUpdateRIGHT = true;
                            }
                            else
                            {
                                DialogResult dr2 = MessageBox.Show("Selection Failed. Try again?", "", MessageBoxButtons.YesNo);

                                switch (dr2)
                                {
                                case DialogResult.Yes:

                                    strHandleRIGHT = selectBrkLine("RIGHT", objProfileView);
                                    if (strHandleRIGHT != string.Empty)
                                    {
                                        Poly3dRIGHT     = (Polyline3d)Base_Tools45.Db.handleToObject(strHandleRIGHT);
                                        boolUpdateRIGHT = true;
                                    }
                                    else
                                    {
                                        return;
                                    }

                                    break;

                                case DialogResult.No:

                                    return;
                                }
                            }
                        }
                        catch (Autodesk.AutoCAD.Runtime.Exception)
                        {
                        }

                        break;

                    case DialogResult.No:

                        return;
                    }
                }
            }

            Polyline3d Poly3dLEFT     = null;
            bool       boolUpdateLEFT = false;

            try
            {
                Poly3dLEFT = (Polyline3d)Base_Tools45.Db.handleToObject(strHandleLEFT);
            }
            catch (Autodesk.AutoCAD.Runtime.Exception)
            {
                if (Poly3dLEFT == null)
                {
                    DialogResult dr = MessageBox.Show("The Breakline for the LEFT side has been deleted.\n Would you like to select a new Design Reference Breakline for the LEFT Side?",
                                                      "",
                                                      MessageBoxButtons.YesNo);

                    switch (dr)
                    {
                    case DialogResult.Yes:

                        try
                        {
                            strHandleLEFT = selectBrkLine("LEFT", objProfileView);

                            if (strHandleLEFT != string.Empty)
                            {
                                Poly3dLEFT     = (Polyline3d)Base_Tools45.Db.handleToObject(strHandleLEFT);
                                boolUpdateLEFT = true;
                            }
                            else
                            {
                                DialogResult dr2 = MessageBox.Show("Selection Failed. Try again?", "", MessageBoxButtons.YesNo);

                                switch (dr2)
                                {
                                case DialogResult.Yes:

                                    strHandleRIGHT = selectBrkLine("RIGHT", objProfileView);
                                    if (strHandleRIGHT != string.Empty)
                                    {
                                        Poly3dLEFT     = (Polyline3d)Base_Tools45.Db.handleToObject(strHandleLEFT);
                                        boolUpdateLEFT = true;
                                    }
                                    else
                                    {
                                        return;
                                    }

                                    break;

                                case DialogResult.No:

                                    break;
                                }
                            }
                        }
                        catch (Autodesk.AutoCAD.Runtime.Exception)
                        {
                        }

                        break;

                    case DialogResult.No:

                        return;
                    }
                }
            }

            BRKLINE_DESIGN_HANDLE = strHandleRIGHT;
            BRKLINE_EXIST_HANDLE  = strHandleLEFT;

            Alignment objAlign = null;

            using (Transaction TR = BaseObjs.startTransactionDb())
            {
                try
                {
                    objAlign    = (Alignment)TR.GetObject(objProfileView.AlignmentId, OpenMode.ForRead);
                    ACTIVEALIGN = objAlign;
                }
                catch (Autodesk.AutoCAD.Runtime.Exception)
                {
                    Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("Original Alignment is not available. Exiting.....");
                    return;
                }
            }

            List <staOffElev> sOffs = wd.convert3dPolyToPnt_Data(objAlign, ALGNENTDATA, Poly3dRIGHT.ObjectId, "DESIGN");

            PNTSDESIGN = new List <PNT_DATA>();

            foreach (staOffElev s in sOffs)                                                       //convert data to work with existing methods.
            {
                PNT_DATA p = new PNT_DATA()
                {
                    STA = s.staAlign, z = s.elev
                };
                PNTSDESIGN.Add(p);
            }
            wdp.CreateProfileByLayout2("BRKRIGHT", objAlign, PNTSDESIGN);
            if (boolUpdateRIGHT)
            {
                tvs = new TypedValue[4] {
                    new TypedValue(1001, "BRKRIGHT"),
                    new TypedValue(1005, Poly3dRIGHT.Handle),
                    new TypedValue(1040, PNTSDESIGN[0].STA),
                    new TypedValue(1040, PNTSDESIGN[PNTSDESIGN.Count - 1].STA)
                };

                objProfileView.ObjectId.setXData(tvs, "BRKRIGHT");
            }

            sOffs     = wd.convert3dPolyToPnt_Data(ACTIVEALIGN, ALGNENTDATA, Poly3dLEFT.ObjectId, "EXIST");
            PNTSEXIST = new List <PNT_DATA>();
            foreach (staOffElev s in sOffs)
            {
                PNT_DATA p = new PNT_DATA()
                {
                    STA = s.staAlign, z = s.elev
                };
                PNTSEXIST.Add(p);
            }

            wdp.CreateProfileByLayout2("BRKLEFT", objAlign, PNTSEXIST);
            if (boolUpdateLEFT)
            {
                tvs = new TypedValue[4] {
                    new TypedValue(1001, "BRKLEFT"),
                    new TypedValue(1005, Poly3dLEFT.Handle),
                    new TypedValue(1040, PNTSEXIST[0].STA),
                    new TypedValue(1040, PNTSEXIST[PNTSEXIST.Count - 1].STA)
                };

                objProfileView.ObjectId.setXData(tvs, "BRKLEFT");
            }

            wdl.wallDesignLimits(objProfileView, "WDE");
        }