Example #1
0
File: cmdRL.cs Project: 15831944/EM
        RL(string nameApp, string nameCmd)
        {
            ObjectId idPoly = ObjectId.Null;
            bool     escape = false;

            List <ObjectId> idPnts        = new List <ObjectId>();
            ObjectId        idCogoPntBASE = CgPnt.selectCogoPointByNode("\nSelect Base Point: ", osMode: 8);

            if (idCogoPntBASE == ObjectId.Null)
            {
                Application.ShowAlertDialog("CogoPoint not found.  Exiting......");
                return;
            }

            BaseObjs.updateGraphics();
            Point3d pnt3dBASE = idCogoPntBASE.getCogoPntCoordinates();

            idPnts.Add(idCogoPntBASE);

            string pntDesc = idCogoPntBASE.getCogoPntDesc();

            if (pntDesc == "")
            {
                pntDesc = "CPNT-ON";
            }

            string       prompt = "\nLocate New Point: ";
            PromptStatus ps;
            Point3d      pnt3dTAR = UserInput.getPoint(prompt, pnt3dBASE, out escape, out ps, osMode: 641);

            if (escape || pnt3dTAR == Pub.pnt3dO)
            {
                return;
            }

            double distance = 0.0;
            double DeltaZ   = 0.0;
            double grade    = 0.0;

            resultsRL resRL;

            getRLpromptresults(out resRL, out escape);
            if (escape)
            {
                return;
            }

            switch (resRL.opt)
            {
            case "R":
                grade    = resRL.val;
                distance = pnt3dBASE.getDistance(pnt3dTAR);
                pnt3dTAR = new Point3d(pnt3dTAR.X, pnt3dTAR.Y, pnt3dBASE.Z + (grade * distance));
                break;

            case "Z":
                DeltaZ   = resRL.val;
                pnt3dTAR = new Point3d(pnt3dTAR.X, pnt3dTAR.Y, pnt3dBASE.Z + DeltaZ);
                break;
            }

            uint     pntNum;
            ObjectId idCogoPntTAR = pnt3dTAR.setPoint(out pntNum, pntDesc);
            ObjectId idPoly3d     = ObjectId.Null;

            if (nameCmd == "cmdRL")
            {
                idPnts.Add(idCogoPntTAR);

                List <Handle> hPnts = new List <Handle>();
                hPnts.Add(idPnts[0].getHandle());
                hPnts.Add(idPnts[1].getHandle());

                using (BaseObjs._acadDoc.LockDocument())
                {
                    idPoly3d = BrkLine.makeBreakline(nameApp, nameCmd, out idPoly, idPnts);
                }
            }

            Grading_Palette.gPalette.pGrading.cmdRL_Default = resRL.opt;
            Grading_Palette.gPalette.pGrading.cmdRL_GRADE   = grade.ToString();
            Grading_Palette.gPalette.pGrading.cmdRL_DELTAZ  = DeltaZ.ToString();

            Dict.setCmdDefault("cmdRL", "cmdDefault", resRL.opt);
            Dict.setCmdDefault("cmdRL", "GRADE", grade.ToString());
            Dict.setCmdDefault("cmdRL", "DELTAZ", DeltaZ.ToString());

            bool       exists          = false;
            PointGroup pntGroup        = CgPnt_Group.addPntGroup(pntDesc, out exists);
            ObjectId   idPntLabelStyle = Pnt_Style.getPntLabelStyle(CgPnts.setup(pntDesc));

            if (!exists)
            {
                try
                {
                    using (Transaction tr = BaseObjs.startTransactionDb())
                    {
                        pntGroup.UpgradeOpen();
                        pntGroup.PointLabelStyleId = idPntLabelStyle;

                        StandardPointGroupQuery query = new StandardPointGroupQuery();
                        query.IncludeRawDescriptions = pntDesc;
                        pntGroup.SetQuery(query);
                        tr.Commit();
                    }
                }
                catch (System.Exception ex)
                {
                    BaseObjs.writeDebug(ex.Message + " cmdRL.cs: line: 167");
                }
            }
        }
