Beispiel #1
0
        insertCurve(ObjectId idAlign)
        {
            Alignment align = (Alignment)idAlign.getEnt();
            AlignmentEntityCollection ents = align.Entities;
            PromptStatus ps;
            Point3d      pnt3dPick = UserInput.getPoint("Select Curve PI", out ps, osMode: 1);

            AlignmentEntity lineBefore = null;
            AlignmentEntity lineAfter  = null;

            for (int i = 0; i < ents.Count; i++)
            {
                AlignmentEntity ent = ents[i];
                if (ent.EntityType == AlignmentEntityType.Line)
                {
                    AlignmentLine line = (AlignmentLine)ent;
                    if (line.EndPoint.IsEqualTo(pnt3dPick.Convert2d(BaseObjs.xyPlane), new Tolerance(.01, .01)))
                    {
                        lineBefore = line;
                    }
                    if (line.StartPoint.IsEqualTo(pnt3dPick.Convert2d(BaseObjs.xyPlane), new Tolerance(.01, .01)))
                    {
                        lineAfter = line;
                    }
                }
            }

            AlignmentArc       arc         = ents.AddFreeCurve(lineBefore.EntityId, lineAfter.EntityId, 200.0, CurveParamType.Radius, false, CurveType.Compound);
            List <AlgnEntData> algnEntData = sortAlignEnts(align);

            fAlignEnts.updateForm(algnEntData);
            fAlignEnts.AlignHandle = align.Handle;
            Application.ShowModelessDialog(Application.MainWindow.Handle, fAlignEnts, false);
        }
Beispiel #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="align"></param>
        private void enumerateEntsByOrder(Alignment align)
        {
            AlignmentEntityCollection ents = align.Entities;

            for (int i = 0; i < ents.Count; i++)
            {
                AlignmentEntity ent = ents.GetEntityByOrder(i);
                BaseObjs.write(string.Format("\n.. Entity Sequence: {0}", i));
                writeAlignData(ent);
            }
        }
Beispiel #3
0
        private void enumerateEntitiesByOrder(Alignment alignment)
        {
            AlignmentEntityCollection entities = alignment.Entities;

            for (int i = 0; i < entities.Count; i++)
            {
                AlignmentEntity entity = entities.GetEntityByOrder(i);
                write("\n.. Entity ID: " + entity.EntityId);
                write("\n.. Entity Sequence: " + i);
                write("\n.. Entity Class: " + entity.GetType());
                write("\n.. Entity Type: " + entity.EntityType);
                write("\n.. Subentities: " + entity.SubEntityCount);
            }
        }
Beispiel #4
0
        getAlignEntData(Alignment align)
        {
            List <AlgnEntData>        algnData = new List <AlgnEntData>();
            AlignmentEntityCollection ents     = align.Entities;

            foreach (AlignmentEntity ent in ents)
            {
                AlgnEntData aData = new AlgnEntData();
                if (ent.EntityType == AlignmentEntityType.Arc)
                {
                    AlignmentArc arc = (AlignmentArc)ent;
                    aData.ID     = arc.EntityId;
                    aData.Type   = "Arc";
                    aData.StaBeg = arc.StartStation;
                    aData.StaEnd = arc.EndStation;
                    aData.Length = arc.Length;
                    aData.Radius = arc.Radius;
                    try
                    {
                        aData.EntBefore = arc.EntityBefore;
                    }
                    catch
                    {
                        aData.EntBefore = 0;
                    }
                }
                else if (ent.EntityType == AlignmentEntityType.Line)
                {
                    AlignmentLine line = (AlignmentLine)ent;
                    aData.ID     = line.EntityId;
                    aData.Type   = "Line";
                    aData.StaBeg = line.StartStation;
                    aData.StaEnd = line.EndStation;
                    aData.Length = line.Length;
                    aData.Radius = 0;
                    try
                    {
                        aData.EntBefore = line.EntityBefore;
                    }
                    catch
                    {
                        aData.EntBefore = 0;
                    }
                }
                algnData.Add(aData);
            }
            return(algnData);
        }
Beispiel #5
0
        //EntityId + Constraint.
        private void GetAlignmentEntitiesInfo(String alignmentName)
        {
            ObjectId  alignOid = doc.GetSitelessAlignmentId(alignmentName);
            Alignment align    = ts.GetObject(alignOid, OpenMode.ForRead) as Alignment;

            m_editor.WriteMessage("\n---------User Story 4 :Alignment Entities properties- begin----------------\n");

            AlignmentEntityCollection alignColl = align.Entities;
            int count   = alignColl.Count;
            int alignID = alignColl.FirstEntity;

            while (true)
            {
                AlignmentEntity alignEntity = alignColl.EntityAtId(alignID);
                Debug.Assert(alignID == alignEntity.EntityId);

                //m_editor.WriteMessage("Alignment EntityId : {0}  Constraint : {1}\n", alignEntity.EntityId, alignEntity.Constraint);
                if (alignID == alignColl.LastEntity)
                {
                    break;
                }
                alignID = alignEntity.EntityAfter;
            }
        }
