예제 #1
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
        }
예제 #2
0
        selectAlignment(ObjectId idAlign)
        {
            Alignment objAlign   = (Alignment)idAlign.getEnt();
            AlgnData  alignData  = new AlgnData();
            AlgnData  alignDataX = new AlgnData();

            Point3d pnt3dPicked = Pub.pnt3dO;
            string  nameAlign   = "";

            if ((idAlign == null))
            {
                idAlign = Align.selectAlign("\nSelect Alignment: ", "Alignment Selection Failed", out pnt3dPicked, out nameAlign);
            }

            ResultBuffer rb = idAlign.getXData("PROFILE");

            if (rb == null)
            {
                return(false);
            }
            TypedValue[] tvs = rb.AsArray();
            fStake.HandleProfileView = tvs[1].Value.ToString().stringToHandle();

            rb = idAlign.getXData("CLASS");
            if (rb == null)
            {
                return(false);
            }
            tvs = rb.AsArray();
            string strClass = tvs[1].Value.ToString();

            fStake.ClassObj = strClass;

            Alignment align = (Alignment)idAlign.getEnt();

            fStake.ACTIVEALIGN = align;
            fStake.HandleAlign = idAlign.getHandle();
            fStake.objectID    = idAlign;

            int result = 0;

            for (int i = nameAlign.Length - 1; i >= 1; i += -1)
            {
                if (!nameAlign.Substring(i, 1).isInteger(out result))
                {
                    fStake.NameStakeObject = nameAlign.Substring(0, i);
                    break;
                }
            }

            ObjectId idTable = ObjectId.Null;

            Table table = null;

            try
            {
                idTable = Stake_Table.getTableId(idAlign);
            }
            catch (System.Exception)
            {
                try
                {
                    SelectionSet ss  = Select.buildSSet(typeof(Table));
                    ObjectId[]   ids = ss.GetObjectIds();

                    using (Transaction tr = BaseObjs.startTransactionDb())
                    {
                        for (int i = 0; i < ids.Length; i++)
                        {
                            table = (Table)tr.GetObject(ids[i], OpenMode.ForRead);
                            if (table.Cells[1, 1].Value.ToString() == nameAlign)
                            {
                                TypedValue[] t = new TypedValue[2];
                                t.SetValue(new TypedValue(1001, "TABLE"), 0);
                                t.SetValue(new TypedValue(1005, ids[i].getHandle()), 1);
                                idAlign.setXData(t, "TABLE");
                                break;
                            }
                        }
                    }
                }
                catch (System.Exception)
                {
                    Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("Select Table Failed");
                }
            }

            switch (fStake.algnData.Count)
            {
            case 0:

                alignData.AlignHandle = align.Handle;
                alignData.TableHandle = table.Handle;
                alignData.AlignID     = idAlign;
                alignData.AlignName   = nameAlign;
                alignData.AlignLayer  = align.Layer;

                fStake.algnData.Add(alignData);

                break;

            case 1:

                alignData = fStake.algnData[0];

                if (alignData.AlignHandle == align.Handle)
                {
                    alignData.TableHandle = table.Handle;
                }
                else
                {
                    alignDataX.AlignHandle = align.Handle;
                    alignDataX.TableHandle = table.Handle;
                    alignDataX.AlignID     = idAlign;
                    alignDataX.AlignName   = align.Name;
                    alignDataX.AlignLayer  = align.Layer;

                    fStake.algnData.Add(alignDataX);
                }
                break;

            default:

                bool boolFound = false;

                for (int i = fStake.algnData.Count; i > 1; i--)
                {
                    alignDataX = fStake.algnData[i - 1];
                    alignData  = fStake.algnData[i];

                    if (alignDataX.AlignHandle == alignData.AlignHandle)
                    {
                        fStake.algnData.RemoveAt(i);
                    }
                }

                for (int i = 1; i < fStake.algnData.Count; i++)
                {
                    alignData = fStake.algnData[i];
                    if (alignData.AlignHandle == objAlign.Handle)
                    {
                        alignData.TableHandle = idTable.getHandle();
                        boolFound             = true;
                    }
                }

                if (!boolFound)
                {
                    alignDataX.AlignHandle = objAlign.Handle;
                    alignDataX.TableHandle = idTable.getHandle();

                    alignDataX.AlignID    = idAlign;
                    alignDataX.AlignName  = objAlign.Name;
                    alignDataX.AlignLayer = objAlign.Layer;

                    fStake.algnData.Add(alignDataX);
                }

                break;
            }

            fStake.POI_CALC = Stake_Table.resetPOI(idTable);

            Stake_Misc.set_fStakeProps(strClass);

            if (strClass == "BLDG")
            {
                Stake_Grid.updateGridCollections(objAlign.Name);

                Application.ShowModelessDialog(Application.MainWindow.Handle, fGrid, false);
                fStake.Hide();
            }

            fStake.ACTIVEALIGN = objAlign;

            return(true);
        }