Example #2
0
        createAlignLabelSetStyle(string name)
        {
            AlignmentLabelSetStyle alignLabelSetStyle = null;
            ObjectId idStyle = ObjectId.Null;
            ObjectId idItem  = ObjectId.Null;

            try
            {
                idStyle = BaseObjs._civDoc.Styles.LabelSetStyles.AlignmentLabelSetStyles[name];
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(string.Format("{0} Align_Style.cs: line: 112", ex.Message));
            }
            if (idStyle == ObjectId.Null)
            {
                idStyle = BaseObjs._civDoc.Styles.LabelSetStyles.AlignmentLabelSetStyles.Add(name);
            }

            try
            {
                using (Transaction tr = BaseObjs.startTransactionDb())
                {
                    alignLabelSetStyle             = (AlignmentLabelSetStyle)tr.GetObject(idStyle, OpenMode.ForWrite);
                    alignLabelSetStyle.Description = "Program Generated";

                    idItem = BaseObjs._civDoc.Styles.LabelStyles.AlignmentLabelStyles.MajorStationLabelStyles.Add("Parallel with line Tick");
                    LabelStyle labelStyle = (LabelStyle)tr.GetObject(idItem, OpenMode.ForWrite);
                    try
                    {
                        labelStyle.RemoveComponent("New Tick");
                    }
                    catch (System.Exception ex)
                    {
                        BaseObjs.writeDebug(string.Format("{0} Align_Style.cs: line: 129", ex.Message));
                    }

                    try
                    {
                        ObjectId id = labelStyle.AddComponent("Tick", LabelStyleComponentType.Tick);
                        LabelStyleTickComponent cmpnnt = (LabelStyleTickComponent)tr.GetObject(id, OpenMode.ForWrite);
                        cmpnnt.Tick.Lineweight.Value      = LineWeight.LineWeight060;
                        cmpnnt.Tick.AlignWithObject.Value = true;
                        cmpnnt.Tick.RotationAngle.Value   = 0.0;
                        cmpnnt.General.Visible.Value      = true;
                    }
                    catch (System.Exception ex)
                    {
                        BaseObjs.writeDebug(string.Format("{0} Align_Style.cs: line: 141", ex.Message));
                    }
                    try
                    {
                        labelStyle.RemoveComponent("New Block");
                    }
                    catch (System.Exception ex)
                    {
                        BaseObjs.writeDebug(string.Format("{0} Align_Style.cs: line: 147", ex.Message));
                    }

                    try
                    {
                        labelStyle.RemoveComponent("New Line");
                    }
                    catch (System.Exception ex)
                    {
                        BaseObjs.writeDebug(string.Format("{0} Align_Style.cs: line: 154", ex.Message));
                    }

                    try
                    {
                        ObjectId id = labelStyle.AddComponent("Line", LabelStyleComponentType.Line);
                        LabelStyleLineComponent cmpnnt = (LabelStyleLineComponent)tr.GetObject(id, OpenMode.ForWrite);
                        cmpnnt.Line.Color.Value             = Autodesk.AutoCAD.Colors.Color.FromRgb(255, 127, 0);
                        cmpnnt.Line.Angle.Value             = 2.094;
                        cmpnnt.Line.StartPointXOffset.Value = 0.005;
                        cmpnnt.Line.StartPointYOffset.Value = -0.005;
                        cmpnnt.General.Visible.Value        = true;
                    }
                    catch (System.Exception ex)
                    {
                        BaseObjs.writeDebug(string.Format("{0} Align_Style.cs: line: 167", ex.Message));
                    }

                    try
                    {
                        labelStyle.RemoveComponent("New Text");
                    }
                    catch (System.Exception ex)
                    {
                        BaseObjs.writeDebug(string.Format("{0} Align_Style.cs: line: 174", ex.Message));
                    }

                    try
                    {
                        ObjectId id = labelStyle.AddComponent("Text", LabelStyleComponentType.Text);
                        LabelStyleTextComponent cmpnnt = (LabelStyleTextComponent)tr.GetObject(id, OpenMode.ForWrite);

                        cmpnnt.Text.XOffset.Value    = 60;
                        cmpnnt.Text.YOffset.Value    = -0.25 - cmpnnt.Text.Height.Value;
                        cmpnnt.Text.Color.Value      = Autodesk.AutoCAD.Colors.Color.FromRgb(0, 255, 0);
                        cmpnnt.Text.Contents.Value   = "STA=<[Station Value(Uft|FS|P2|RN|AP|Sn|TP|B2|EN|W0|OF)]>";
                        cmpnnt.General.Visible.Value = true;
                    }
                    catch (System.Exception ex)
                    {
                        BaseObjs.writeDebug(string.Format("{0} Align_Style.cs: line: 188", ex.Message));
                    }

                    alignLabelSetStyle.Add(labelStyle.ObjectId);

                    AlignmentLabelSetItem stationStyleMajor = alignLabelSetStyle[alignLabelSetStyle.Count - 1];
                    stationStyleMajor.Increment = 20;

                    tr.Commit();
                }
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(string.Format("{0} Align_Style.cs: line: 200", ex.Message));
            }
            return(idStyle);
        }
        trimEdgeToCurb(ObjectId idBlockRef, ObjectIdCollection idsPoly3d, ObjectId idPoly3dRF, List <Handle> handles3)
        {
            bool     ints     = false;
            ObjectId idPolyLT = handles3[1].getObjectId();
            ObjectId idPolyRT = handles3[3].getObjectId();

            List <Point3d> pnt3dBox = new List <Point3d> {
                idPolyRT.getBegPnt(),
                           idPolyRT.getEndPnt(),
                           idPolyLT.getEndPnt(),
                           idPolyLT.getBegPnt(),
            };

            pnt3dBox.Add(pnt3dBox[0]);

            ObjectId idPolyBox  = Draw.addPoly(pnt3dBox);
            Entity   entPolyBox = idPolyBox.getEnt();

            string nameLayer = "CURB-TEMP";

            Layer.manageLayers(nameLayer);
            ResultBuffer rb = null;

            try {
                ObjectIdCollection idsEntTemp = xRef.copyXRefEnts(idBlockRef, "CURB", nameLayer);

                BaseObjs.updateGraphics();
                ObjectIdCollection idsEnts = new ObjectIdCollection();

                try {
                    for (int i = idsEntTemp.Count - 1; i > -1; i--)
                    {
                        Debug.Print(i.ToString());
                        ObjectId idEnt = idsEntTemp[i];
                        Entity   ent   = idEnt.getEnt();
                        if (ent == null)
                        {
                            continue;
                        }

                        Point3dCollection pnts3dInt0 = new Point3dCollection();

                        switch (idEnt.getType())
                        {
                        case "Arc":
                        case "Line":
                            idEnt.changeProp(LineWeight.LineWeight050, clr.mag);
                            BaseObjs.updateGraphics();

                            ent.BoundingBoxIntersectWith(entPolyBox, Intersect.OnBothOperands, pnts3dInt0, IntPtr.Zero, IntPtr.Zero);

                            if (pnts3dInt0.Count > 0)
                            {
                                idsEnts.Add(idEnt);
                                idEnt.changeProp(LineWeight.LineWeight100, clr.cyn);
                                BaseObjs.updateGraphics();
                            }
                            else
                            {
                                idEnt.delete();
                            }
                            break;

                        case "Polyline":

                            List <ObjectId> idsPolyEnts = idEnt.poly_ArcsLines(nameLayer);
                            idEnt.delete();
                            idsEntTemp.Remove(idEnt);

                            foreach (ObjectId idx in idsPolyEnts)
                            {
                                ent = idx.getEnt();
                                idx.changeProp(LineWeight.LineWeight050, clr.mag);
                                BaseObjs.updateGraphics();

                                pnts3dInt0 = new Point3dCollection();

                                ent.BoundingBoxIntersectWith(entPolyBox, Intersect.OnBothOperands, pnts3dInt0, IntPtr.Zero, IntPtr.Zero);

                                if (pnts3dInt0.Count > 0)
                                {
                                    idsEnts.Add(idx);
                                    idsEntTemp.Add(idx);
                                    idx.changeProp(LineWeight.LineWeight100, clr.cyn);
                                    BaseObjs.updateGraphics();
                                }
                                else
                                {
                                    idx.delete();
                                }
                            }
                            break;

                        case "Spline":
                            string message = "\nWarning: Drawing containing the curb objects contains Splines.\nReplace the Splines with Lines, Arcs, or Polylines and reprocess.\nExiting...";
                            Application.ShowAlertDialog(message);
                            idsEntTemp.delete();
                            return(false);

                        default:
                            idEnt.delete();
                            idsEntTemp.Remove(idEnt);
                            break;
                        }
                    }
                }
                catch (System.Exception) {
                }
                finally{
                    idPolyBox.delete();
                }

                if (idsEnts.Count == 0)
                {
                    return(ints);
                }

                CogoPoint cogoPntBEG;

                Handle[] hPolysIn = new Handle[4];
                handles3.CopyTo(hPolysIn);

                for (int n = 0; n < idsPoly3d.Count; n++)
                {
                    bool delete = false;
                    bool exists = false;

                    List <Point3d> pnt3dIntL   = new List <Point3d>();
                    List <Point3d> pnt3dRevL   = new List <Point3d>();
                    List <Point3d> pnt3dFinalL = new List <Point3d>();

                    ObjectId idPoly3dEDGE = idsPoly3d[n];
                    Handle   h            = idPoly3dEDGE.getHandle();

                    ObjectId idPolyEDGE = hPolysIn[n * 2 + 1].getObjectId();
                    h = idPolyEDGE.getHandle();

                    double lenEDGE = idPolyEDGE.getLength();                        //2dPoly IS DERIVED FROM REFERENCE 3DPOLYLINE in cmdBV
                    double deltaZ  = 0;

                    Polyline polyEDGE = (Polyline)idPolyEDGE.getEnt();

                    ObjectIdCollection idsDelete = new ObjectIdCollection();
                    try {
                        foreach (ObjectId idEnt in idsEnts)
                        {
                            Entity ent = idEnt.getEnt();

                            if (ent is Arc)
                            {
                                try {
                                    Arc arc = (Arc)ent;
                                    idEnt.changeProp(clr.red);
                                    BaseObjs.updateGraphics();

                                    Point3d        pnt3dPolyBeg = polyEDGE.ObjectId.getBegPnt();
                                    Point3d        pnt3dPolyEnd = polyEDGE.ObjectId.getEndPnt();
                                    List <Point3d> pnts3dPoly   = new List <Point3d> {
                                        pnt3dPolyBeg, pnt3dPolyEnd
                                    };
                                    List <Point3d> pnt3dIntLx = new List <Point3d>();
                                    bool           intersects = Geom.intersectsArc(pnts3dPoly, arc, out pnt3dIntLx, ref idsDelete);
                                    foreach (Point3d p3d in pnt3dIntLx)
                                    {
                                        pnt3dIntL.Add(p3d);
                                    }
                                }
                                catch (System.Exception) {
                                }
                            }
                            else
                            {
                                try {
                                    idEnt.changeProp(clr.yel);
                                    BaseObjs.updateGraphics();
                                    Point3dCollection pnt3dIntC = new Point3dCollection();
                                    polyEDGE.IntersectWith(ent, 0, pnt3dIntC, IntPtr.Zero, IntPtr.Zero);
                                    foreach (Point3d pnt3d in pnt3dIntC)
                                    {
                                        pnt3dIntL.Add(pnt3d);
                                    }
                                }
                                catch (System.Exception) {
                                }
                            }
                        }
                        idsDelete.delete();
                        BaseObjs.updateGraphics();
                    }
                    catch (Autodesk.AutoCAD.Runtime.Exception) {
                    }
                    finally {
                    }
                    if (pnt3dIntL.Count > 0)
                    {
                        delete = true;
                        ints   = true;
                        rb     = idPoly3dRF.getXData(apps.lnkBrks2);                                        //poly3dEDGE stores FL/RF cogo points at each end
                        if (rb == null)
                        {
                            return(false);
                        }
                        List <Handle>    handles2 = rb.rb_handles();                                             //list of handles of points at each end of FL/RF
                        List <CogoPoint> cogoPnts = handles2.getCogoPntsFromHandlesList();
                        cogoPntBEG = cogoPnts[0];

                        ObjectId idDictM   = Dict.getNamedDictionary(apps.lnkBrks3, out exists);
                        ObjectId idDictBEG = Dict.getSubEntry(idDictM, handles2[0].ToString());
                        ObjectId idDictEND = Dict.getSubEntry(idDictM, handles2[1].ToString());
                        ObjectId idDictX   = ObjectId.Null;

                        idDictX = Dict.getSubEntry(idDictBEG, idPoly3dEDGE.getHandle().ToString());
                        rb      = Dict.getXRec(idDictX, "Offset");
                        if (rb == null)
                        {
                            return(false);
                        }
                        TypedValue[] TVs    = rb.AsArray();
                        double       offset = (double)TVs[0].Value;

                        rb     = Dict.getXRec(idDictX, "DeltaZ");
                        TVs    = rb.AsArray();
                        deltaZ = (double)TVs[0].Value;

                        Point3d pnt3dFLbeg = cogoPntBEG.Location;

                        Point3d pnt3dEDGEbeg = idPoly3dEDGE.getBegPnt();
                        Point3d pnt3dEDGEend = idPoly3dEDGE.getEndPnt();

                        double slopeEdge = (pnt3dEDGEend.Z - pnt3dEDGEbeg.Z) / pnt3dEDGEbeg.getDistance(pnt3dEDGEend);

                        pnt3dRevL.Add(new Point3d(pnt3dEDGEbeg.X, pnt3dEDGEbeg.Y, 0.0)); //start list with begin point of edge
                        pnt3dRevL.Add(pnt3dIntL[0]);                                     //add first intersection

                        double angle    = pnt3dEDGEbeg.getDirection(pnt3dFLbeg);
                        double distance = pnt3dEDGEbeg.getDistance(pnt3dFLbeg);
                        double slope    = pnt3dEDGEbeg.getSlope(pnt3dFLbeg);


                        distance = distance * 1.1;

                        for (int i = 1; i < pnt3dIntL.Count; i++)
                        {
                            if (pnt3dIntL[i - 1].isEqual(pnt3dIntL[i - 0], 0.1) == false)
                            {
                                pnt3dRevL.Add(pnt3dIntL[i]);
                            }
                        }

                        pnt3dRevL.Add(new Point3d(pnt3dEDGEend.X, pnt3dEDGEend.Y, 0.0));

                        List <PNT_LIST> pntList = new List <PNT_LIST>();
                        short           x       = -1;
                        foreach (Point3d pnt3d in pnt3dRevL)
                        {
                            pntList.Add(new PNT_LIST {
                                index  = ++x,
                                length = pnt3dEDGEbeg.getDistance(pnt3d)
                            });
                        }

                        var sortDist = from pntlst in pntList
                                       orderby pntlst.length ascending
                                       select pntlst;

                        foreach (PNT_LIST pntLst in sortDist)
                        {
                            pnt3dFinalL.Add(pnt3dRevL[pntLst.index]);
                        }

                        for (int i = 1; i < pnt3dFinalL.Count; i++)
                        {
                            double distX = pnt3dFinalL[i - 1].getDistance(pnt3dFinalL[i]);
                            if (distX == 0)
                            {
                                pnt3dFinalL.Remove(pnt3dFinalL[i]);
                            }
                        }


                        if (pnt3dFinalL.Count > 1)
                        {
                            idsDelete = new ObjectIdCollection();
                            for (int i = 1; i < pnt3dFinalL.Count; i++)
                            {
                                bool     curb     = false;
                                Point3d  pnt3dMID = pnt3dFinalL[i - 1].getMidPoint2d(pnt3dFinalL[i + 0]);
                                Point3d  pnt3dTAR = pnt3dMID.traverse(angle, distance);
                                ObjectId idLine   = Base_Tools45.Draw.addLine(pnt3dMID, pnt3dTAR);
                                Line     line     = (Line)idLine.getEnt();
                                BaseObjs.updateGraphics();

                                Point3dCollection pnts3dInts = new Point3dCollection();
                                for (int j = idsEnts.Count - 1; j > -1; j--)
                                {
                                    ObjectId idEnt = idsEnts[j];
                                    Entity   ent   = idEnt.getEnt();
                                    if (ent is Arc)
                                    {
                                        Arc arc = (Arc)ent;

                                        List <Point3d> pnts3dLine = new List <Point3d> {
                                            pnt3dMID, pnt3dTAR
                                        };
                                        List <Point3d> pnt3dIntLx = new List <Point3d>();
                                        bool           intersects = Geom.intersectsArc(pnts3dLine, arc, out pnt3dIntLx, ref idsDelete);
                                        foreach (Point3d p3d in pnt3dIntLx)
                                        {
                                            pnts3dInts.Add(p3d);
                                        }
                                    }
                                    else
                                    {
                                        Point3dCollection pnt3dIntC = new Point3dCollection();
                                        line.IntersectWith(ent, 0, pnt3dIntC, IntPtr.Zero, IntPtr.Zero);
                                        foreach (Point3d pnt3d in pnt3dIntC)
                                        {
                                            pnts3dInts.Add(pnt3d);
                                        }
                                    }
                                }
                                if (pnts3dInts.Count > 0)
                                {
                                    curb = true;
                                }

                                if (!curb)                                   //'IF NO CURB THEN BUILD 3DPOLY SEGMENT
                                {
                                    Point3dCollection pnts3d  = new Point3dCollection();
                                    double            distBEG = pnt3dEDGEbeg.getDistance(pnt3dFinalL[i - 1]);
                                    pnts3d.Add(new Point3d(pnt3dFinalL[i - 1].X, pnt3dFinalL[i - 1].Y, pnt3dEDGEbeg.Z + distBEG * slopeEdge));

                                    double distEND = pnt3dEDGEbeg.getDistance(pnt3dFinalL[i + 0]);
                                    pnts3d.Add(new Point3d(pnt3dFinalL[i + 0].X, pnt3dFinalL[i + 0].Y, pnt3dEDGEbeg.Z + distEND * slopeEdge));

                                    ObjectId idPoly = Base_Tools45.Draw.addPoly(pnts3d, "GUTTER");
                                    handles3.Add(idPoly.getHandle());



                                    if (distBEG == 0 && System.Math.Round(distEND, 3) == System.Math.Round(lenEDGE))
                                    {
                                        distEND = -1;
                                    }
                                }
                                line.ObjectId.delete();
                            }
                            if (delete)                               //'REMOVE  ORGINAL BREAKLINE DATA FROM EXTENSION DICTIONARY
                            {
                                handles3.Remove(idPolyEDGE.getHandle());

                                Misc.deleteObj(idPolyEDGE);
                            }
                        }
                    }
                    else                        // no intersection with curb
                    {
                        idPolyEDGE.changeProp(nameLayer: "GUTTER");
                    }
                }                // end loop

                idsEntTemp.delete();

                idPoly3dRF.setXData(handles3, apps.lnkBrks3);
            }
            catch (System.Exception ex) {
                BaseObjs.writeDebug(ex.Message + " Grading_GetNestedCurbObjects.cs: line: 414");
            }
            return(ints);
        }
        trimGutterEdgeToCurbX(ObjectIdCollection idsPoly3d, ObjectId idPoly3dFL, List <Handle> handles3)
        {
            bool     exists;
            ObjectId idDict   = Dict.getNamedDictionary("cmdBVxRefs", out exists);
            ObjectId idXRef   = ObjectId.Null;
            string   fileName = string.Empty;
            bool     hasXRefs = false;

            try {
                if (!exists)
                {
                    ObjectIdCollection ids = xRef.getXRefsContainingTargetLayer("CURB");
                    if (ids == null)
                    {
                        return(hasXRefs);
                    }
                    switch (ids.Count)
                    {
                    case 0:
                        Autodesk.AutoCAD.ApplicationServices.Core.Application.ShowAlertDialog("No CURB layer found in any of the xRefs ...... exiting");
                        hasXRefs = false;
                        break;

                    case 1:
                        fileName = xRef.getXRefFileName(ids[0]);
                        Grading_Palette.gPalette.pGrading.BlockXRefName = fileName;                                                     //if only one xref has curb layer then use it and
                        idXRef = ids[0];
                        trimEdgeToCurb(idXRef, idsPoly3d, idPoly3dFL, handles3);                                                        //store xref name in form for use again
                        hasXRefs = true;
                        break;

                    default:
                        hasXRefs = true;
                        winXRefs fXRefs = winXRefs.frmXRefs;
                        if (fXRefs.idXRef == ObjectId.Null)                                   //initiate user interaction to select which
                        {
                            List <Grading_xRefID> listXRefs = new List <Grading_xRefID>();
                            foreach (ObjectId id in ids)
                            {
                                fileName = xRef.getXRefFileName(id);
                                listXRefs.Add(new Grading_xRefID(fileName, id));
                                fXRefs.lstBox1.Items.Add(fileName);
                            }
                            fXRefs.listXRefs = listXRefs;
                            fXRefs.ShowDialog();
                        }
                        idXRef = fXRefs.idXRef;
                        trimEdgeToCurb(idXRef, idsPoly3d, idPoly3dFL, handles3);
                        break;
                    }
                    if (fileName == string.Empty)
                    {
                        Dict.deleteDictionary("cmdVBxRefs");
                    }
                    else
                    {
                        Dict.addXRec(idDict, "xRefName", new ResultBuffer(new TypedValue(1000, fileName)));
                    }
                }
                else
                {
                    ResultBuffer rb = Dict.getXRec(idDict, "xRefName");
                    if (rb != null)
                    {
                        TypedValue[] tvs = rb.AsArray();
                        fileName = tvs[0].Value.ToString();
                        BlockReference br = xRef.getXRefBlockReference(fileName);
                        idXRef = br.ObjectId;
                        trimEdgeToCurb(idXRef, idsPoly3d, idPoly3dFL, handles3);
                        hasXRefs = true;
                    }
                }
            }
            catch (System.Exception ex) {
                BaseObjs.writeDebug(ex.Message + " Grading_GetNestedCurbObjects.cs: line: 77");
            }
            return(hasXRefs);
        }