Beispiel #6
0
        changeAlignStartPoint()
        {
            //BEGIN: UPDATE PROFILE, TABLE, AND POIs

            AlgnData  algnData = new AlgnData();
            ObjectId  idAlign  = ObjectId.Null;
            Alignment objAlign = null;

            if (selectAlignment(idAlign))
            {
                objAlign = fStake.ACTIVEALIGN;
            }
            else
            {
                return;
            }

            objAlign = fStake.ACTIVEALIGN;
            AlignmentEntityCollection objAlignEnts = objAlign.Entities;

            //BEGIN: UPDATE PROFILE, TABLE, AND POIs
            double       dblLenAlign = objAlign.Length;
            PromptStatus ps;
            Point3d      varPnt = UserInput.getPoint("Select Desired Start Point", out ps, osMode: 0);

            double dblStation = 0, dblOffset = 0;

            idAlign.getAlignStaOffset(varPnt, ref dblStation, ref dblOffset);
            double dblStationStart = objAlign.StartingStation;
            double dblStationDelta = dblStation - dblStationStart;
            // if varPnt is out of range then dblStation returns ZERO

            Profile profFLOWLINE      = Prof.getProfile(idAlign, "FLOwLINE");
            ProfilePVICollection pvis = profFLOWLINE.PVIs;

            List <POI> varPOI_Temp = new List <POI>();

            foreach (ProfilePVI pvi in pvis)
            {
                POI poi = new POI {
                    Station = Math.roundDown3(pvi.Station), Elevation = pvi.Elevation
                };
                varPOI_Temp.Add(poi);
            }

            Debug.Print("varPOI_Temp Before");
            for (int i = 0; i < varPOI_Temp.Count; i++)
            {
                Debug.Print(varPOI_Temp[i].Station + "  " + varPOI_Temp[i].Elevation);
            }

            //adjust POI_Temp stationing

            for (int i = 0; i < varPOI_Temp.Count; i++)
            {
                POI poi = varPOI_Temp[i];
                if (poi.Station < dblStationDelta + dblStationStart)
                {
                    poi.Station = Math.roundDown3(dblLenAlign + varPOI_Temp[i].Station);
                }
                else
                {
                    poi.Station = Math.roundDown3(varPOI_Temp[i].Station - dblStationDelta);
                }
                varPOI_Temp[i] = poi;
            }

            List <POI> poiTmp       = new List <POI>();
            var        sortPOI_Temp = from t in varPOI_Temp
                                      orderby t.Station ascending
                                      select t;

            foreach (var t in sortPOI_Temp)
            {
                poiTmp.Add(t);
            }
            varPOI_Temp = poiTmp;

            int k = varPOI_Temp.Count;

            POI poitemp = varPOI_Temp[k - 1];

            poitemp.Elevation = varPOI_Temp[0].Elevation;
            varPOI_Temp[k]    = poitemp;

            Debug.Print("varPOI_Temp After");
            for (int i = 0; i < k; i++)
            {
                Debug.Print(varPOI_Temp[i].Station + "  " + varPOI_Temp[i].Elevation);
            }

            //END: UPDATE PROFILE, TABLE, AND POIs

            ObjectId idPoly = objAlign.GetPolyline();
            Polyline poly   = (Polyline)idPoly.getEnt();

            string   strAlignName = objAlign.Name;
            AlgnData aData;

            for (int j = 1; j < fStake.algnData.Count; j++)
            {
                aData = fStake.algnData[j];
                if (aData.AlignHandle == objAlign.Handle)
                {
                    break;
                }
            }

            objAlign.ReferencePointStation = 100.0;

            foreach (AlignmentEntity ent in objAlignEnts)
            {
                objAlignEnts.Remove(ent);
            }

            List <Vertex2d> v2ds = Conv.poly_Vertex2dList(idPoly);

            int p = 0;

            foreach (Vertex2d v in v2ds)
            {
                if (v.Position.IsEqualTo(varPnt, new Tolerance(0, 0)))
                {
                    break;
                }
                p++;
            }

            List <Vertex2d> v2dsNew = new List <Vertex2d>();

            for (int i = p; i < v2ds.Count; i++)
            {
                v2dsNew.Add(v2ds[i]);
            }

            for (int i = 1; i < p; i++)
            {
                v2dsNew.Add(v2ds[i]);
            }
            v2dsNew.Add(v2ds[p]);

            int     lngID = 0;
            Point3d dblPntBeg = Pub.pnt3dO, dblPntEnd = Pub.pnt3dO, dblPntMid = Pub.pnt3dO;

            for (int i = 1; i < v2dsNew.Count; i++)
            {
                if (v2dsNew[i].Bulge == 0)
                {
                    dblPntBeg = v2dsNew[i - 1].Position;
                    dblPntEnd = v2dsNew[i = 0].Position;

                    AlignmentLine objAlignEntTan = objAlign.Entities.AddFixedLine(lngID, dblPntBeg, dblPntEnd);
                    lngID = objAlignEntTan.EntityId;
                }
                else
                {
                    dblPntBeg = v2dsNew[i - 1].Position;
                    dblPntEnd = v2dsNew[i = 0].Position;

                    int intDir = 0;

                    if (v2dsNew[i - 1].Bulge > 0)
                    {
                        intDir = 1;
                    }
                    else
                    {
                        intDir = -1;
                    }

                    Arc arc = (Arc)Arc.Create(IntPtr.Zero, true);
                    arc.StartPoint = dblPntBeg;
                    arc.EndPoint   = dblPntEnd;

                    Point3d pnt3dMidLC = dblPntBeg.getMidPoint3d(dblPntEnd);
                    double  lenLC      = dblPntBeg.getDistance(dblPntEnd);
                    double  dirLC      = dblPntBeg.getDirection(dblPntEnd);
                    double  lenM       = System.Math.Abs(lenLC / 2 * v2dsNew[i - 1].Bulge);
                    dblPntMid = pnt3dMidLC.traverse(dirLC + System.Math.PI / 2 * intDir, lenM);

                    AlignmentArc objAlignEntArc = objAlign.Entities.AddFixedCurve(lngID, dblPntBeg, dblPntMid, dblPntEnd);
                    lngID = objAlignEntArc.EntityId;
                }
            }

            objAlign.Update();
            objAlign.ReferencePoint        = varPnt.Convert2d(BaseObjs.xyPlane);
            objAlign.ReferencePointStation = System.Math.Round(100.0 + dblStationDelta, 3);

            //BEGIN: UPDATE PROFILE, TABLE, AND POIs
            List <POI> varpoi = fStake.POI_CALC;

            //POIs are updated when selectAlignment is executed

            //ADJUST POI STATIONING
            //need complete POIs for descriptions
            for (int i = 0; i < varpoi.Count; i++)
            {
                if (varpoi[i].Station < dblStationDelta + dblStationStart)
                {
                    varpoi[i].Station = Math.roundDown3(dblLenAlign + varpoi[i].Station);
                }
                else
                {
                    varpoi[i].Station = Math.roundDown3(varpoi[i].Station - dblStationDelta);
                }
            }

            varpoi = varpoi.sortPOIbyStation();

            int n = varpoi.Count;

            varpoi[0].DescX     = "BEG " + varpoi[0].Desc0;
            varpoi[n - 2].DescX = varpoi[n - 2].DescX.Replace("END", "").Trim();
            varpoi[n - 1].DescX = varpoi[n - 1].DescX.Replace("BEG", "END").Trim();

            if (fStake.ClassObj == "CURB")
            {
                Stake_AddProfile.makeProfile(idAlign, varPOI_Temp, "CURB", "ByLayout", true);
            }

            ObjectId idTable = Stake_Table.makeTable(idAlign, varpoi);

            Stake_Table.addTableData(idTable, varpoi);

            if (Stake_GetBC_EC.getBC_EC(idAlign, ref varpoi) == false)
            {
                return;
            }

            fStake.POI_CALC = varpoi;
            //END: UPDATE PROFILE, TABLE, AND POIs
        }