예제 #3
0
        updateAlignData()
        {
            ObjectIdCollection idsAlign = Align.getAlignmentIDs();

            List <AlgnData> alignData = new List <AlgnData>();

            foreach (ObjectId id in idsAlign)
            {
                Alignment    objAlign = (Alignment)id.getEnt();
                ResultBuffer rb       = id.getXData("CLASS");

                if (rb != null)
                {
                    rb = id.getXData("TABLE");

                    if (rb != null)
                    {
                        TypedValue[] tvs   = rb.AsArray();
                        AlgnData     aData = new AlgnData();

                        aData.TableHandle = tvs[1].Value.ToString().stringToHandle();
                        aData.AlignLayer  = objAlign.Layer;
                        aData.AlignName   = objAlign.Name;
                        aData.AlignHandle = objAlign.Handle;
                        aData.AlignID     = objAlign.ObjectId;

                        alignData.Add(aData);
                    }
                    else
                    {
                        SelectionSet objSSet = Select.buildSSet(typeof(Table));

                        if (objSSet.Count > 0)
                        {
                            ObjectId[] ids = objSSet.GetObjectIds();

                            foreach (ObjectId idTable in ids)
                            {
                                Table table = (Table)idTable.getEnt();

                                if (table.Cells[1, 1].Contents[0].ToString() == objAlign.Name)
                                {
                                    TypedValue[] tvs = new TypedValue[2];
                                    tvs.SetValue(new TypedValue(1001, "TABLE"), 0);
                                    tvs.SetValue(new TypedValue(1005, table.Handle), 0);
                                    id.setXData(tvs, "TABLE");

                                    AlgnData aData = new AlgnData();

                                    aData.TableHandle = table.Handle;
                                    aData.AlignLayer  = objAlign.Layer;
                                    aData.AlignName   = objAlign.Name;
                                    aData.AlignHandle = objAlign.Handle;
                                    aData.AlignID     = objAlign.ObjectId;

                                    alignData.Add(aData);
                                }
                            }
                        }
                        else
                        {
                            string message = string.Format("Table for Align: {0} is missing -> redo alignment!!", objAlign.Name);
                            Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog(message);
                        }
                    }
                }
            }
        }