Example #5
0
        updateBrkLines_Pnts()
        {
            int count1 = 0;
            int count2 = 0;
            int count3 = 0;
            int count4 = 0;
            int n      = 0;

            try
            {
                ObjectIdCollection ids = BaseObjs._acadDoc.getBrkLines();
                color = new Color();
                color = Color.FromColorIndex(ColorMethod.ByBlock, 100);
                foreach (ObjectId idBrkLine in ids)
                {
                    Debug.Print(idBrkLine.getHandle().ToString());
                    List <TypedValue[]> lstTVs = null;
                    try
                    {
                        ResultBuffer RB_BrkLine = idBrkLine.getXData(null);
                        TypedValue[] tvsX       = null;
                        if (RB_BrkLine != null)
                        {
                            tvsX = RB_BrkLine.AsArray();
                            List <string> nameApps = null;
                            lstTVs = xData.parseXData(tvsX, out nameApps);

                            var result = apps.lstApps.Intersect(nameApps);

                            if (result.Count <string>() == 0)
                            {
                                idBrkLine.changeProp(color, "BRKLINE-ERROR", LineWeight.LineWeight200);
                                count1++;
                                continue;
                            }
                        }
                        else
                        {
                            idBrkLine.changeProp(color, "BRKLINE-ERROR", LineWeight.LineWeight200);
                            count1++;
                            continue;
                        }
                    }
                    catch (System.Exception ex)
                    {
                        BaseObjs.writeDebug(ex.Message + " cmdUBP.cs: line: 66");
                    }

                    Color color7 = new Color();
                    color7 = Color.FromColorIndex(ColorMethod.ByBlock, 7);

                    Color color21 = new Color();
                    color21 = Color.FromColorIndex(ColorMethod.ByBlock, 21);

                    foreach (TypedValue[] tvs in lstTVs)
                    {
                        if (tvs[0].Value.ToString() != apps.lnkBrks)
                        {
                            continue;
                        }

                        Point3dCollection pnts3d = idBrkLine.getCoordinates3d();
                        if (pnts3d != null)
                        {
                            List <Handle> handlesBRk = tvs.getHandleList();
                            for (int i = 0; i < handlesBRk.Count; i++)
                            {
                                Handle handle = handlesBRk[i];
                                if (handle.ToString() != "0")
                                {
                                    CogoPoint cogoPnt = (CogoPoint)handle.getEnt();
                                    if (cogoPnt != null)
                                    {
                                        Point3d pnt3d = pnts3d[i];
                                        if (System.Math.Round(pnt3d.X, 3) == System.Math.Round(cogoPnt.Easting, 3) &&
                                            System.Math.Round(pnt3d.Y, 3) == System.Math.Round(cogoPnt.Northing, 3))
                                        {
                                            if (System.Math.Round(pnt3d.Z, 3) != System.Math.Round(cogoPnt.Elevation, 3))
                                            {
                                                count2++;
                                                pnt3d = new Point3d(pnt3d.X, pnt3d.Y, cogoPnt.Elevation);
                                                idBrkLine.updateVertex(i, pnt3d);
                                            }
                                            try
                                            {
                                                ResultBuffer rb = cogoPnt.ObjectId.getXData(apps.lnkBrks);
                                                if (rb != null)
                                                {
                                                    List <Handle> handlesPNT = rb.rb_handles();
                                                    if (handlesPNT.Contains(idBrkLine.getHandle()) == false)
                                                    {
                                                        TypedValue[] tvsX = new TypedValue[1] {
                                                            new TypedValue(1005, idBrkLine.getHandle())
                                                        };
                                                        cogoPnt.ObjectId.setXData(tvsX, apps.lnkBrks);
                                                    }
                                                }
                                                else
                                                {
                                                    TypedValue[] TVs = new TypedValue[2];
                                                    TVs.SetValue(new TypedValue(1001, apps.lnkBrks), 0);
                                                    TVs.SetValue(new TypedValue(1005, idBrkLine.getHandle()), 1);
                                                    cogoPnt.ObjectId.setXData(TVs, apps.lnkBrks);
                                                }
                                            }
                                            catch (System.Exception ex)
                                            {
                                                BaseObjs.writeDebug(ex.Message + " cmdUBP.cs: line: 124");
                                            }
                                        }
                                        else
                                        {
                                            count3++;
                                            idBrkLine.changeProp(color7, "BRKLINE-ERROR", LineWeight.LineWeight200);
                                            break;
                                        }
                                    }
                                }
                                else
                                {
                                    count4++;
                                    idBrkLine.changeProp(color21, "BRKLINE-ERROR", LineWeight.LineWeight200);
                                    break;
                                }
                            }
                        }
                    }
                }

                string mess = string.Format("Results: \nRB Missing: {0}\nHandle = 0: {1}\nXY Error: {2}\nZ Error: {3}", count1, count4, count3, count2);
                Application.ShowAlertDialog(mess);
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " cmdUBP.cs: line: 151");
                Debug.Print(n.ToString());
            }

            try
            {
                SelectionSet           ss       = Select.buildSSet(typeof(MText), true);
                ObjectId[]             idsMText = ss.GetObjectIds();
                IEnumerator <ObjectId> iEn      = (IEnumerator <ObjectId>)idsMText.GetEnumerator();
                ResultBuffer           rbMTxt   = null;
                foreach (ObjectId id in idsMText)
                {
                    rbMTxt = id.getXData(apps.lnkGS);
                    if (rbMTxt == null)
                    {
                        continue;
                    }
                    TypedValue[]  tvs     = rbMTxt.AsArray();
                    List <Handle> handles = rbMTxt.rb_handles();
                    foreach (Handle h in handles)
                    {
                        ObjectId idObj = h.getObjectId();
                        if (!idObj.IsValid)
                        {
                            xData.removeHandleFromXDataGS(id, apps.lnkGS, h);
                        }
                    }
                }
            }
            catch
            {
            }
        }