Beispiel #7
0
        makeBaseline()
        {
            Layer.manageLayers("GRADING LIMIT");
            Layer.manageLayers("SECTIONS");

            SelectionSet objSSet = EW_Utility1.buildSSetGradingLim();
            Entity       ent     = objSSet.GetObjectIds()[0].getEnt();
            ObjectId     idLim   = ent.ObjectId;

            double    dblStationBase = 0;
            bool      boolUseBase;
            Alignment objAlignBASE = null;
            Alignment objAlign     = Align.getAlignment("BASE");

            if (objAlign != null)
            {
                DialogResult varResponse = MessageBox.Show("Use existing BASE alignment for sections?", "", MessageBoxButtons.YesNo);

                if (varResponse == DialogResult.Yes)
                {
                    objAlignBASE   = objAlign;
                    dblStationBase = objAlignBASE.StartingStation;

                    objAlign    = null;
                    boolUseBase = true;
                }
                else
                {
                    boolUseBase   = false;
                    objAlign.Name = "BASE_old";
                }
            }
            else
            {
                boolUseBase = false;
            }
            List <Point3d> varPntInts = new List <Point3d>();
            ObjectId       idLWPline = ObjectId.Null, idLine = ObjectId.Null;
            double         dblAng = 0;
            bool           exists;
            Point3d        pnt3dCEN = Pub.pnt3dO, pnt3dTAR = Pub.pnt3dO, dPntBeg = Pub.pnt3dO, dPntEnd = Pub.pnt3dO;

            if (!boolUseBase)
            {
                ObjectId idDictGRADEDOCK = Dict.getNamedDictionary("GRADEDOCK", out exists);

                if (!exists)
                {
                    Application.ShowAlertDialog("GRADEDOCK Dictionary missing. Create alignment BASE and try again.");
                    return;
                }
                else
                {
                    ResultBuffer rb  = Dict.getXRec(idDictGRADEDOCK, "CENTROID");
                    TypedValue[] tvs = rb.AsArray();

                    pnt3dCEN = new Point3d(double.Parse(tvs[0].Value.ToString()),
                                           double.Parse(tvs[1].Value.ToString()),
                                           double.Parse(tvs[2].Value.ToString()));

                    rb  = Dict.getXRec(idDictGRADEDOCK, "TARGET");
                    tvs = rb.AsArray();

                    pnt3dTAR = new Point3d(double.Parse(tvs[0].Value.ToString()),
                                           double.Parse(tvs[1].Value.ToString()),
                                           double.Parse(tvs[2].Value.ToString()));
                }

                idLine = Draw.addLine(pnt3dCEN, pnt3dTAR);

                varPntInts = idLine.intersectWith(idLim, extend.source);
                idLine.delete();

                dPntBeg = varPntInts[0];
                dPntEnd = varPntInts[1];

                dblAng = dPntBeg.getDirection(dPntEnd);

                if (dblAng > pi / 2 & dblAng <= 3 * pi / 2)
                {
                    varPntInts.Reverse();
                    dPntBeg = varPntInts[0];
                    dPntEnd = varPntInts[1];

                    dblAng = Measure.getAzRadians(dPntBeg, dPntEnd);
                }

                idLWPline = Draw.addPoly(varPntInts);

                dblStationBase = 0;
            }

            Point3d pnt3dB = dPntBeg.traverse(dblAng, 10);
            Point3d pnt3dE = dPntEnd.traverse(dblAng, 10);
            Point3d pnt3dM = pnt3dB.getMidPoint3d(pnt3dE);

            if ((objAlignBASE == null))
            {
                objAlignBASE = Align.addAlignmentFromPoly("BASE", "SECTIONS", idLWPline, "Standard", "Standard", true, true);
            }

            AlignmentEntityCollection ents = objAlignBASE.Entities;

            AlignmentEntity objAlignEnt = ents[0];

            if (objAlignEnt.EntityType == AlignmentEntityType.Line)
            {
                AlignmentLine objAlignEntTan = (AlignmentLine)objAlignEnt;
                Point2d       pnt2dBeg       = objAlignEntTan.StartPoint;
                Point2d       pnt2dEnd       = objAlignEntTan.EndPoint;

                dblAng = pnt2dBeg.getDirection(pnt2dEnd);
            }

            int    j = -1;
            double easting = 0, northing = 0;
            double dblOffR = 0, dblOffL = 0;

            while (dblStationBase < objAlignBASE.Length)
            {
                j = j + 1;
                dblStationBase = dblStationBase + j * 50;
                objAlignBASE.PointLocation(dblStationBase, 0.0, ref easting, ref northing);
                Point3d pnt3dX      = new Point3d(easting, northing, 0);
                Point3d varPntPolar = pnt3dX.traverse(dblAng + pi / 2, 100.0);
                idLine     = Draw.addLine(pnt3dX, varPntPolar);
                varPntInts = idLine.intersectWith(idLim, extend.source);
                idLine.delete();

                StaOff sOff = new StaOff();
                sOff.Sta = dblStationBase;
                double dblStation = 0, dblOffset = 0;

                for (int k = 0; k < varPntInts.Count; k++)
                {
                    objAlignBASE.StationOffset(varPntInts[k].X, varPntInts[k].Y, ref dblStation, ref dblOffset);

                    if (dblOffset >= 0)
                    {
                        sOff.R = dblOffset;
                    }
                    else
                    {
                        sOff.L = System.Math.Abs(dblOffset);
                    }

                    if (sOff.R > dblOffR)
                    {
                        dblOffR = sOff.R;
                    }

                    if (sOff.L > dblOffL)
                    {
                        dblOffL = sOff.L;
                    }

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

            double dblRem = dblOffL % 10;

            if (dblRem < 5)
            {
                dblOffL = System.Math.Round(dblOffL / 10, 0) * 10 + 10;
            }
            else
            {
                dblOffL = System.Math.Round(dblOffL / 10, 0) * 10;
            }

            dblRem = dblOffR % 10;

            if (dblRem < 5)
            {
                dblOffR = System.Math.Round(dblOffR / 10, 0) * 10 + 10;
            }
            else
            {
                dblOffR = System.Math.Round(dblOffR / 10, 0) * 10;
            }

            EW_CmdSections.cmdSections(objAlignBASE.ObjectId, dblOffR, dblOffL);
        }
 /// <summary>
 /// Initialzies the enumerator using the entity collection.
 /// </summary>
 /// <param name="entities">Alignment entity collection to enumerate.
 /// </param>
 internal ByEntityIdEnumerator(AlignmentEntityCollection entities)
 {
     m_TheEntities = entities;
     m_Enumerator  = m_TheEntities.GetEnumerator();
 }
 /// <summary>
 /// Initializes the policy object with the current entity collection
 /// for the alignment.
 /// </summary>
 /// <param name="entities">Entities to enunmerate.</param>
 public void Initialize(AlignmentEntityCollection entities)
 {
     m_TheEntities = entities;
 }
Beispiel #10
0
        getBC_EC(ObjectId idAlign, ref List <POI> varpoi)
        {
            bool      boolExists = false;
            Profile   objProfile = null;
            Alignment objAlign   = (Alignment)idAlign.getEnt();

            try
            {
                objProfile = Prof.getProfile(idAlign, "FLOWLINE");
            }
            catch (System.Exception)
            {
                objProfile = Prof.getProfile(idAlign, "STAKE");
            }

            string strClass = fStake.ClassObj;

            AlignmentEntityCollection objAlignEnts = objAlign.Entities;
            bool isRightHand = false;

            if (objAlignEnts.Count > 1)
            {
                for (int i = 0; i < objAlignEnts.Count; i++)
                {
                    AlignmentEntity objAlignEnt = objAlignEnts[i];

                    if (objAlignEnt.EntityType == AlignmentEntityType.Arc)
                    {
                        boolExists = false;

                        AlignmentArc objAlignEntArc = (AlignmentArc)objAlignEnt;

                        isRightHand = !(objAlignEntArc.Clockwise);
                        double dblStationBC = System.Math.Round(objAlignEntArc.StartStation, 3);

                        int x = 0;
                        for (int j = 0; j < varpoi.Count; j++)
                        {
                            if (System.Math.Abs(varpoi[j].Station - dblStationBC) < 0.05)
                            {
                                boolExists = true;
                                x          = j;
                                break;
                            }
                        }

                        double  dblBulge     = 0;
                        double  dblAngDirCen = objAlignEntArc.StartPoint.getDirection(objAlignEntArc.CenterPoint);//direction to center of arc
                        double  dblAngDelta  = objAlignEntArc.Delta;
                        double  dblRadius    = System.Math.Round(objAlignEntArc.Radius, 2);
                        Point2d dblPntCen    = objAlignEntArc.CenterPoint;

                        if (boolExists)
                        {
                            dblBulge = System.Math.Tan(objAlignEntArc.Delta / 4);

                            if (objAlignEntArc.Clockwise)
                            {
                                dblBulge = dblBulge * -1.0;
                            }

                            POI vpoi = varpoi[x];

                            vpoi.Station = Math.roundDown3(dblStationBC);
                            if (vpoi.Desc0 == "EC")
                            {
                                vpoi.Desc0 = "PCC";
                            }
                            else
                            {
                                vpoi.Desc0 = "BC";
                            }
                            vpoi.AngDir      = dblAngDirCen;
                            vpoi.isRightHand = isRightHand;
                            vpoi.Bulge       = dblBulge;
                            vpoi.Radius      = dblRadius;
                            vpoi.CenterPnt   = new Point3d(dblPntCen.X, dblPntCen.Y, 0);

                            varpoi[x] = vpoi;
                        }
                        else
                        {
                            string strDesc = "BC";
                            double dblElev = 0;

                            try
                            {
                                dblElev = objProfile.ElevationAt(dblStationBC);
                            }
                            catch (System.Exception)
                            {
                                try
                                {
                                    dblElev = objProfile.ElevationAt(dblStationBC + 0.05);
                                }
                                catch (System.Exception)
                                {
                                    idAlign.delete();
                                    Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog(string.Format("Design Point not found at beginning of Arc @ {0:###+00.00} - revise and retry - exiting", dblStationBC));
                                    return(false);
                                }
                            }

                            if (dblElev != 0)
                            {
                                dblBulge = System.Math.Tan(objAlignEntArc.Delta / 4);
                                if (objAlignEntArc.Clockwise)
                                {
                                    dblBulge = dblBulge * -1.0;
                                }
                                dblRadius = System.Math.Round(objAlignEntArc.Radius, 2);

                                POI vpoi = new POI();
                                vpoi.Station     = dblStationBC;
                                vpoi.Desc0       = strDesc;
                                vpoi.ClassObj    = strClass;
                                vpoi.AngDelta    = dblAngDelta;
                                vpoi.AngDir      = dblAngDirCen;
                                vpoi.isRightHand = isRightHand;
                                vpoi.Elevation   = dblElev;
                                vpoi.Bulge       = dblBulge;
                                vpoi.Radius      = dblRadius;
                                vpoi.CenterPnt   = new Point3d(dblPntCen.X, dblPntCen.Y, 0);

                                varpoi.Add(vpoi);
                                varpoi = varpoi.sortPOIbyStation();
                            }
                        }

                        boolExists = false;

                        double dblStationEC = System.Math.Round(objAlignEntArc.EndStation, 3);

                        x = 0;
                        for (int j = 0; j < varpoi.Count; j++)
                        {
                            if (System.Math.Abs(varpoi[j].Station - dblStationEC) < 0.05)
                            {
                                boolExists = true;
                                x          = j;
                                break;
                            }
                        }

                        dblAngDirCen = objAlignEntArc.EndPoint.getDirection(objAlignEntArc.CenterPoint);

                        if (boolExists)
                        {
                            POI vpoi = varpoi[x];
                            vpoi.Station     = Math.roundDown3(dblStationEC);
                            vpoi.Desc0       = "EC";
                            vpoi.AngDir      = dblAngDirCen;
                            vpoi.isRightHand = isRightHand;
                            vpoi.Bulge       = dblBulge;
                            vpoi.Radius      = dblRadius;
                            varpoi[x]        = vpoi;
                        }
                        else
                        {
                            string strDesc = "EC";
                            double dblElev = 0;

                            try
                            {
                                dblElev = objProfile.ElevationAt(dblStationEC);
                            }
                            catch (System.Exception)
                            {
                                dblElev = objProfile.ElevationAt(dblStationBC - 0.05);
                            }

                            POI vpoi = new POI();
                            vpoi.Station     = dblStationEC;
                            vpoi.Desc0       = strDesc;
                            vpoi.ClassObj    = strClass;
                            vpoi.AngDelta    = dblAngDelta;
                            vpoi.AngDir      = dblAngDirCen;
                            vpoi.isRightHand = isRightHand;
                            vpoi.Elevation   = dblElev;
                            vpoi.Bulge       = dblBulge;
                            vpoi.Radius      = dblRadius;

                            varpoi.Add(vpoi);

                            varpoi = varpoi.sortPOIbyStation();
                        }
                    }
                }
            }

            return(true);
        }
Beispiel #11
0
        set5x5(ObjectId idAlign, double dblElev, double dblStation, double dblOffset, int intSide, string strName, string strDesc)
        {
            double dblAngBack  = 0;
            double dblAngAhead = 0;

            double    dblEasting0  = 0;
            double    dblNorthing0 = 0;
            Alignment objAlign     = (Alignment)idAlign.getEnt();
            AlignmentEntityCollection alignEnts = objAlign.Entities;
            //Debug.Print objAlign.EndingStation

            AlignmentEntity        alignEnt0   = (AlignmentEntity)alignEnts.EntityAtStation(dblStation);
            AlignmentLine          alignLine0  = null;
            AlignmentSubEntityLine subEntLine0 = null;

            if (alignEnt0.EntityType == AlignmentEntityType.Line)
            {
                alignLine0  = (AlignmentLine)alignEnts.EntityAtStation(dblStation);
                subEntLine0 = (AlignmentSubEntityLine)alignLine0[0];
            }
            else
            {
                return;
            }

            AlignmentLine   alignLineA = null;
            AlignmentLine   alignLineB = null;
            AlignmentEntity alignEntX  = null;

            Point2d pnt2dBeg = Point2d.Origin;
            Point2d pnt2dEnd = Point2d.Origin;

            //Point at Tangent Start Point
            if (Math.roundDown3(dblStation) == Math.roundDown3(alignLine0.StartStation))
            {
                alignLineA = alignLine0;

                pnt2dBeg    = alignLineA.StartPoint;
                pnt2dEnd    = alignLineA.EndPoint;
                dblAngAhead = pnt2dBeg.getDirection(pnt2dEnd);

                //First Tangent
                if (alignEnt0.EntityBefore != 0)
                {
                    alignEntX = alignEnts[alignEnt0.EntityBefore - 1];

                    if (alignEntX.EntityType == AlignmentEntityType.Line)
                    {
                        alignLineB = (AlignmentLine)alignEntX;
                        pnt2dBeg   = alignLineB.StartPoint;
                        pnt2dEnd   = alignLineB.EndPoint;
                        dblAngBack = pnt2dBeg.getDirection(pnt2dEnd);
                    }
                }
                else
                {
                    dblAngBack = dblAngAhead;
                    //     Debug.Print dblAngBack
                }
                //Point at Tangent End Point
            }
            else if (Math.roundDown3(dblStation) == Math.roundDown3(alignLine0.EndStation))
            {
                alignLineB = alignLine0;

                pnt2dBeg   = alignLineB.StartPoint;
                pnt2dEnd   = alignLineB.EndPoint;
                dblAngBack = pnt2dBeg.getDirection(pnt2dEnd);

                //Last Tangent
                if (alignEnt0.EntityAfter != 0)
                {
                    alignEntX = alignEnts[alignLine0.EntityAfter - 1];

                    if (alignEntX.EntityType == AlignmentEntityType.Line)
                    {
                        alignLineA = (AlignmentLine)alignEntX;

                        pnt2dBeg    = alignLineA.StartPoint;
                        pnt2dEnd    = alignLineA.EndPoint;
                        dblAngAhead = pnt2dBeg.getDirection(pnt2dEnd);
                    }
                }
                else
                {
                    dblAngAhead = dblAngBack;
                }
            }
            else
            {
                pnt2dBeg    = alignLine0.StartPoint;
                pnt2dEnd    = alignLine0.EndPoint;
                dblAngAhead = pnt2dBeg.getDirection(pnt2dEnd);
            }

            idAlign.getAlignPointLoc(dblStation, 0.0, ref dblEasting0, ref dblNorthing0);
            //get point of intersection

            Point3d pnt3d = new Point3d(dblEasting0, dblNorthing0, 0.0);

            Point3d pnt3dX = pnt3d.traverse(dblAngAhead + (3 * PI / 4 * intSide * -1), dblOffset / System.Math.Sin(PI / 4));

            pnt3dX = pnt3dX.addElevation(dblElev);

            string strOffset = string.Format("{0} x {1}", dblOffset.ToString(), dblOffset.ToString());

            Debug.Print(dblStation + " set5x5");
            setOffsetPoint(pnt3dX, strOffset, strName, strDesc, idAlign, dblStation);

            pnt3dX = pnt3dX.traverse(dblAngAhead + (PI / 4 * intSide * -1), dblOffset / System.Math.Sin(PI / 4));
            pnt3dX = pnt3dX.addElevation(dblElev);

            strOffset = string.Format("{0} x {1}", dblOffset.ToString(), dblOffset.ToString());

            Debug.Print(dblStation + " set5x5");
            setOffsetPoint(pnt3dX, strOffset, strName, strDesc, idAlign, dblStation);
        }
Beispiel #12
0
        copyAlignFromXref(ObjectId idAlign, string strSource)
        {
            Alignment objAlign = (Alignment)idAlign.getEnt();
            AlignmentEntityCollection objAlignEnts = default(AlignmentEntityCollection);
            AlignmentEntity           objAlignEnt  = default(AlignmentEntity);
            AlignmentArc  objAlignEntArc           = default(AlignmentArc);
            AlignmentLine objAlignEntTan           = default(AlignmentLine);

            Point2d pnt2dBeg        = objAlign.ReferencePoint;
            double  dblStationStart = objAlign.ReferencePointStation;
            string  strAlignName    = objAlign.Name;

            StationEquationCollection objStationEQs   = objAlign.StationEquations;
            List <AlgnEntData>        varAlignEntData = listAlignEnts(objAlign);

            objAlignEnts = objAlign.Entities;

            List <Vertex2d> pnts2dPoly = new List <Vertex2d>();

            double bulge = 0;

            for (int i = 0; i < varAlignEntData.Count; i++)
            {
                objAlignEnt = objAlignEnts.EntityAtId(varAlignEntData[i].ID);

                if (objAlignEnt.EntityType == AlignmentEntityType.Arc)
                {
                    objAlignEntArc = (AlignmentArc)objAlignEnt;

                    if (i == objAlignEnts.Count - 1)
                    {
                        bulge = System.Math.Tan(objAlignEntArc.Delta / 4);
                        if (objAlignEntArc.Clockwise)
                        {
                            bulge = bulge * -1.0;
                        }
                        pnts2dPoly.Add(new Vertex2d(new Point3d(objAlignEntArc.StartPoint.X, objAlignEntArc.StartPoint.Y, 0), bulge, 0, 0, 0));
                        pnts2dPoly.Add(new Vertex2d(new Point3d(objAlignEntArc.EndPoint.X, objAlignEntArc.EndPoint.Y, 0), 0, 0, 0, 0));
                    }
                    else
                    {
                        bulge = System.Math.Tan(objAlignEntArc.Delta / 4);
                        if (objAlignEntArc.Clockwise)
                        {
                            bulge = bulge * -1;
                        }
                        pnts2dPoly.Add(new Vertex2d(new Point3d(objAlignEntArc.StartPoint.X, objAlignEntArc.StartPoint.Y, 0), bulge, 0, 0, 0));
                    }
                }
                else if (objAlignEnt.EntityType == AlignmentEntityType.Line)
                {
                    objAlignEntTan = (AlignmentLine)objAlignEnt;

                    if (i == objAlignEnts.Count - 1)
                    {
                        pnts2dPoly.Add(new Vertex2d(new Point3d(objAlignEntTan.StartPoint.X, objAlignEntTan.StartPoint.Y, 0), 0, 0, 0, 0));
                        pnts2dPoly.Add(new Vertex2d(new Point3d(objAlignEntTan.EndPoint.X, objAlignEntTan.EndPoint.Y, 0), 0, 0, 0, 0));
                    }
                    else
                    {
                        pnts2dPoly.Add(new Vertex2d(new Point3d(objAlignEntTan.StartPoint.X, objAlignEntTan.StartPoint.Y, 0), 0, 0, 0, 0));
                    }
                }
            }

            ObjectId idPoly = Draw.addPoly(pnts2dPoly);

            string strLayer = "";

            if (strSource == "WALLDESIGN")
            {
                strLayer = "WALL-PROFILE";
            }
            else
            {
                strLayer = strSource;
            }

            Layer.manageLayers(strLayer);

            Alignment objAlignNew = null;

            try
            {
                objAlignNew = Align.addAlignmentFromPoly(strAlignName, strLayer, idPoly, "Standard", "Standard", true);
            }
            catch (System.Exception ex)
            {
                System.Diagnostics.Debug.Print(ex.ToString());
                return(null);
            }

            objAlignNew.ReferencePointStation = dblStationStart;

            double dblStaBack  = 0;
            double dblStaAhead = 0;
            StationEquationType objStaEqType = default(StationEquationType);

            for (int i = 0; i <= objStationEQs.Count - 1; i++)
            {
                dblStaBack   = objStationEQs[i].RawStationBack;
                dblStaAhead  = objStationEQs[i].StationAhead;
                objStaEqType = objStationEQs[i].EquationType;

                objAlignNew.StationEquations.Add(dblStaBack, dblStaAhead, objStaEqType);
            }
            return(objAlignNew);
        }
Beispiel #13
0
        listAlignEnts(Alignment objAlign)
        {
            AlignmentEntity objAlignEnt    = default(AlignmentEntity);
            AlignmentLine   objAlignEntTan = default(AlignmentLine);
            AlignmentArc    objAlignEntArc = default(AlignmentArc);

            List <AlgnEntData> varAlignData  = null;
            List <AlgnEntData> varAlignDataX = null;

            int lngBefore = 0;

            AlignmentEntityCollection ents = objAlign.Entities;

            for (int i = 0; i < ents.Count; i++)
            {
                objAlignEnt = ents[i];

                AlgnEntData alignData = new AlgnEntData();
                if (objAlignEnt.EntityType == AlignmentEntityType.Arc)
                {
                    objAlignEntArc      = (AlignmentArc)objAlignEnt;
                    alignData.ID        = objAlignEntArc.EntityId;
                    alignData.Type      = "Arc";
                    alignData.StaBeg    = System.Math.Round(objAlignEntArc.StartStation, 2);
                    alignData.StaEnd    = System.Math.Round(objAlignEntArc.EndStation, 2);
                    alignData.Length    = System.Math.Round(objAlignEntArc.Length, 2);
                    alignData.Radius    = System.Math.Round(objAlignEntArc.Radius, 2);
                    alignData.EntBefore = objAlignEntArc.EntityBefore;

                    varAlignData.Add(alignData);
                }
                else if (objAlignEnt.EntityType == AlignmentEntityType.Line)
                {
                    objAlignEntTan      = (AlignmentLine)objAlignEnt;
                    alignData.ID        = objAlignEntTan.EntityId;
                    alignData.Type      = "Tangent";
                    alignData.StaBeg    = System.Math.Round(objAlignEntTan.StartStation, 2);
                    alignData.StaEnd    = System.Math.Round(objAlignEntTan.EndStation, 2);
                    alignData.Length    = System.Math.Round(objAlignEntTan.Length, 2);
                    alignData.Radius    = 0.0;
                    alignData.EntBefore = objAlignEntTan.EntityBefore;

                    varAlignData.Add(alignData);
                }
            }

            int n = -1;
            int k = 0;

            do
            {
                for (int i = 0; i < ents.Count; i++)
                {
                    if (varAlignData[i].EntBefore == lngBefore)
                    {
                        n += 1;                                         //n is index for new list
                        varAlignDataX[n] = varAlignData[i];
                        k = i;
                        break;
                    }
                }

                lngBefore = varAlignData[k].ID;
            }while (n < ents.Count);

            return(varAlignDataX);
        }
Beispiel #14
0
        getCardinals_Horizontal(ObjectId idAlign, ref List <POI> varpoi)
        {
            Alignment objAlign = (Alignment)idAlign.getEnt();
            //BEGIN HORIZONTAL CARDINALS
            AlignmentEntityCollection objAlignEnts = objAlign.Entities;
            AlignmentEntity           objAlignEnt  = objAlignEnts[0];

            //GET BEG AND END OF FIRST SEGMENT - THEN GET END OF FOLLOWING SEGMENTS
            switch (objAlignEnt.EntityType)
            {
            case AlignmentEntityType.Arc:
                AlignmentArc objAlignEntArc = (AlignmentArc)objAlignEnt;
                POI          poi            = new POI();
                poi.Station  = Math.roundDown3((objAlignEntArc.StartStation));
                poi.Desc0    = "HC";
                poi.ClassObj = fStake.ClassObj;
                varpoi.Add(poi);

                poi          = new POI();
                poi.Station  = Math.roundDown3((objAlignEntArc.EndStation));
                poi.Desc0    = "HC";
                poi.ClassObj = fStake.ClassObj;
                varpoi.Add(poi);
                break;

            case AlignmentEntityType.Line:
                AlignmentLine objAlignEntTan = (AlignmentLine)objAlignEnt;
                poi          = new POI();
                poi.Station  = Math.roundDown3((objAlignEntTan.StartStation));
                poi.Desc0    = "HC";
                poi.ClassObj = fStake.ClassObj;
                varpoi.Add(poi);

                poi          = new POI();
                poi.Station  = Math.roundDown3((objAlignEntTan.EndStation));
                poi.Desc0    = "HC";
                poi.ClassObj = fStake.ClassObj;
                varpoi.Add(poi);
                break;
            }

            POI vpoi = new POI();

            if (objAlignEnts.Count > 1)
            {
                for (int i = 1; i <= objAlignEnts.Count - 1; i++)
                {
                    objAlignEnt = objAlignEnts[i];

                    vpoi = new POI();
                    switch (objAlignEnt.EntityType)
                    {
                    case AlignmentEntityType.Arc:
                        AlignmentArc objAlignEntArc = (AlignmentArc)objAlignEnt;
                        vpoi.Station  = Math.roundDown3((objAlignEntArc.EndStation));
                        vpoi.Desc0    = "HC";
                        vpoi.ClassObj = fStake.ClassObj;
                        break;

                    case AlignmentEntityType.Line:
                        AlignmentLine objAlignEntTan = (AlignmentLine)objAlignEnt;
                        vpoi.Station  = Math.roundDown3((objAlignEntTan.EndStation));
                        vpoi.Desc0    = "HC";
                        vpoi.ClassObj = fStake.ClassObj;

                        break;
                    }
                    varpoi.Add(vpoi);
                }
            }
            //END HORIZONTAL CARDINALS
        }
Beispiel #15
0
        private void cmdUpdate_Click(object sender, EventArgs e)
        {
            Control            cntrl;
            ControlCollection  cntrls   = (ControlCollection)this.Controls;
            List <AlgnEntData> algnData = new List <AlgnEntData>();
            int k = cntrls.Count;

            k = (k - 9) / 1 - 1;

            Object[,] varData = new object[k, 6];
            for (int i = 0; i < cntrls.Count; i++)
            {
                cntrl = cntrls[i];
                if (cntrl.Name.Contains("lbl"))
                {
                    int id  = int.Parse(cntrl.Name.Substring(4, 1));
                    int idx = id + 2;
                    varData[id, idx] = cntrl.Text;
                }
            }
            AlgnEntData aData;

            for (int i = 0; i < k; i++)
            {
                aData        = new AlgnEntData();
                aData.ID     = int.Parse(varData[i, 1].ToString());
                aData.Type   = varData[i, 2].ToString();
                aData.StaBeg = double.Parse(varData[i, 3].ToString());
                aData.StaEnd = double.Parse(varData[i, 4].ToString());
                aData.Length = double.Parse(varData[i, 5].ToString());
                aData.Radius = double.Parse(varData[i, 6].ToString());
                algnData.Add(aData);
            }

            Alignment align = (Alignment)idAlign.getEnt();
            AlignmentEntityCollection ents = align.Entities;
            bool changed = false;

            for (int i = 0; i < ents.Count; i++)
            {
                AlignmentEntity ent = ents[i];
                if (ent.EntityType == AlignmentEntityType.Arc)
                {
                    if (algnData[1].Radius == 0)
                    {
                        ents.Remove(ent);
                        changed = true;
                    }
                }
                else
                {
                    AlignmentArc arc = (AlignmentArc)ent;
                    if (!arc.Radius.Equals(algnData[i].Radius))
                    {
                        arc.Radius = algnData[i].Radius;
                        changed    = true;
                    }
                }
                if (changed)
                {
                    this.Close();
                    MNP_Align.editAlign(align.ObjectId);
                }
            }
        }
Beispiel #16
0
        getAlgnEntData(Alignment objAlign)
        {
            //-----------------------------------------------Collect alignment segment data-----------------------------------------------
            AlgnEntData        algnEntData     = default(AlgnEntData);
            List <AlgnEntData> algnEntDataList = new List <AlgnEntData>();           //data for alignment entities in order occurance in alignment not by ID

            AlignmentEntityCollection alignEnts = objAlign.Entities;
            int k = alignEnts.Count;

            foreach (AlignmentEntity alignEnt in alignEnts)
            {
                algnEntData = new AlgnEntData();
                if (alignEnt.EntityType == AlignmentEntityType.Arc)
                {
                    AlignmentArc alignEntArc = alignEnt as AlignmentArc;
                    try {
                        algnEntData.EntBefore = alignEntArc.EntityBefore;
                    }
                    catch (Autodesk.Civil.EntityNotFoundException) {
                        algnEntData.EntBefore = 0;
                    }
                    algnEntData.ID        = alignEntArc.EntityId;
                    algnEntData.Length    = alignEntArc.Length;
                    algnEntData.Radius    = alignEntArc.Radius;
                    algnEntData.Direction = 0;
                    algnEntData.ClockWise = alignEntArc.Clockwise;
                    algnEntData.StaBeg    = alignEntArc.StartStation;
                    algnEntData.StaEnd    = alignEntArc.EndStation;
                    algnEntData.Type      = "Arc";
                    algnEntData.pnt2dBeg  = alignEntArc.StartPoint;
                    algnEntData.pnt2dEnd  = alignEntArc.EndPoint;
                }
                else if (alignEnt.EntityType == AlignmentEntityType.Line)
                {
                    AlignmentLine alignEntLine = alignEnt as AlignmentLine;
                    try {
                        algnEntData.EntBefore = alignEntLine.EntityBefore;
                    }
                    catch (Autodesk.Civil.EntityNotFoundException) {
                        algnEntData.EntBefore = 0;
                    }
                    algnEntData.ID        = alignEntLine.EntityId;
                    algnEntData.Length    = alignEntLine.Length;
                    algnEntData.Radius    = 0;
                    algnEntData.Direction = alignEntLine.Direction;
                    algnEntData.StaBeg    = alignEntLine.StartStation;
                    algnEntData.StaEnd    = alignEntLine.EndStation;
                    algnEntData.Type      = "Line";
                    algnEntData.pnt2dBeg  = alignEntLine.StartPoint;
                    algnEntData.pnt2dEnd  = alignEntLine.EndPoint;
                }
                algnEntDataList.Add(algnEntData);
            }

            for (int i = 0; i < algnEntDataList.Count - 1; i++)
            {
                AlgnEntData algnEnt0 = algnEntDataList[i];
                AlgnEntData algnEntX = algnEntDataList[i + 1];

                Vector2d v2d0 = algnEnt0.pnt2dEnd - algnEnt0.pnt2dBeg;
                Vector2d v2dX = algnEntX.pnt2dEnd - algnEntX.pnt2dBeg;

                double ang3pnts = Geom.getAngle3Points2d(algnEnt0.pnt2dBeg, algnEnt0.pnt2dEnd, algnEntX.pnt2dEnd);
                algnEnt0.AngDeflection = v2d0.getDeflectionAngle2Vectors(v2dX);
                if (Geom.testRight(algnEnt0.pnt2dBeg, algnEnt0.pnt2dEnd, algnEntX.pnt2dEnd) < 0)
                {
                    algnEnt0.AngDeflection *= -1;
                }

                algnEntDataList[i] = algnEnt0;
            }
            return(algnEntDataList);
        }
 /// <summary>
 /// Initializes the class from the alignment entities.
 /// </summary>
 /// <param name="entities">Entities to enumerate</param>
 internal BySequenceEnumerator(AlignmentEntityCollection entities)
 {
     m_TheEntities = entities;
     m_EntityIndex = -1;
 }
Beispiel #18
0
        getAnglePoints(ObjectId idAlign, ref List <POI> varpoi)
        {
            POI  vPoi       = new POI();
            bool boolClosed = false;

            string  strClass   = fStake.ClassObj;
            Profile objProfile = null;

            switch (strClass)
            {
            case "CURB":
                objProfile = Prof.getProfile(idAlign, "FLOWLINE");
                break;

            case "FL":
                objProfile = Prof.getProfile(idAlign, "STAKE");
                break;

            case "WTR":
                objProfile = Prof.getProfile(idAlign, "CPNT");
                break;

            case "BLDG":
                vPoi = new POI();
                break;
            }

            Alignment objAlign = (Alignment)idAlign.getEnt();
            AlignmentEntityCollection objAlignEnts = objAlign.Entities;
            double          dblElev      = 0;
            bool            isRightHand  = false;
            AlignmentEntity objAlignEnt0 = null;
            AlignmentEntity objAlignEntX = null;
            AlignmentLine   objAlignTan0 = null;
            AlignmentLine   objAlignTanX = null;
            AlignmentArc    objAlignArc0 = null;
            AlignmentArc    objAlignArcX = null;

            if (objAlignEnts.Count > 1)
            {
                for (int i = 0; i < objAlignEnts.Count - 1; i++)
                {
                    objAlignEnt0 = objAlignEnts[i + 0];
                    objAlignEntX = objAlignEnts[i + 1];

                    if (objAlignEnt0.EntityType == AlignmentEntityType.Line)
                    {
                        objAlignTan0 = (AlignmentLine)objAlignEnt0;

                        if (objAlignEntX.EntityType == AlignmentEntityType.Line)
                        {
                            objAlignTanX = (AlignmentLine)objAlignEntX;

                            double dblAng0 = objAlignTan0.StartPoint.getDirection(objAlignTan0.EndPoint);
                            double dblAngX = objAlignTanX.StartPoint.getDirection(objAlignTanX.EndPoint);

                            if (System.Math.Round(dblAng0, 3) != System.Math.Round(dblAngX, 3))
                            {
                                Point3d pnt3d1 = new Point3d(objAlignTan0.StartPoint.X, objAlignTan0.StartPoint.Y, 0);
                                Point3d pnt3d2 = new Point3d(objAlignTan0.EndPoint.X, objAlignTan0.EndPoint.Y, 0);
                                Point3d pnt3d3 = new Point3d(objAlignTanX.EndPoint.X, objAlignTanX.EndPoint.Y, 0);

                                double dblStation = System.Math.Round(objAlignTanX.StartStation, 3);
                                //          Debug.Print i

                                double dblAngDelta = Geom.getAngle3Points(pnt3d1, pnt3d2, pnt3d3);
                                double dblAngDir   = dblAngX;

                                Vector3d v3d1 = pnt3d2 - pnt3d1;
                                Vector3d v3d2 = pnt3d3 - pnt3d2;

                                Vector3d v3dC = v3d1.CrossProduct(v3d2);

                                if (v3dC.Z > 0)
                                {
                                    isRightHand = true;
                                }
                                else
                                {
                                    isRightHand = false;
                                }

                                switch (strClass)
                                {
                                case "CURB":
                                case "FL":
                                case "WTR":

                                    try
                                    {
                                        dblElev = System.Math.Round(objProfile.ElevationAt(dblStation), 3);
                                    }
                                    catch (System.Exception)
                                    {
                                    }

                                    break;
                                }

                                POI vpoi = new POI();

                                vpoi.Station     = dblStation;
                                vpoi.Desc0       = "AP";
                                vpoi.ClassObj    = strClass;
                                vpoi.AngDelta    = dblAngDelta;
                                vpoi.AngDir      = dblAngDir;
                                vpoi.isRightHand = isRightHand;
                                vpoi.Elevation   = dblElev;

                                varpoi.Add(vpoi);
                                varpoi = varpoi.sortPOIbyStation();
                            }
                        }
                    }
                }
            }

            objAlignEnt0 = objAlignEnts[objAlignEnts.FirstEntity - 1];
            objAlignEntX = objAlignEnts[objAlignEnts.LastEntity - 1];

            bool boolArc0 = false;
            bool boolArcX = false;
            bool boolTan0 = false;
            bool boolTanX = false;

            Point2d pnt2dBeg = Point2d.Origin, pnt2dEnd = Point2d.Origin;

            if (objAlignEnt0.EntityType == AlignmentEntityType.Arc)
            {
                objAlignArc0 = (AlignmentArc)objAlignEnt0;
                pnt2dBeg     = objAlignArc0.StartPoint;
                boolArc0     = true;
            }
            else
            {
                objAlignTan0 = (AlignmentLine)objAlignEnt0;
                pnt2dBeg     = objAlignTan0.StartPoint;
                boolTan0     = true;
            }

            if (objAlignEntX.EntityType == AlignmentEntityType.Arc)
            {
                objAlignArcX = (AlignmentArc)objAlignEntX;
                pnt2dEnd     = objAlignArcX.StartPoint;
                boolArcX     = true;
            }
            else
            {
                objAlignTanX = (AlignmentLine)objAlignEntX;
                pnt2dEnd     = objAlignTanX.StartPoint;
                boolTanX     = true;
            }

            if (System.Math.Round(pnt2dEnd.X, 2) == System.Math.Round(pnt2dBeg.X, 2))
            {
                if (System.Math.Round(pnt2dEnd.Y, 2) == System.Math.Round(pnt2dBeg.Y, 2))
                {
                    boolClosed         = true;
                    varpoi[0].isClosed = true;

                    if (boolArc0 & boolArcX)
                    {
                        varpoi[0].Desc0 = "PCC";
                    }
                    else if (boolArc0 & boolTanX)
                    {
                        //do nothing
                    }
                    else if (boolTan0 & boolArcX)
                    {
                        varpoi[0].Desc0 = "EC";
                    }
                    else if (boolTan0 & boolTanX)
                    {
                        Point3d pnt3d1 = new Point3d(objAlignTanX.StartPoint.X, objAlignTanX.StartPoint.Y, 0);
                        Point3d pnt3d2 = new Point3d(objAlignTanX.EndPoint.X, objAlignTanX.EndPoint.Y, 0);
                        Point3d pnt3d3 = new Point3d(objAlignTan0.EndPoint.X, objAlignTan0.EndPoint.Y, 0);

                        double dblAngDelta = Geom.getAngle3Points(pnt3d1, pnt3d2, pnt3d3);

                        double dblAng0   = objAlignTan0.StartPoint.getDirection(objAlignTan0.EndPoint);
                        double dblAngDir = dblAng0;

                        Vector3d v3d1 = pnt3d2 - pnt3d1;
                        Vector3d v3d2 = pnt3d3 - pnt3d2;

                        Vector3d v3dC = v3d1.CrossProduct(v3d2);

                        if (v3dC.Z > 0)
                        {
                            isRightHand = true;
                        }
                        else
                        {
                            isRightHand = false;
                        }

                        if (strClass == "BLDG")
                        {
                            varpoi[0].Station  = objAlignTan0.StartStation;
                            varpoi[0].Desc0    = "AP";
                            varpoi[0].DescX    = "BEG AP";
                            varpoi[0].ClassObj = strClass;
                            varpoi[0].AngDelta = dblAngDelta;
                            varpoi[0].AngDir   = dblAngDir;
                        }
                        else
                        {
                            varpoi[0].Desc0    = "AP";
                            varpoi[0].DescX    = "BEG AP";
                            varpoi[0].AngDelta = dblAngDelta;
                            varpoi[0].AngDir   = dblAngDir;
                        }
                    }
                }
            }

            if (boolClosed)
            {
                int j = varpoi.Count - 1;

                if (varpoi[j].Station != Math.roundDown3((objAlign.EndingStation)))
                {
                    POI vpoi = new POI();
                    vpoi.Station   = Math.roundDown3((objAlign.EndingStation));
                    vpoi.Elevation = varpoi[0].Elevation;
                    if (strClass == "BLDG")
                    {
                        vpoi.DescX = varpoi[0].DescX;
                    }
                    else
                    {
                        vpoi.DescX = "END AP";
                    }
                    vpoi.Desc0    = "AP";
                    vpoi.ClassObj = strClass;
                    vpoi.isClosed = true;

                    varpoi.Add(vpoi);
                }
                else
                {
                    POI vpoi = varpoi[j];

                    vpoi.Elevation = varpoi[0].Elevation;
                    vpoi.Desc0     = "AP";
                    if (strClass == "BLDG")
                    {
                        vpoi.DescX = varpoi[0].DescX;
                    }
                    vpoi.DescX    = "END AP";
                    vpoi.ClassObj = strClass;
                    vpoi.isClosed = true;
                    varpoi[j]     = vpoi;
                }
            }
        }
Beispiel #19
0
        makePipeNetwork(ObjectId idAlign, string nameNetwork, string pipeType)
        {
            string pntDesc = fMNP.pntDesc;

            Point3d pnt3dPick = Pub.pnt3dO;

            if (idAlign == ObjectId.Null)
            {
                Autodesk.AutoCAD.DatabaseServices.Entity ent = Select.selectEntity(typeof(Alignment), "Select Alignment: ", "Selected object was not an alignment. Try again: ", out pnt3dPick);
                idAlign = ent.ObjectId;
            }

            Network            net   = null;
            ObjectIdCollection ids   = CivilApplication.ActiveDocument.GetPipeNetworkIds();
            ObjectId           idNet = ObjectId.Null;

            if (ids.Count == 0)
            {
                idNet = Network.Create(CivilApplication.ActiveDocument, ref nameNetwork);
            }
            else
            {
                for (int i = 0; i < ids.Count; i++)
                {
                    net = (Network)ids[i].getEnt();
                    //if (net.Name == nameNetwork){
                    //    string index = Align.getAlignIndex(nameNetwork);
                    //    nameNetwork = string.Format("{0}-{1}", nameNetwork, index);
                    //    break;
                    //}
                }
                idNet = Network.Create(CivilApplication.ActiveDocument, ref nameNetwork);
            }

            bool exists = false;

            Alignment align = (Alignment)idAlign.getEnt();
            AlignmentEntityCollection ents = align.Entities;
            TinSurface tinSurfDE           = Surf.getTinSurface("CPNT-ON", out exists);

            List <AlgnEntData> algnData = MNP_Align.sortAlignEnts(align);
            List <string>      hPipe    = new List <string>();
            List <ObjectId>    idsCgPnt = new List <ObjectId>();

            ObjectId idPipe, idPipeSize, idStruct, idStructSize;

            using (Transaction tr = BaseObjs.startTransactionDb())
            {
                net = (Network)tr.GetObject(idNet, OpenMode.ForWrite);
                net.ReferenceAlignmentId = idAlign;
                net.ReferenceSurfaceId   = Surf.getTinSurface("CPNT-ON", out exists).ObjectId;

                ObjectId  idPartsList = CivilApplication.ActiveDocument.Styles.PartsListSet["Standard"];
                PartsList partsList   = (PartsList)tr.GetObject(idPartsList, OpenMode.ForRead);

                idPipe = partsList["Concrete Pipe"];
                PartFamily partFamily = (PartFamily)tr.GetObject(idPipe, OpenMode.ForWrite);

                idPipeSize = partFamily[0];

                PartSize        partSize = (PartSize)tr.GetObject(idPipeSize, OpenMode.ForRead);
                PartDataRecord  pdr      = partSize.SizeDataRecord;
                PartDataField[] pdf      = pdr.GetAllDataFields();

                for (int i = 0; i < pdf.Length; i++)
                {
                    System.Diagnostics.Debug.Print(string.Format("{0}: {1}", pdf[i].Description, pdf[i].Value.ToString()));
                }

                idStruct     = partsList["Rectangular Structure Slab Top Rectangular Frame"];
                partFamily   = (PartFamily)tr.GetObject(idStruct, OpenMode.ForWrite);
                idStructSize = partFamily[0];

                double depth = -6, slope = 0, dZ = 0, top = 0;
                double diam = double.Parse(pdf[0].Value.ToString()) / 12;

                ObjectId idPipeNew = ObjectId.Null;

                AlignmentEntity ent    = null;
                Structure       sPrev  = null;
                uint            pntNum = 0;

                ObjectId     idCgPntBeg, idCgPntEnd, idCgPntPrev = ObjectId.Null;
                TypedValue[] tvs;

                for (int i = 0; i < algnData.Count; i++)
                {
                    if (algnData.Count == 1)
                    {
                        ent = ents[0];
                    }
                    else
                    {
                        ent = ents.EntityAtId(algnData[i].ID);
                    }

                    ObjectId  idStructNew = ObjectId.Null;
                    Structure s           = null;
                    Pipe      p           = null;

                    if (ent.EntityType == AlignmentEntityType.Line)
                    {
                        AlignmentLine line     = (AlignmentLine)ent;
                        Point2d       pnt2dBeg = line.StartPoint;
                        Point2d       pnt2dEnd = line.EndPoint;

                        try
                        {
                            top = tinSurfDE.FindElevationAtXY(pnt2dBeg.X, pnt2dBeg.Y) + depth;
                        }
                        catch (System.Exception)
                        {
                            Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("Pipe endpoint is beyond limit of design surface");
                            return;
                        }

                        Point3d pnt3dBeg = new Point3d(pnt2dBeg.X, pnt2dBeg.Y, top);

                        try
                        {
                            top = tinSurfDE.FindElevationAtXY(pnt2dEnd.X, pnt2dEnd.Y) + depth;
                        }
                        catch (System.Exception)
                        {
                            Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("Pipe endpoint is beyond limit of design surface");
                            return;
                        }

                        Point3d pnt3dEnd = new Point3d(pnt2dEnd.X, pnt2dEnd.Y, top);

                        LineSegment3d seg3d = new LineSegment3d(pnt3dBeg, pnt3dEnd);

                        net.AddLinePipe(idPipe, idPipeSize, seg3d, ref idPipeNew, true);

                        p = (Pipe)idPipeNew.getEnt();
                        p.AddToProfileView(fMNP.idProfileView);

                        ObjectId idPart = getProfileViewPart();

                        slope = pnt3dBeg.getSlope(pnt3dEnd);

                        dZ = diam / (2 * (System.Math.Cos(System.Math.Atan(System.Math.Abs(slope)))));

                        if (i == 0)
                        {
                            pnt3dBeg = new Point3d(pnt3dBeg.X, pnt3dBeg.Y, pnt3dBeg.Z - dZ);
                            pnt3dEnd = new Point3d(pnt3dEnd.X, pnt3dEnd.Y, pnt3dEnd.Z - dZ);

                            idCgPntBeg = pnt3dBeg.setPoint(out pntNum, pntDesc);
                            idsCgPnt.Add(idCgPntBeg);

                            idCgPntEnd = pnt3dEnd.setPoint(out pntNum, pntDesc);
                            idsCgPnt.Add(idCgPntEnd);

                            idCgPntPrev = idCgPntEnd;

                            tvs = new TypedValue[3];
                            tvs.SetValue(new TypedValue(1001, apps.lnkMNP), 0);
                            tvs.SetValue(new TypedValue(1005, idCgPntBeg.getHandle().ToString()), 1);
                            tvs.SetValue(new TypedValue(1005, idCgPntEnd.getHandle().ToString()), 2);

                            //idPart.setXData(rb, apps.lnkMNP);
                            idPipeNew.setXData(tvs, apps.lnkMNP);

                            net.AddStructure(idStruct, idStructSize, pnt3dBeg, 0, ref idStructNew, true);
                            s = (Structure)idStructNew.getEnt();
                            s.AddToProfileView(fMNP.idProfileView);
                            s.ConnectToPipe(idPipeNew, ConnectorPositionType.Start);

                            net.AddStructure(idStruct, idStructSize, pnt3dEnd, 0, ref idStructNew, true);
                            s = (Structure)idStructNew.getEnt();
                            s.AddToProfileView(fMNP.idProfileView);
                            s.ConnectToPipe(idPipeNew, ConnectorPositionType.End);

                            sPrev = s;
                            hPipe.Add(idPipeNew.getHandle().ToString());
                        }
                        else
                        {
                            pnt3dEnd   = new Point3d(pnt3dEnd.X, pnt3dEnd.Y, pnt3dEnd.Z - dZ);
                            idCgPntEnd = pnt3dEnd.setPoint(out pntNum, pntDesc);
                            idsCgPnt.Add(idCgPntEnd);

                            tvs = new TypedValue[3];
                            tvs.SetValue(new TypedValue(1001, apps.lnkMNP), 0);
                            tvs.SetValue(new TypedValue(1005, idCgPntPrev.getHandle().ToString()), 1);
                            tvs.SetValue(new TypedValue(1005, idCgPntEnd.getHandle().ToString()), 2);

                            //idPart.setXData(rb, apps.lnkMNP);
                            idPipeNew.setXData(tvs, apps.lnkMNP);

                            idCgPntPrev = idCgPntEnd;

                            net.AddStructure(idStruct, idStructSize, pnt3dEnd, 0, ref idStructNew, true);
                            s = (Structure)idStructNew.getEnt();
                            s.AddToProfileView(fMNP.idProfileView);
                            sPrev.ConnectToPipe(idPipeNew, ConnectorPositionType.Start);
                            s.ConnectToPipe(idPipeNew, ConnectorPositionType.End);

                            sPrev = s;
                            hPipe.Add(idPipeNew.getHandle().ToString());
                        }
                    }
                    else if (ent.EntityType == AlignmentEntityType.Arc)
                    {
                        AlignmentArc arc    = (AlignmentArc)ent;
                        double       radius = arc.Radius;

                        Point2d pnt2dBeg = arc.StartPoint;
                        Point2d pnt2dEnd = arc.EndPoint;

                        try
                        {
                            top = tinSurfDE.FindElevationAtXY(pnt2dBeg.X, pnt2dBeg.Y) + depth;
                        }
                        catch (System.Exception)
                        {
                            Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("Pipe endpoint is beyond limit of design surface");
                            return;
                        }
                        Point3d pnt3dBeg = new Point3d(pnt2dBeg.X, pnt2dBeg.Y, top);

                        try
                        {
                            top = tinSurfDE.FindElevationAtXY(pnt2dEnd.X, pnt2dEnd.Y) + depth;
                        }
                        catch (System.Exception)
                        {
                            Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("Pipe endpoint is beyond limit of design surface");
                            return;
                        }

                        IntPtr  iptr     = (IntPtr)0;
                        Point3d pnt3dEnd = new Point3d(pnt2dEnd.X, pnt2dEnd.Y, top);

                        Arc a = new Arc();
                        a.Radius     = arc.Radius;
                        a.StartPoint = new Point3d(pnt2dBeg.X, pnt2dBeg.Y, 0);
                        a.EndPoint   = new Point3d(pnt2dEnd.X, pnt2dEnd.Y, 0);
                        a.Center     = new Point3d(arc.CenterPoint.X, arc.CenterPoint.Y, 0);

                        Curve3d c = (Curve3d)a.GetGeCurve();

                        net.AddCurvePipe(idPipe, idPipeSize, c, arc.Clockwise, ref idPipeNew, true);

                        p = (Pipe)idPipeNew.getEnt();
                        p.AddToProfileView(fMNP.idProfileView);

                        ObjectId idPart = getProfileViewPart();
                        slope = (pnt3dEnd.Z - pnt3dBeg.Z) / arc.Length;

                        dZ = diam / (2 * (System.Math.Cos(System.Math.Atan(System.Math.Abs(slope)))));

                        if (i == 0)
                        {
                            pnt3dBeg = new Point3d(pnt3dBeg.X, pnt3dBeg.Y, pnt3dBeg.Z - dZ);
                            pnt3dEnd = new Point3d(pnt3dEnd.X, pnt3dEnd.Y, pnt3dEnd.Z - dZ);

                            idCgPntBeg = pnt3dBeg.setPoint(out pntNum, pntDesc);
                            idsCgPnt.Add(idCgPntBeg);

                            idCgPntEnd = pnt3dEnd.setPoint(out pntNum, pntDesc);
                            idsCgPnt.Add(idCgPntEnd);

                            tvs = new TypedValue[3];
                            tvs.SetValue(new TypedValue(1001, apps.lnkMNP), 0);
                            tvs.SetValue(new TypedValue(1005, idCgPntBeg.getHandle().ToString()), 1);
                            tvs.SetValue(new TypedValue(1005, idCgPntEnd.getHandle().ToString()), 2);

                            //idPart.setXData(rb, apps.lnkMNP);
                            idPipeNew.setXData(tvs, apps.lnkMNP);

                            net.AddStructure(idStruct, idStructSize, pnt3dBeg, 0, ref idStructNew, true);
                            s = (Structure)tr.GetObject(idStructNew, OpenMode.ForWrite);
                            s.AddToProfileView(fMNP.idProfileView);
                            s.ConnectToPipe(idPipeNew, ConnectorPositionType.Start);

                            net.AddStructure(idStruct, idStructSize, pnt3dBeg, 0, ref idStructNew, true);
                            s = (Structure)tr.GetObject(idStructNew, OpenMode.ForWrite);
                            s.AddToProfileView(fMNP.idProfileView);
                            s.ConnectToPipe(idPipeNew, ConnectorPositionType.End);
                            sPrev = s;
                            hPipe.Add(idPipeNew.getHandle().ToString());
                        }
                        else
                        {
                            pnt3dEnd = new Point3d(pnt3dEnd.X, pnt3dEnd.Y, pnt3dEnd.Z - dZ);

                            idCgPntEnd = pnt3dEnd.setPoint(out pntNum, pntDesc);
                            idsCgPnt.Add(idCgPntEnd);

                            tvs = new TypedValue[3];
                            tvs.SetValue(new TypedValue(1001, apps.lnkMNP), 0);
                            tvs.SetValue(new TypedValue(1005, idCgPntPrev.getHandle().ToString()), 1);
                            tvs.SetValue(new TypedValue(1005, idCgPntEnd.getHandle().ToString()), 2);

                            //idPart.setXData(rb, apps.lnkMNP);
                            idPipeNew.setXData(tvs, apps.lnkMNP);

                            idCgPntPrev = idCgPntEnd;

                            net.AddStructure(idStruct, idStructSize, pnt3dBeg, 0, ref idStructNew, true);
                            s = (Structure)tr.GetObject(idStructNew, OpenMode.ForWrite);
                            s.AddToProfileView(fMNP.idProfileView);
                            sPrev.ConnectToPipe(idPipeNew, ConnectorPositionType.Start);
                            s.ConnectToPipe(idPipeNew, ConnectorPositionType.End);
                            sPrev = s;
                            hPipe.Add(idPipeNew.getHandle().ToString());
                        }
                    }
                }
                tr.Commit();
            }

            hPipe.Insert(0, "-1");
            hPipe.Add("-1");

            for (int i = 0; i < idsCgPnt.Count; i++)
            {
                TypedValue[] tvs = new TypedValue[3];
                tvs.SetValue(new TypedValue(1001, apps.lnkMNP), 0);
                tvs.SetValue(new TypedValue(1005, hPipe[i]), 1);
                tvs.SetValue(new TypedValue(1005, hPipe[i + 1]), 2);
                idsCgPnt[i].setXData(tvs, apps.lnkMNP);
            }
        }