예제 #4
0
        modifyStaking(List <POI> varpoi)
        {
            Alignment objAlign = fStake.ACTIVEALIGN;
            ObjectId  idAlign  = objAlign.ObjectId;

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

            if (Stake_GetCardinals.userAddCrossingsFeatures(idAlign, ref varPOIadd))
            {
                switch (fStake.ClassObj)
                {
                case "WTR":
                    Stake_GetSurfaceElev.getSurfaceElevations(idAlign, ref varPOIadd);

                    break;

                case "ALIGN":
                case "SEWER":

                    Stake_GetSurfaceElev.getProfileElevations(idAlign, "STAKE", ref varPOIadd);

                    break;
                }

                for (int i = 0; i <= varPOIadd.Count; i++)
                {
                    varpoi.Add(varPOIadd[i]);
                }

                var sortSta = from s in varpoi
                              orderby s.Station ascending
                              select s;

                List <POI> poitmp = new List <POI>();
                foreach (var s in sortSta)
                {
                    poitmp.Add(s);
                }

                varpoi = poitmp;

                Stake_AddProfile.makeProfile(idAlign, varpoi, "STAKE", "ByLayout", true);

                switch (fStake.ClassObj)
                {
                case "ALIGN":
                case "SEWER":

                    Stake_UpdateProfile.updateProfile(idAlign, varpoi, "STAKE", false, "STAKE");

                    break;
                }

                List <AlgnData> algnData = fStake.algnData;
                AlgnData        aData    = new AlgnData();
                Table           objTable = null;
                for (int i = 1; i < algnData.Count; i++)
                {
                    aData = algnData[i];

                    if (aData.AlignHandle == objAlign.Handle)
                    {
                        objTable = (Table)aData.TableHandle.getEnt();
                        objTable.ObjectId.delete();
                        break;
                    }
                }

                ObjectId idTable = Stake_Table.makeTable(idAlign, varpoi, aData);
                Stake_Table.addTableData(idTable, varpoi);
            }
            return(varpoi);
        }