Example #6
0
        addWaterSurfaceProfile()
        {
            SelectionSet ss = Select.buildSSet(typeof(ProfileView), false, "Select Profile View");

            if (ss == null || ss.Count == 0)
            {
                return;
            }
            ObjectId[] ids = ss.GetObjectIds();

            ProfileView view    = (ProfileView)ids[0].getEnt();
            ObjectId    idAlign = view.AlignmentId;

            Entity ent = idAlign.getEnt();

            Prof.removeProfile(idAlign, "WSelev");
            ObjectId idLayer = Layer.manageLayers("PF-HGL");
            ObjectId idStyle = Prof_Style.getProfileStyle("WS");

            try
            {
                using (Transaction tr = BaseObjs.startTransactionDb())
                {
                    ProfileStyle style = (ProfileStyle)tr.GetObject(idStyle, OpenMode.ForWrite);
                    style.GetDisplayStyleProfile(ProfileDisplayStyleProfileType.Arrow).Visible         = false;
                    style.GetDisplayStyleProfile(ProfileDisplayStyleProfileType.Line).Visible          = true;
                    style.GetDisplayStyleProfile(ProfileDisplayStyleProfileType.Line).Layer            = "PF-HGL";
                    style.GetDisplayStyleProfile(ProfileDisplayStyleProfileType.Line).LinetypeScale    = 0.5;
                    style.GetDisplayStyleProfile(ProfileDisplayStyleProfileType.LineExtension).Visible = false;
                    tr.Commit();
                }
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(string.Format("{0} WSP_App.cs: line: 44", ex.Message));
            }

            ObjectId idStyleLabelSet = Prof_Style.getProfileLabelSetStyle("None");
            Profile  prof            = Prof.addProfileByLayout("WSelev", idAlign, idLayer, idStyle, idStyleLabelSet);

            string nameDwg = BaseObjs.docName;

            string defExt = "OUT";
            string title  = "Select WSPG output file";

            string filter = "Text files (*.out)|*.out";
            //filter="Text files (*.txt)|*.txt|All files (*.*)|*.*"
            string defPath  = string.Format("{0}{1}", @"\\Brianw-civil3d\xdrive\", nameDwg.Substring(0, 4));
            string nameFile = Dialog.OpenFileDialog(defExt, title, filter, defPath);

            StreamReader sr = new StreamReader(nameFile);

            bool   start = false;
            string heading01 = "", heading02 = "";

            while (!sr.EndOfStream)
            {
                string buf = sr.ReadLine();
                if (buf.Contains("HEADING LINE NO 1"))
                {
                    sr.ReadLine();
                    buf       = sr.ReadLine();
                    heading01 = buf.Trim();
                }
                if (buf.Contains("HEADING LINE NO 2"))
                {
                    sr.ReadLine();
                    buf       = sr.ReadLine();
                    heading02 = buf.Trim();
                }
            }

            sr.Close();

            List <double> pnts = new List <double>();

            sr = new StreamReader(nameFile);
            double staPrior = 0.0;
            int    k        = -1;
            double resElev  = 0;

            while (!sr.EndOfStream)
            {
                string buf = sr.ReadLine();
                if (buf.Length >= 6)
                {
                    if (buf.Substring(0, 5) == "*****")
                    {
                        start = true;
                        buf   = sr.ReadLine();
                    }
                }
                if (buf.Length >= 10)
                {
                    if (buf.Substring(0, 9) == "LICENSEE:")
                    {
                        start = false;
                    }
                }

                if (buf.Contains(heading01))
                {
                    start = false;
                }

                if (start)
                {
                    if (buf.Length >= 38)
                    {
                        string elev = buf.Substring(27, 10);
                        if (double.TryParse(elev, out resElev))
                        {
                            k += 2;
                            pnts.Add(double.Parse(buf.Substring(0, 10).Trim()));
                            pnts.Add(double.Parse(buf.Substring(27, 10).Trim()));
                            if (pnts[k - 1] == staPrior)
                            {
                                pnts[k - 1] += 0.05;
                            }
                            staPrior = pnts[k - 1];
                        }
                    }
                }
            }
            sr.Close();

            try
            {
                using (Transaction t = BaseObjs.startTransactionDb())
                {
                    for (int i = 0; i < pnts.Count; i += 2)
                    {
                        prof.PVIs.AddPVI(pnts[i], pnts[i + 1]);
                    }
                    t.Commit();
                }
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(string.Format("{0} WSP_App.cs: line: 125", ex.Message));
            }
        }
Example #7
0
File: PF.cs Project: 15831944/EM
        doProcessFigures()
        {
            bool     exists     = false;
            ObjectId idDictHist = Dict.getNamedDictionary("HISTORY", out exists);

            if (exists)
            {
                bool         def    = true;
                bool         answer = false;
                PromptStatus ps     = UserInput.getUserInputYesNo("Command PF has been executed on this drawing - Continue?", def, out answer);
                if (ps == PromptStatus.OK)
                {
                    if (answer == false)
                    {
                        return;
                    }
                }
                else
                {
                    return;
                }
            }

            if (BaseObjs._acadDocs.Count > 4)
            {
                bool         def    = false;
                bool         answer = false;
                PromptStatus ps     = UserInput.getUserInputYesNo(string.Format("There are {0} drawings open on this machine.  Do you wish to continue?", BaseObjs._acadDocs.Count.ToString()), def, out answer);
                if (ps == PromptStatus.OK)
                {
                    if (answer == false)
                    {
                        return;
                    }
                }
                else
                {
                    return;
                }
            }

            string       JN          = string.Empty;
            string       TOP         = string.Empty;
            string       nameFile    = string.Empty;
            string       nameFileMod = string.Empty;
            ResultBuffer rb          = null;

            ObjectId idDictPPF2 = Dict.getNamedDictionary("PPF2", out exists);

            if (!exists)
            {
                Application.ShowAlertDialog("Dictionary PPF2 is missing - Breaklines will be named \'TEMP\'");

                string nameFull = BaseObjs.docFullName;
                JN  = BaseObjs.docName.Substring(0, 4);
                TOP = "TEMP";
            }
            else
            {
                using (BaseObjs._acadDoc.LockDocument())
                {
                    rb = Dict.getXRec(idDictPPF2, "strTOP");
                }

                TypedValue[] tvs = rb.AsArray();

                if (tvs.Length > 0)
                {
                    JN          = tvs[0].Value.ToString();
                    TOP         = tvs[1].Value.ToString();
                    nameFile    = tvs[2].Value.ToString();
                    nameFileMod = tvs[3].Value.ToString();
                }
            }

            AeccSurveyDocument survDoc   = BaseObjsCom.aeccSurvDoc;
            AeccSurveyProjects survProjs = survDoc.Projects;
            AeccSurveyProject  survProj  = null;

            try
            {
                foreach (AeccSurveyProject sProj in survProjs)
                {
                    if (sProj.Name == JN)
                    {
                        survProj = sProj;
                        survProj.Open();
                        break;
                    }
                }
            }
            catch (System.Exception ex)
            {
                //Application.ShowAlertDialog(ex.Message + " PF.cs: line: 146");
                BaseObjs.writeDebug(ex.Message + " PF.cs: line: 146");
            }

            AeccSurveyFigures survFigures = survProj.Figures;
            List <ObjectId>   idPolys3d   = new List <ObjectId>();
            List <Node3d>     nodes3d     = new List <Node3d>();

            foreach (AeccSurveyFigure figure in survFigures)
            {
                AeccSurveyFigureNodes nodes = figure.FigureNodes;

                foreach (AeccSurveyFigureNode node in nodes)
                {
                    Node3d node3d = new Node3d(node.X, node.Y, node.Z, node.Bulge);
                    nodes3d.Add(node3d);
                }

                ObjectId idPoly3d = buildPoly3dFromNodes(nodes3d);
                Layer.setLayer(idPoly3d, figure.Layer);
                idPolys3d.Add(idPoly3d);
            }

            survProj.Close();

            TransferObjs.transferObjects(idPolys3d, TemplateCONT, nameFileMod);
            TransferObjs.transferObjects(idPolys3d, TemplateTOPO, nameFile);

            string handleLastEnt = string.Empty;

            try
            {
                handleLastEnt = idPolys3d[idPolys3d.Count - 1].getHandle().ToString();
            }
            catch (System.Exception ex)
            {
                //Application.ShowAlertDialog(ex.Message + " PF.cs: line: 176");
                BaseObjs.writeDebug(ex.Message + " PF.cs: line: 176");
            }

            CgPnt_Group.deletePntGroup(Path.GetFileName(nameFileMod));

            rb = new ResultBuffer(new TypedValue(1005, handleLastEnt));

            Dict.addXRec(idDictHist, "lastENT", rb);
        }
Example #8
0
        private void cmdSetup_Click(object sender, RoutedEventArgs e)
        {
            FolderBrowserDialog fbd = new FolderBrowserDialog();

            fbd.Description = "Browse to Project Folder";
            fbd.ShowDialog();

            string strPath = fbd.SelectedPath;

            int intPosX = 1, intPos = 0;

            if (strPath == "")
            {
                System.Windows.MessageBox.Show("No Folder Selected");
                return;
            }
            else
            {
                while (intPosX != 0)
                {
                    intPos  = intPosX + 1;
                    intPosX = (short)(strPath.IndexOf("\\", intPos - 1) + 1);
                }
            }

            string strJN = strPath.Substring(intPos - 1);

            strPath = string.Format("{0}\\{1}EW.dwg", strPath, strJN);

            if (FileSystem.FileExists(strPath))
            {
                MessageBoxResult varResponse = System.Windows.MessageBox.Show(string.Format("File {0} exists! Make Backup??", strPath), "File Exists!", MessageBoxButton.YesNoCancel);

                if (varResponse == MessageBoxResult.Yes)
                {
                    FileInfo fileInfo;

                    fileInfo = FileSystem.GetFileInfo(strPath);

                    string strDateCreated = (fileInfo.LastAccessTime).ToString();
                    intPos         = (short)(strDateCreated.IndexOf(" ") + 1);
                    strDateCreated = strDateCreated.Substring(0, intPos - 1);
                    strDateCreated = strDateCreated.Replace("/", "_");
                    intPos         = strPath.IndexOf(".");

                    FileSystem.CopyFile(strPath, string.Format("{0}_{1}.dwg", strPath.Substring(0, intPos - 1), strDateCreated));
                    FileSystem.DeleteFile(strPath);
                }
                else if (varResponse == MessageBoxResult.No)
                {
                    FileSystem.DeleteFile(strPath);
                }
                else if (varResponse == MessageBoxResult.Cancel)
                {
                    return;
                }
            }

            using (BaseObjs._acadDoc.LockDocument()) {
                Document objDwgEW = DocumentCollectionExtension.Add(BaseObjs._acadDocs, @"R:\TSET\Template\CIVIL3D2015\EW.dwt");
                BaseObjs._acadDoc.Database.SaveAs(strPath, true, DwgVersion.Current, BaseObjs._acadDoc.Database.SecurityParameters);
            }

            using (BaseObjs._acadDoc.LockDocument()) {
                xRef.doMXR();
            }
            Point3d pnt3dUR = BaseObjs._acadDoc.Database.Extmax;

            SelectionSet objSSet = EW_Utility1.buildSSetTable();

            ObjectId[] ids = objSSet.GetObjectIds();
            if (ids == null || ids.Length == 0)
            {
                return;
            }

            Table tbl = null;

            using (BaseObjs._acadDoc.LockDocument()) {
                ObjectId id = ids[0];
                try {
                    using (Transaction tr = BaseObjs.startTransactionDb()) {
                        tbl = (Table)tr.GetObject(id, OpenMode.ForWrite);
                        Extents3d ext3d = (Extents3d)tbl.Bounds;
                        tbl.TransformBy(Matrix3d.Displacement(new Vector3d(pnt3dUR.X, pnt3dUR.Y, 0)));

                        objSSet = Base_Tools45.Select.buildSSet(typeof(Polyline), ext3d.MinPoint, ext3d.MaxPoint);
                        ids     = objSSet.GetObjectIds();
                        ObjectIdCollection idsm = new ObjectIdCollection();
                        foreach (ObjectId idm in ids)
                        {
                            idsm.Add(idm);
                        }
                        idsm.moveObjs(Point3d.Origin, pnt3dUR);

                        tr.Commit();
                    }
                }
                catch (System.Exception ex) {
                    BaseObjs.writeDebug(string.Format("{0} frmEarthwork.cs: line: 137", ex.Message));
                }

                Layer.manageLayers("0");

                string strDwgName = BaseObjs.docName;
                intPos     = strDwgName.IndexOf(".") + 1;
                strDwgName = strDwgName.Substring(0, intPos - 1);
                BlockReference blkRef;

                blkRef = xRef.getXRefBlockReference("CNTL");
                if (blkRef != null)
                {
                    string strBlkName = blkRef.Name;

                    BaseObjs._acadDoc.SendStringToExecute(string.Format("-LA\rF\r{0}*\r\r", strBlkName), true, false, false);

                    BaseObjs._acadDoc.SendStringToExecute(string.Format("-LA\rT\r{0}|CURB\r\r", strBlkName), true, false, false);
                    BaseObjs._acadDoc.SendStringToExecute(string.Format("-LA\rT\r{0}|GB\r\r", strBlkName), true, false, false);
                    BaseObjs._acadDoc.SendStringToExecute(string.Format("-LA\rT\r{0}|BLDG\r\r", strBlkName), true, false, false);
                    BaseObjs._acadDoc.SendStringToExecute(string.Format("-LA\rT\r{0}|FL\r\r", strBlkName), true, false, false);
                    BaseObjs._acadDoc.SendStringToExecute(string.Format("-LA\rT\r{0}|FS\r\r", strBlkName), true, false, false);
                    BaseObjs._acadDoc.SendStringToExecute(string.Format("-LA\rT\r{0}|GUTTER\r\r", strBlkName), true, false, false);
                    BaseObjs._acadDoc.SendStringToExecute(string.Format("-LA\rT\r{0}|WALL\r\r", strBlkName), true, false, false);
                }

                blkRef = xRef.getXRefBlockReference("BNDRY");
                if (blkRef != null)
                {
                    string strBlkName = blkRef.Name;

                    BaseObjs._acadDoc.SendStringToExecute(string.Format("-LA\rF\r{0}*\r\r", strBlkName), true, false, false);
                    BaseObjs._acadDoc.SendStringToExecute(string.Format("-LA\rT\r{0}|PL\r\r", strBlkName), true, false, false);
                }

                View.ZoomExtents();
            }
            System.Windows.Forms.MessageBox.Show("User needs to create data shortcut for Surfaces: CPNT-ON and EXIST");
        }
Example #9
0
File: cmdBC.cs Project: 15831944/EM
        getUserInput(string nameCmd)
        {
            bool          escape    = false;
            List <double> userInput = new List <double>();

            try
            {
                TypedValue[] TVs    = null;
                ResultBuffer RB     = null;
                bool         exists = false;
                if (nameCmd == "cmdABG")
                {
                    nameCmd = "cmdBG";
                }

                if (nameCmd == "cmdABC")
                {
                    nameCmd = "cmdBC";
                }

                ObjectId idDict = Dict.getNamedDictionary(nameCmd, out exists);
                if (!exists)
                {
                    userInput.Add(0.5);
                    userInput.Add(1.5);
                    userInput.Add(0.02);

                    userInput.Add(1.5);
                    userInput.Add(0.1875);

                    TVs = new TypedValue[userInput.Count];
                    for (int i = 0; i < userInput.Count; i++)
                    {
                        TVs.SetValue(new TypedValue(1040, userInput[i]), i);
                    }
                    RB = new ResultBuffer(TVs);
                    Dict.addXRec(idDict, "cmdDefault", RB);
                }
                else
                {
                    RB  = Dict.getXRec(idDict, "cmdDefault");
                    TVs = RB.AsArray();
                    for (int i = 0; i < TVs.Length; i++)
                    {
                        if (TVs[i].Value.ToString() != "")
                        {
                            userInput.Add(Convert.ToDouble(TVs[i].Value));
                        }
                        else
                        {
                            switch (i)
                            {
                            case 0:
                            case 1:
                            case 2:
                                break;

                            case 3:
                                userInput.Add(1.5);
                                break;

                            case 4:
                                userInput.Add(0.1875);
                                break;
                            }
                        }
                    }
                }

                if (RB != null)
                {
                    string message1 = "Curb Height: ";
                    string message2 = "\nBench Width: ";
                    string message3 = "\nBench Slope: ";

                    string message = string.Format("{0}{1}{2}{3}{4}{5}", message1.PadRight(50), userInput[0].ToString(), message2.PadRight(49), userInput[1].ToString(), message3.PadRight(50), userInput[2].ToString());
                    if (nameCmd == "cmdBG")
                    {
                        string message4 = "\nGutter Width: ";
                        string message5 = "\nGutter Vertical Difference: ";

                        message = string.Format("{0}{1}{2}{3}{4}", message, message4.PadRight(50), userInput[3].ToString(), message5.PadRight(42), userInput[4].ToString());
                    }

                    var response = MessageBox.Show(message, "Accept Current Settings?", MessageBoxButtons.YesNoCancel);
                    if (response == DialogResult.Yes)
                    {
                        return(userInput);
                    }
                    if (response == DialogResult.Cancel)
                    {
                        return(null);
                    }
                }
                double value = 0;
                escape = UserInput.getUserInput("\nEnter Curb Height in Feet: ", out value, Convert.ToDouble(userInput[0]));
                if (escape)
                {
                    return(null);
                }
                userInput[0] = value;
                escape       = UserInput.getUserInput("\nEnter Bench Width in feet (from Back of Curb to Grade Break): ", out value, Convert.ToDouble(userInput[1]));
                if (escape)
                {
                    return(null);
                }
                userInput[1] = value;
                escape       = UserInput.getUserInput("\nEnter Bench Slope: ", out value, Convert.ToDouble(userInput[2]));
                if (escape)
                {
                    return(null);
                }
                userInput[2] = value;

                if (nameCmd == "cmdBG")
                {
                    escape = UserInput.getUserInput("\nEnter Gutter Width in feet (distance from Curb Line to Edge of Pavement: ", out value, Convert.ToDouble(userInput[3]));
                    if (escape)
                    {
                        return(null);
                    }
                    userInput[3] = value;
                    escape       = UserInput.getUserInput("\nEnter Vert. Diff (FL to Lip of Gutter/Edge of Pavement: ", out value, Convert.ToDouble(userInput[4]));
                    if (escape)
                    {
                        return(null);
                    }
                    userInput[4] = value;
                }

                Dict.deleteXRec(idDict, "cmdDefault");

                TVs = new TypedValue[userInput.Count];

                for (int i = 0; i < userInput.Count; i++)
                {
                    TVs.SetValue(new TypedValue(1040, userInput[i]), i);
                }
                RB = new ResultBuffer(TVs);
                Dict.addXRec(idDict, "cmdDefault", RB);
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " cmdBC.cs: line: 310");
            }

            return(userInput);
        }
