コード例 #1
0
        MCE(List <ObjectId> idsPnts = null, string result = "")
        {
            double elev = 0.0;

            if (idsPnts == null)
            {
                idsPnts = new List <ObjectId>();
                Type         type;
                TypedValue[] tvs = new TypedValue[5];
                tvs.SetValue(new TypedValue((int)DxfCode.Operator, "<OR"), 0);

                type = typeof(Polyline3d);
                tvs.SetValue(new TypedValue((int)DxfCode.Start, RXClass.GetClass(type).DxfName), 1);

                type = typeof(CogoPoint);
                tvs.SetValue(new TypedValue((int)DxfCode.Start, RXClass.GetClass(type).DxfName), 2);

                type = typeof(Polyline);
                tvs.SetValue(new TypedValue((int)DxfCode.Start, RXClass.GetClass(type).DxfName), 3);

                tvs.SetValue(new TypedValue((int)DxfCode.Operator, "OR>"), 4);

                SelectionSet ss = Select.buildSSet(tvs, false);
                if (ss == null)
                {
                    return;
                }
                ObjectId[] ids = ss.GetObjectIds();

                List <string> descPnts = new List <string>();
                string        descPnt  = "";
                try
                {
                    if (ss.Count == 1)
                    {
                        string t = ids[0].getType().ToUpper();
                        if (t == "POLYLINE" || t == "POLYLINE2D" || t == "POLYLINE3D")
                        {
                            Point3dCollection pnts3d = ids[0].getCoordinates3d();
                            tvs = new TypedValue[1];
                            tvs.SetValue(new TypedValue((int)DxfCode.Start, "AECC_COGO_POINT"), 0);
                            SelectionFilter       filter = new SelectionFilter(tvs);
                            PromptSelectionResult psr    = BaseObjs._editor.SelectCrossingPolygon(pnts3d, filter);
                            if (psr.Status == PromptStatus.OK)
                            {
                                ids = psr.Value.GetObjectIds();
                                foreach (ObjectId id in ids)
                                {
                                    idsPnts.Add(id);
                                    descPnt = id.getCogoPntDesc();
                                    if (!descPnts.Contains(descPnt))
                                    {
                                        descPnts.Add(descPnt);
                                    }
                                }
                            }
                            else
                            {
                                return;
                            }
                        }
                        else
                        {
                            idsPnts.Add(ids[0]);
                            string message = string.Format("\nElev = {0:F2}", ids[0].getCogoPntElevation());
                            BaseObjs._editor.WriteMessage(message);
                        }
                    }
                    else if (ss.Count > 1)
                    {
                        foreach (ObjectId id in ids)
                        {
                            if (id.getType().ToUpper() == "COGOPOINT")
                            {
                                idsPnts.Add(id);
                                descPnt = id.getCogoPntDesc();
                                if (!descPnts.Contains(descPnt))
                                {
                                    descPnts.Add(descPnt);
                                }
                            }
                        }
                    }
                }
                catch (System.Exception ex)
                {
                    BaseObjs.writeDebug(ex.Message + " cmdMCE.cs: line: 98");
                }

                int  len    = descPnts.Count;
                bool escape = true;

                if (len > 1)
                {
                    string prompt    = "";
                    string keyWords1 = "";      // not used - couldn't
                    string keyWords2 = "";
                    string desWords  = "";
                    string desWords2 = "";

                    try
                    {
                        List <string> nameGrp = new List <string>();
                        List <CgPnt_Group.pntGroupParams> pntGroups = new List <CgPnt_Group.pntGroupParams>();
                        CgPnt_Group.pntGroupParams        pntGrpSymCol;
                        for (int i = 0; i < len; i++)
                        {
                            pntGroups.Add(CgPnt_Group.pntGroups.Find(s => s.name == descPnts[i]));
                        }

                        foreach (CgPnt_Group.pntGroupParams p in pntGroups)
                        {
                            keyWords1 = string.Format("{0}{1} ", keyWords1, p.key);
                            desWords  = string.Format("{0}{1} ", desWords, p.name);
                        }

                        keyWords1 = keyWords1.Trim();
                        keyWords2 = keyWords1.Replace(" ", "/");
                        desWords2 = desWords.Trim();

                        keyWords2 = string.Format("[{0}]", keyWords2);
                        desWords  = string.Format("[{0}]", desWords2);

                        prompt = string.Format("\n** WARNING ** Multiple Point Groups in Selection: {0} Found!", desWords);
                        BaseObjs.write(prompt);

                        desWords = desWords.Replace(" ", "/");

                        string resDesc = pntGroups[0].name;
                        string resKey  = pntGroups[0].key;

                        pntGrpSymCol = CgPnt_Group.pntGroups.Find(s => s.name == resDesc);

                        prompt = string.Format("\nSelect Target Point Group from List: {0} <{1}> {2}", desWords, pntGrpSymCol.name, desWords);

                        escape = UserInput.getUserInputKeyword(resDesc, out resDesc, prompt, desWords2);

                        pntGrpSymCol = CgPnt_Group.pntGroups.Find(s => s.name == resDesc);

                        List <ObjectId> idsT = new List <ObjectId>();
                        foreach (ObjectId id in idsPnts)
                        {
                            if (id.getCogoPntDesc() == pntGrpSymCol.name)
                            {
                                idsT.Add(id);
                            }
                        }
                        idsPnts = idsT;
                    }
                    catch (System.Exception ex)
                    {
                        BaseObjs.writeDebug(ex.Message + " cmdMCE.cs: line: 161");
                    }
                }

                escape = UserInput.getUserInput("\nEnter new elevation (or +/- change) for points: ", out result, false);

                if (!escape)
                {
                    if (!double.TryParse(result.Substring(0, 1), out elev))
                    {
                        if (result.Substring(0, 1) != "+" && result.Substring(0, 1) != "-")
                        {
                            Application.ShowAlertDialog("Error in input.  Please try again...");
                            return;
                        }
                    }
                }
            }


            List <ObjectId> idsPoly3dSLP = new List <ObjectId>();

            try
            {
                foreach (ObjectId id in idsPnts)
                {
                    double elev0 = id.getCogoPntElevation();
                    elev = id.setPointElevation(result);
                    ResultBuffer rb = id.getXData(null);
                    if (rb != null)
                    {
                        TypedValue[]        tvsAll   = rb.AsArray();
                        List <string>       nameApps = null;
                        List <TypedValue[]> lstTVs   = xData.parseXData(tvsAll, out nameApps);

                        foreach (TypedValue[] tvsPnt in lstTVs)
                        {
                            string nameApp = tvsPnt[0].Value.ToString();
                            switch (nameApp)
                            {
                            case apps.lnkBrks:
                            case apps.lnkBrks2:
                                Grading_Utility.objPnt_Modified(id, nameApp, ref idsPoly3dSLP);                   //update breaklines
                                break;

                            case apps.lnkCO:
                                Grading_Utility.updatePntCalloutElev(elev, tvsPnt);              //update callouts
                                break;

                            case apps.lnkDP:
                                if (tvsPnt[2].Value.ToString() == "Primary")
                                {
                                    Grading_Utility.updatePntCalloutElev(elev, tvsPnt);         //update callouts
                                }
                                break;

                            case apps.lnkGS:
                                System.Diagnostics.Debug.Print(id.getHandle().ToString());
                                Grading_Utility.updateGS(tvsPnt, "cmdMCE");                      //update GS0
                                break;

                            case apps.lnkMNP:
                                double dZ = elev - elev0;
                                PipeNetwork.updatePipes(dZ, elev0, id);

                                break;
                            }
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " cmdMCE.cs: line: 233");
            }

            if (idsPoly3dSLP.Count > 0)
            {
                foreach (ObjectId idPoly3dSLP in idsPoly3dSLP)
                {
                    Grading_UpdateSG.updateSG(idPoly3dSLP);
                }
            }
        }
コード例 #2
0
        doStretchMove(List <EM_EData> enData)
        {
            foreach (EM_EData eData in enData)
            {
                List <ObjectId> ids = null;
                ObjectId        idP3d, idLdr;
                List <Handle>   handles = null;
                ObjectId        idCgPnt, idMTxt;
                bool            exists;

                TypedValue[] tvs     = eData.tvs;
                string       nameApp = tvs[0].Value.ToString();

                switch (nameApp)
                {
                case apps.lnkGS:
                    switch (eData.objType)
                    {
                    case "CogoPoint":
                        idCgPnt = eData.id;
                        Grading_Utility.updateGS(tvs, "Grip_Stretch_Move");
                        break;

                    case "MText":
                        idMTxt = eData.id;
                        LdrText_Move.moveLdrGS(idMTxt, tvs, eData.pnt3d);
                        break;

                    case "Leader":
                        idLdr = eData.id;
                        LdrText_Move.moveTxtGS(idLdr, tvs);
                        break;
                    }
                    break;

                case apps.lnkBrks:
                    ids     = tvs.getObjectIdList();
                    handles = tvs.getHandleList();

                    foreach (Handle handle in handles)
                    {
                        idP3d = Grading_Utility.update3dPoly_lnkBrks1_2(apps.lnkBrks, eData.id, handle);
                        if (idP3d == ObjectId.Null)
                        {
                            handles.Remove(handle);
                        }
                    }
                    break;

                case apps.lnkBrks2:
                    ids     = tvs.getObjectIdList();
                    handles = tvs.getHandleList();
                    foreach (Handle handle in handles)
                    {
                        idP3d = Grading_Utility.update3dPoly_lnkBrks1_2(apps.lnkBrks2, eData.id, handle);
                        if (idP3d == ObjectId.Null)
                        {
                            handles.Remove(handle);
                        }
                    }
                    ObjectId idDictM   = Dict.getNamedDictionary(apps.lnkBrks3, out exists);
                    ObjectId idDictPnt = Dict.getSubEntry(idDictM, eData.id.getHandle().ToString());

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

                        ResultBuffer rb2 = Dict.getXRec(idDictX, "Offset");
                        tvs = rb2.AsArray();
                        double offset = (double)tvs[0].Value;

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

                        rb2 = Dict.getXRec(idDictX, "HandleFL");
                        tvs = rb2.AsArray();
                        Handle handleFL = (Handle)tvs[0].Value;

                        rb2 = Dict.getXRec(idDictX, "Beg");
                        tvs = rb2.AsArray();
                        double beg = (double)tvs[0].Value;

                        rb2 = Dict.getXRec(idDictX, "End");
                        tvs = rb2.AsArray();
                        double end = (double)tvs[0].Value;

                        Grading_Utility.update3dPoly_lnkBrks3(idDictX.getHandle(), offset, deltaZ, handleFL, beg, end);
                    }
                    break;

                case apps.lnkBubs:
                    switch (eData.objType)
                    {
                    case "MText":
                        BB_Events.modTXlnkBubs(eData.id, tvs);
                        break;

                    case "Leader":
                        BB_Events.modLDRlnkBubs(eData.id, tvs);
                        break;
                    }
                    break;

                case apps.lnkCO:
                case apps.lnkLD:
                    switch (eData.objType)
                    {
                    case "CogoPoint":
                        idCgPnt = eData.id;
                        idMTxt  = tvs.getObjectId(3);
                        ResultBuffer rbMTxt  = idMTxt.getXData(nameApp);
                        TypedValue[] tvsMTxt = rbMTxt.AsArray();

                        idLdr = tvsMTxt.getObjectId(3);
                        Point3d pnt3dCgPoint = idCgPnt.getCogoPntCoordinates();
                        Point3d pnt3dLdr     = idLdr.getBegPnt();
                        if (!pnt3dCgPoint.X.Equals(pnt3dLdr.X) || !pnt3dCgPoint.Y.Equals(pnt3dLdr.Y))
                        {
                            idLdr.adjLdrBegPnt(pnt3dCgPoint);
                        }
                        Grading_Utility.updatePntCalloutElev(pnt3dCgPoint.Z, tvs);
                        break;

                    case "MText":
                        idMTxt = eData.id;
                        try
                        {
                            LdrText_Move.moveTX(idMTxt, tvs, eData.pnt3d);
                        }
                        catch (System.Exception ex)
                        {
                            BaseObjs.writeDebug(ex.Message + " EM_StretchMove.cs: line: 147");
                        }
                        break;

                    case "Leader":
                        idLdr = eData.id;
                        LdrText_Rotate.adjTxt(idLdr, nameApp);
                        break;
                    }
                    break;


                //case apps.lnkLD:
                //    switch (eData.objType)
                //    {
                //        case "CogoPoint":
                //            break;

                //        case "MText":
                //            idMTxt = eData.id;
                //            try
                //            {
                //                LdrText_Move.moveTX(idMTxt, tvs, eData.pnt3d);
                //            }
                //            catch (System.Exception ex)
                //            {
                //                BaseObjs.writeDebug(string.Format("{0} EM_StretchMove.cs: line: 138", ex.Message));
                //            }
                //            break;

                //        case "Leader":
                //            idLdr = eData.id;
                //            LdrText_Rotate.adjTxt(idLdr, nameApp);
                //            break;
                //    }
                //    break;

                case apps.lnkDimPL:
                    if (eData.objType == "MText")
                    {
                        idMTxt = eData.id;
                        DimPL_Move.modTXlnkDimPl(idMTxt, tvs, idMTxt.getMTextLocation());
                    }
                    break;

                case apps.lnkMNP:
                    ObjectId id = eData.id;
                    switch (eData.objType)
                    {
                    case "Pipe":
                        using (Transaction tr = BaseObjs.startTransactionDb())
                        {
                            Pipe pipe = (Pipe)tr.GetObject(id, OpenMode.ForWrite);
                            idCgPnt = tvs.getObjectId(1);
                            CogoPoint cgPNt = (CogoPoint)tr.GetObject(idCgPnt, OpenMode.ForWrite);

                            double dZ  = pipe.InnerDiameterOrWidth / (2 * System.Math.Cos(System.Math.Atan(System.Math.Abs(pipe.Slope))));
                            double inv = pipe.StartPoint.Z - dZ;
                            cgPNt.Elevation = inv;

                            ResultBuffer rb = idCgPnt.getXData(apps.lnkCO);
                            if (rb != null)
                            {
                                TypedValue[] tvsCgPNt = rb.AsArray();

                                Grading.Grading_Utility.updatePntCalloutElev(inv, tvsCgPNt);
                                BaseObjs.updateGraphics();
                            }

                            idCgPnt         = tvs.getObjectId(2);
                            cgPNt           = (CogoPoint)tr.GetObject(idCgPnt, OpenMode.ForWrite);
                            inv             = pipe.EndPoint.Z - dZ;
                            cgPNt.Elevation = inv;

                            rb = idCgPnt.getXData(apps.lnkCO);
                            if (rb != null)
                            {
                                TypedValue[] tvsCgPNt = rb.AsArray();

                                Grading.Grading_Utility.updatePntCalloutElev(inv, tvsCgPNt);
                                BaseObjs.updateGraphics();
                            }
                            tr.Commit();
                        }

                        break;

                    case "Structure":
                        Structure s = (Structure)id.getEnt();
                        break;
                    }
                    break;
                }
            }
        }