예제 #5
0
파일: Stake_Table.cs 프로젝트: 15831944/EM
        makeTable(ObjectId idAlign, List <POI> varpoi, AlgnData varAlignData = null, object varPntUpper = null)
        {
            Alignment objAlign = (Alignment)idAlign.getEnt();

            string strLayerName = "TABLES";

            Layer.manageLayers(strLayerName);
            Extents3d ext3d;
            Point3d   pnt3dMin = Pub.pnt3dO, pnt3dMax = Pub.pnt3dO, pnt3dIns = Pub.pnt3dO;
            Table     objTable = null;
            ObjectId  idTable  = ObjectId.Null;

            int    numRows   = varpoi.Count + 2;
            int    numCols   = 33;
            double rowHeight = 5;
            double colWidth  = 30;

            if ((varAlignData == null))
            {
                if ((varPntUpper == null))
                {
                    ProfileView objProfileView = (ProfileView)fStake.HandleProfileView.getEnt();
                    ext3d    = (Extents3d)objProfileView.Bounds;
                    pnt3dMin = ext3d.MinPoint;
                    pnt3dMax = ext3d.MaxPoint;
                    pnt3dIns = new Point3d(pnt3dMax.X + 10, pnt3dMax.Y, 0);

                    idTable = Draw.addTable(pnt3dIns, numRows, numCols, rowHeight, colWidth);

                    AlgnData algnData = new AlgnData();
                    algnData.AlignName   = objAlign.Name;
                    algnData.AlignHandle = objAlign.Handle;
                    algnData.AlignLayer  = objAlign.Layer;
                    algnData.AlignID     = objAlign.ObjectId;
                    algnData.TableHandle = idTable.getHandle();

                    fStake.algnData.Add(algnData);
                }
                else //for WALL only
                {
                    pnt3dIns = new Point3d(pnt3dMax.X + 10, pnt3dMax.Y, 0);

                    idTable = Draw.addTable(pnt3dIns, numRows, numCols, rowHeight, colWidth);
                    AlgnData algnData = new AlgnData();
                    algnData.AlignName   = objAlign.Name;
                    algnData.AlignHandle = objAlign.Handle;
                    algnData.AlignLayer  = objAlign.Layer;
                    algnData.AlignID     = objAlign.ObjectId;
                    algnData.TableHandle = idTable.getHandle();

                    fStake.algnData.Add(algnData);
                }
            }
            else
            {
                ProfileView objProfileView = (ProfileView)fStake.HandleProfileView.getEnt();
                ext3d    = (Extents3d)objProfileView.Bounds;
                pnt3dMin = ext3d.MinPoint;
                pnt3dMax = ext3d.MaxPoint;
                pnt3dIns = new Point3d(pnt3dMax.X + 10, pnt3dMax.Y, 0);
                idTable  = Draw.addTable(pnt3dIns, numRows, numCols, rowHeight, colWidth);
                varAlignData.TableHandle = idTable.getHandle();
            }

            using (Transaction tr = BaseObjs.startTransactionDb())
            {
                objTable = (Table)tr.GetObject(idTable, OpenMode.ForWrite);

                objTable.Layer      = strLayerName;
                objTable.ColorIndex = 41;

                objTable.SuppressRegenerateTable(true);

                objTable.Cells[0, 0].TextString = objAlign.Name;

                objTable.Cells[1, 0].TextString = "INDEX";

                objTable.Cells[1, 1].TextString  = "CLASS";
                objTable.Cells[1, 2].TextString  = "DESCO";
                objTable.Cells[1, 3].TextString  = "DESCX";
                objTable.Cells[1, 4].TextString  = "STATION";
                objTable.Cells[1, 5].TextString  = "OFFSET";
                objTable.Cells[1, 6].TextString  = "ELEVATION";
                objTable.Cells[1, 7].TextString  = "TOW";
                objTable.Cells[1, 8].TextString  = "TOF";
                objTable.Cells[1, 9].TextString  = "INVERT";
                objTable.Cells[1, 10].TextString = "SIZE";

                objTable.Cells[1, 11].TextString = "ANGDELTA";
                objTable.Cells[1, 12].TextString = "ANGDIR";
                objTable.Cells[1, 13].TextString = "ANGCHORD";
                objTable.Cells[1, 14].TextString = "ISRIGHTHAND";
                objTable.Cells[1, 15].TextString = "ISCLOSED";
                objTable.Cells[1, 16].TextString = "ISSTEP";
                objTable.Cells[1, 17].TextString = "CROSSDESC";
                objTable.Cells[1, 18].TextString = "CROSSALIGN";
                objTable.Cells[1, 19].TextString = "CROSSALIGNINV";
                objTable.Cells[1, 20].TextString = "CROSSALIGNSTA";

                objTable.Cells[1, 21].TextString = "CROSSALIGNSIZE";
                objTable.Cells[1, 22].TextString = "PNTNUM";
                objTable.Cells[1, 23].TextString = "PNTSOURCE";
                objTable.Cells[1, 24].TextString = "TYPE";
                objTable.Cells[1, 25].TextString = "BULGE";
                objTable.Cells[1, 26].TextString = "RADIUS";
                objTable.Cells[1, 27].TextString = "SIDE";
                objTable.Cells[1, 28].TextString = "SLOPEAHEAD";
                objTable.Cells[1, 29].TextString = "SLOPEBACK";
                objTable.Cells[1, 30].TextString = "SLOPEH2H";

                objTable.Cells[1, 31].TextString = "XCEN";
                objTable.Cells[1, 32].TextString = "YCEN";

                objTable.Columns[0].Width  = 18.0;
                objTable.Columns[1].Width  = 18.0;
                objTable.Columns[4].Width  = 18.0;
                objTable.Columns[5].Width  = 18.0;
                objTable.Columns[6].Width  = 18.0;
                objTable.Columns[9].Width  = 18.0;
                objTable.Columns[10].Width = 18.0;

                for (int i = 0; i < objTable.Rows.Count; i++)
                {
                    for (int j = 0; j < objTable.Columns.Count; j++)
                    {
                        objTable.Cells[i, j].TextHeight = 0.09 * Misc.getCurrAnnoScale();
                        objTable.Cells[i, j].Alignment  = CellAlignment.MiddleCenter;
                    }
                }

                objTable.SuppressRegenerateTable(false);
                tr.Commit();
            }

            TypedValue[] tvs = new TypedValue[2] {
                new TypedValue(1001, "TABLE"), new TypedValue(1005, objTable.Handle)
            };
            objAlign.ObjectId.setXData(tvs, "TABLE");

            Stake_Dict.updateDictSTAKE();

            return(objTable.ObjectId);
        }