Example #10
0
File: cmdBC.cs Project: 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");
            }
        }
Example #11
0
        XO()
        {
            object  objOffset = Application.GetSystemVariable("OFFSETDIST");
            Point3d pnt3dBeg = Pub.pnt3dO;
            Point3d pnt3dEnd = Pub.pnt3dO;
            Point3d pnt3dCen, pnt3dX;
            string  defPrompt;

            if (objOffset.ToString() == "-1")
            {
                defPrompt = "Through";
            }
            else
            {
                defPrompt = objOffset.ToString();
            }

            double disX = 0.0, offset = 0.0, radius = 0.0;

            bool   through = false;
            string result, prompt = "\nSpecify Offset distance or [Through]: ";

            UserInput.getUserInput(defPrompt, prompt, out result, false);
            if (result == string.Empty)
            {
                return;
            }

            Point3d  pnt3dPick = Pub.pnt3dO;
            string   nameLayer = string.Empty;
            ObjectId idBlkRef  = ObjectId.Null;
            ObjectId idEnt     = xRef.getEntity("\nSelect object to offset or <exit>: ", true, out nameLayer, out pnt3dPick, out idBlkRef);

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

            PromptStatus ps = PromptStatus.Cancel;

            if (result.ToUpper() == "THROUGH" || result.ToUpper() == "T")
            {
                through = true;
                pnt3dX  = UserInput.getPoint("\nSpecify Offset point : ", out ps, osMode: 0);
            }
            else
            {
                offset = double.Parse(result);
                Application.SetSystemVariable("OFFSETDIST", offset);
                if (offset == 0)
                {
                    idEnt.copy("0");
                    return;
                }
                else
                {
                    pnt3dX = UserInput.getPoint("\nSpecify point on side to offset: ", out ps, osMode: 0);
                }
            }
            bool rh = true;

            string typeEnt = idEnt.getType();

            switch (typeEnt)
            {
            case "Polyline":
                double bulge = 0.0;
                try
                {
                    using (Transaction tr = BaseObjs.startTransactionDb())
                    {
                        Polyline poly = (Polyline)tr.GetObject(idEnt, OpenMode.ForRead);
                        if (poly.Closed)
                        {
                            idEnt.checkIfClosed();
                        }
                        int vtx = Geom.getVertexNo(idEnt, pnt3dX);
                        pnt3dBeg = poly.GetPoint3dAt(vtx);
                        pnt3dEnd = poly.GetPoint3dAt(vtx + 1);
                        bulge    = poly.GetBulgeAt(vtx);
                        tr.Commit();
                    }
                }
                catch (System.Exception ex)
                {
                    BaseObjs.writeDebug(ex.Message + " cmdXO.cs: line: 86");
                }
                if (bulge == 0.0)
                {
                    processLine(pnt3dBeg, pnt3dEnd, pnt3dX, through, disX, ref offset);
                }
                else
                {
                    if (bulge < 0)
                    {
                        rh = false;
                    }
                    pnt3dCen = Geom.getCenter(pnt3dBeg, pnt3dEnd, bulge);

                    if (!processArc(pnt3dBeg, pnt3dEnd, pnt3dCen, pnt3dX, through, radius, rh, idEnt, disX, ref offset))
                    {
                        return;
                    }
                }
                break;

            case "Line":
                Line line = (Line)idEnt.getEnt();
                pnt3dBeg = line.StartPoint;
                pnt3dEnd = line.EndPoint;
                processLine(pnt3dBeg, pnt3dEnd, pnt3dX, through, disX, ref offset);
                break;

            case "Arc":
                Arc arc = (Arc)idEnt.getEnt();
                pnt3dBeg = arc.StartPoint;
                pnt3dEnd = arc.EndPoint;
                pnt3dCen = arc.Center;
                radius   = arc.Radius;
                Vector3d v3d = arc.Normal;
                if (v3d.Z < 0)
                {
                    rh = false;
                }

                if (!processArc(pnt3dBeg, pnt3dEnd, pnt3dCen, pnt3dX, through, radius, rh, idEnt, disX, ref offset))
                {
                    return;
                }
                break;
            }
            idEnt.offset(offset);
            idEnt.delete();
        }
Example #12
0
        initializeBrklines()
        {
            string handleBrkLine = string.Empty;
            bool   exists        = false;

            try
            {
                AeccTinSurface surf = mySurfaces.getAeccTinSurface("CPNT-ON", ref exists);
                if (!exists)
                {
                    handleBrkLine = "0000";
                    return(handleBrkLine);
                }
                if (surf.Breaklines.Count == 0)
                {
                    handleBrkLine = "0000";
                    return(handleBrkLine);
                }
                myUtility.deleteAeccBreaklines(surf);
                TypedValue[] TVs = new TypedValue[5];
                TVs.SetValue(new TypedValue((int)DxfCode.Operator, "<OR"), 0);
                TVs.SetValue(new TypedValue((int)DxfCode.Start, "LINE"), 1);
                TVs.SetValue(new TypedValue((int)DxfCode.Start, "POLYLINE"), 2);
                TVs.SetValue(new TypedValue((int)DxfCode.Operator, "OR>"), 3);
                TVs.SetValue(new TypedValue((int)DxfCode.LayerName, "CPNT-BRKLINE"), 4);

                ObjectIdCollection idsObj = new ObjectIdCollection();
                SelectionSet       ss     = Select.buildSSet(TVs);
                ObjectId[]         ids    = ss.GetObjectIds();

                try
                {
                    using (Transaction tr = BaseObjs.startTransactionDb())
                    {
                        foreach (ObjectId id in ids)
                        {
                            Entity ent = (Entity)tr.GetObject(id, OpenMode.ForRead);
                            if (ent.GetType() != typeof(Polyline3d))
                            {
                                Misc.deleteObj(ent.ObjectId);
                            }
                            else
                            {
                                idsObj.Add(id);
                            }
                        }
                        tr.Commit();
                    }
                }
                catch (System.Exception ex)
                {
                    BaseObjs.writeDebug(ex.Message + " cmdABL.cs: line: 211");
                }

                myUtility.addAeccBreaklines(surf, idsObj, "BRK-00");

                handleBrkLine = Db.idObjToHandle(idsObj[idsObj.Count - 1]).ToString();
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " cmdABL.cs: line: 220");
            }
            return(handleBrkLine);
        }
Example #13
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);
        }