예제 #1
0
파일: xData.cs 프로젝트: 15831944/EM
        updatePntXData(this ObjectId idCgPnt, ObjectId idPoly3d, string nameApp)
        {
            try
            {
                checkPointXDataXNodes(idCgPnt, nameApp);
                Handle hPoly3d = idPoly3d.getHandle();

                ResultBuffer rbo = idCgPnt.getXData(nameApp);

                if (rbo != null)
                {
                    List <Handle> handles = rbo.rb_handles();
                    handles.Add(hPoly3d);
                    idCgPnt.clearXData(nameApp);
                    idCgPnt.setXData(handles, nameApp);
                }
                else
                {
                    TypedValue[] TVs = new TypedValue[2];
                    TVs.SetValue(new TypedValue(1001, nameApp), 0);
                    TVs.SetValue(new TypedValue(1005, hPoly3d), 1);

                    idCgPnt.setXData(TVs, nameApp);
                }
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " xData.cs: line: 677");
            }
        }
예제 #2
0
        updatePntXData(CogoPoint cogoPnt, ObjectId idPoly3d)
        {
            try {
                checkPointXDataXNodes(cogoPnt, apps.lnkBrks);
                ResultBuffer RB0     = cogoPnt.ObjectId.getXData(apps.lnkBrks);
                Handle       hPoly3d = idPoly3d.getHandle();

                if (RB0 != null)
                {
                    List <Handle> handles = RB0.rb_handles();
                    handles.Add(hPoly3d);
                    cogoPnt.ObjectId.clearXData(apps.lnkBrks);
                    cogoPnt.ObjectId.setXData(handles.handles_RB(apps.lnkBrks), apps.lnkBrks);
                }
                else
                {
                    TypedValue[] tvs = new TypedValue[2];
                    tvs.SetValue(new TypedValue(1001, apps.lnkBrks), 0);
                    tvs.SetValue(new TypedValue(1005, hPoly3d), 1);

                    ResultBuffer RBX = new ResultBuffer(tvs);
                    cogoPnt.ObjectId.setXData(tvs, apps.lnkBrks);
                }
            }
            catch (System.Exception ex) {
                BaseObjs.writeDebug(ex.Message + " Grading_xData.cs: line: 192");
            }
        }
예제 #3
0
파일: xData.cs 프로젝트: 15831944/EM
 replaceHandleInXdata(this ObjectId id, string nameApp, Handle hAdd, Handle hDel)
 {
     TypedValue[] tvsNew = null;
     try
     {
         using (Transaction tr = BaseObjs.startTransactionDb())
         {
             ResultBuffer rb = id.getXData(nameApp);
             if (rb == null)
             {
                 return;
             }
             List <Handle> handles = rb.rb_handles();
             int           x       = handles.IndexOf(hDel);
             handles.Insert(x, hAdd);
             handles.Remove(hDel);
             tvsNew = new TypedValue[handles.Count + 1];
             tvsNew.SetValue(new TypedValue(1001, nameApp), 0);
             for (int i = 0; i < handles.Count; i++)
             {
                 tvsNew.SetValue(new TypedValue(1005, handles[i]), i + 1);
             }
             id.clearXData(nameApp);
             id.setXData(tvsNew, nameApp);
             tr.Commit();
         }
     }
     catch (System.Exception ex)
     {
         BaseObjs.writeDebug(ex.Message + " xData.cs: line: 603");
     }
 }
예제 #4
0
        replacePntXData(CogoPoint cogoPnt, CogoPoint cogoPntX, Polyline3d poly3d)
        {
            try {
                ResultBuffer  RB0     = poly3d.ObjectId.getXData(apps.lnkBrks);
                List <Handle> handles = RB0.rb_handles();                    //get list of unique non Zero handles

                int i = handles.IndexOf(cogoPnt.Handle);
                handles.RemoveAt(i);
                handles.Insert(i, cogoPntX.Handle);

                poly3d.ObjectId.clearXData(apps.lnkBrks);
                poly3d.ObjectId.setXData(handles.handles_RB(apps.lnkBrks), apps.lnkBrks3);
            }
            catch (System.Exception ex) {
                BaseObjs.writeDebug(ex.Message + " Grading_xData.cs: line: 166");
            }
        }
예제 #5
0
파일: xData.cs 프로젝트: 15831944/EM
 checkPointXDataXNodes(ObjectId idCgPnt, string nameApp)
 {
     try
     {
         ResultBuffer rbo = idCgPnt.getXData(nameApp);
         if (rbo != null)
         {
             //CLEAR XDATA
             List <Handle> handles = rbo.rb_handles();
             Handle        h       = "0".stringToHandle();
             ObjectId      id      = ObjectId.Null;
             //Working with a list of unique non-zero handles
             int k = handles.Count;
             for (int i = k - 1; i > -1; i--)
             {
                 //GET BREAKLINE PER STORED HANDLES
                 try
                 {
                     h  = handles[i];
                     id = h.getObjectId();
                     if (!id.IsValid || id.IsErased || id.IsEffectivelyErased)
                     {
                         handles.RemoveAt(i);
                         continue;
                     }
                 }
                 catch (System.Exception)
                 {
                     handles.RemoveAt(i);
                 }
                 Polyline3d poly3d = (Polyline3d)h.getEnt();
                 if (poly3d == null)
                 {
                     handles.RemoveAt(i);
                 }
             }
             idCgPnt.clearXData(nameApp);
             idCgPnt.setXData(handles, nameApp);
         }
     }
     catch (System.Exception ex)
     {
         BaseObjs.writeDebug(ex.Message + " xData.cs: line: 191");
     }
 }
예제 #6
0
파일: xData.cs 프로젝트: 15831944/EM
        removeHandleFromXDataGS(this ObjectId id, string nameApp, Handle h)
        {
            ResultBuffer rb = id.getXData(nameApp);

            if (rb == null)
            {
                return;
            }
            TypedValue[]  tvs     = rb.AsArray();
            List <Handle> handles = rb.rb_handles();

            switch (handles.Count)
            {
            case 0:
                id.clearXData(nameApp);
                break;

            case 1:
                if (h.ToString() == handles[0].ToString())
                {
                    id.clearXData(nameApp);
                }
                break;

            default:
                if (handles.Contains(h))
                {
                    handles.Remove(h);
                }
                TypedValue[] tvsNew = new TypedValue[2 + handles.Count];
                tvsNew.SetValue(tvs[0], 0);
                tvsNew.SetValue(tvs[1], 1);
                for (int i = 0; i < handles.Count; i++)
                {
                    tvsNew.SetValue(new TypedValue(1005, handles[i]), i + 2);
                }
                id.clearXData(nameApp);
                id.setXData(tvsNew, nameApp);
                break;
            }
        }
예제 #7
0
파일: cmdCPXD.cs 프로젝트: 15831944/EM
        checkPntXData()
        {
            using (BaseObjs._acadDoc.LockDocument())
            {
                try
                {
                    using (Transaction tr = BaseObjs.startTransactionDb())
                    {
                        TypedValue[] TVs = new TypedValue[1];
                        TVs.SetValue(new TypedValue((int)DxfCode.Start, RXClass.GetClass(typeof(CogoPoint)).DxfName), 0);
                        SelectionSet ss = Select.buildSSet(TVs);
                        if (ss != null)
                        {
                            foreach (ObjectId id in ss.GetObjectIds())
                            {
                                ResultBuffer rb = null;

                                if (id.IsValid)
                                {
                                    rb = id.getXData(apps.lnkBrks);
                                    if (rb != null)
                                    {
                                        List <Handle> handles = rb.rb_handles();
                                        Handle        hZero   = "0".stringToHandle();
                                        if (handles.Contains(hZero))
                                        {
                                            handles.Remove(hZero);
                                        }
                                    }
                                }
                            }
                        }
                        tr.Commit();
                    }
                }
                catch (System.Exception ex)
                {
                    BaseObjs.writeDebug(ex.Message + " cmdCPXD.cs: line: 50");
                }
            }
        }
예제 #8
0
        resetHandle(ObjectId idPoly3d)
        {
            ResultBuffer      rb      = idPoly3d.getXData(apps.lnkBrks);
            List <Handle>     handles = rb.rb_handles();
            Point3dCollection pnts3d  = idPoly3d.getCoordinates3d();

            if (handles.Count == pnts3d.Count)
            {
                for (int i = 0; i < handles.Count; i++)
                {
                    Point3d pnt3dCogoPnt = handles[i].getCogoPntCoordinates();
                    if (Measure.getDistance2d(pnts3d[i], pnt3dCogoPnt, 3) == 0.0 && pnts3d[i].Z == pnt3dCogoPnt.Z)
                    {
                    }
                    else
                    {
                        idPoly3d.updateVertex(i, pnt3dCogoPnt);
                    }
                }
            }
        }
예제 #9
0
 checkPointXDataXNodes(CogoPoint cogoPnt, string nameApp)
 {
     try {
         ResultBuffer RB0 = cogoPnt.ObjectId.getXData(nameApp);
         if (RB0 != null)
         {
             List <Handle> handles = RB0.rb_handles();
             Handle        h       = "0".stringToHandle();
             ObjectId      id      = ObjectId.Null;
             int           k       = handles.Count;
             for (int i = k - 1; i > -1; i--)
             {
                 try
                 {
                     h  = handles[i];
                     id = h.getObjectId();
                     if (!id.IsValid || id.IsErased || id.IsEffectivelyErased)
                     {
                         handles.RemoveAt(i);
                         continue;
                     }
                 }
                 catch (System.Exception ex)
                 {
                     handles.RemoveAt(i);
                 }
                 Polyline3d poly3d = (Polyline3d)h.getEnt();
                 if (poly3d == null)
                 {
                     handles.RemoveAt(i);
                 }
             }
             cogoPnt.ObjectId.clearXData(nameApp);
             cogoPnt.ObjectId.setXData(handles.handles_RB(nameApp), nameApp);
         }
     }
     catch (System.Exception ex) {
         BaseObjs.writeDebug(ex.Message + " Grading_xData.cs: line: 107");
     }
 }
예제 #10
0
        checkPointXData2Nodes(ObjectId idCogoPnt, ResultBuffer RBpnt, string nameApp)
        {
            try {
                List <Handle> handlesP3d = RBpnt.rb_handles();

                int i = 0;
                foreach (Handle hP3d in handlesP3d)
                {
                    Polyline3d poly3d = (Polyline3d)Db.handleToObject(hP3d.ToString());

                    if ((poly3d != null))
                    {
                        if (poly3d.Length != 0)
                        {
                            ResultBuffer      RBp3d        = poly3d.ObjectId.getXData(nameApp);
                            List <Handle>     handlesPnts  = RBp3d.rb_handles();
                            Handle            hPnt         = idCogoPnt.getHandle();
                            Point3dCollection pnts3d       = poly3d.getCoordinates3d();
                            Point3d           pnt3dCogoPnt = hPnt.getCogoPntCoordinates();

                            if (System.Math.Round(pnts3d[0].X, 3) == System.Math.Round(pnt3dCogoPnt.X, 3) &&
                                System.Math.Round(pnts3d[0].Y, 3) == System.Math.Round(pnt3dCogoPnt.Y, 3))
                            {
                                if (pnts3d[0].Z != pnt3dCogoPnt.Z)
                                {
                                    poly3d.setBegPnt(pnt3dCogoPnt);
                                }
                                if (!handlesPnts.Contains(hPnt))
                                {
                                    handlesPnts.Add(hPnt);
                                    poly3d.ObjectId.setXData(handlesPnts, nameApp);
                                }
                            }
                            else if (System.Math.Round(pnts3d[1].X, 3) == System.Math.Round(pnt3dCogoPnt.X, 3) &&
                                     System.Math.Round(pnts3d[1].Y, 3) == System.Math.Round(pnt3dCogoPnt.Y, 3))
                            {
                                if (pnts3d[1].Z != pnt3dCogoPnt.Z)
                                {
                                    poly3d.setEndPnt(pnt3dCogoPnt);
                                }
                                if (!handlesPnts.Contains(hPnt))
                                {
                                    handlesPnts.Add(hPnt);
                                    poly3d.ObjectId.setXData(handlesPnts, nameApp);
                                }
                            }
                            else
                            {
                                poly3d.ObjectId.delete();
                                handlesP3d.RemoveAt(i);
                                RBpnt = handlesP3d.handles_RB(nameApp);
                                idCogoPnt.setXData(RBpnt.AsArray(), nameApp);
                            }
                        }
                        else
                        {
                            poly3d.ObjectId.delete();
                            handlesP3d.RemoveAt(i);
                            RBpnt = handlesP3d.handles_RB(nameApp);
                            idCogoPnt.setXData(RBpnt.AsArray(), nameApp);
                        }
                    }
                    else
                    {
                        handlesP3d.RemoveAt(i);
                        RBpnt = handlesP3d.handles_RB(nameApp);
                        idCogoPnt.setXData(RBpnt.AsArray(), nameApp);
                    }
                    i++;
                }
            }
            catch (System.Exception ex) {
                BaseObjs.writeDebug(ex.Message + " Grading_xData.cs: line: 70");
            }
            return(RBpnt);
        }
예제 #11
0
        CBF()
        {
            try
            {
                AeccDatabase db = BaseObjsCom.aeccDb;


                ObjectId idPoly3d = Select.getBrkLine("Select 3d Breakline");
                Handle   hPoly3d  = idPoly3d.getHandle();

                ResultBuffer rbPoly3d = idPoly3d.getXData(apps.lnkBrks);
                if (rbPoly3d == null)
                {
                    return;
                }
                List <Handle>       hCgPnts  = rbPoly3d.rb_handles();
                TypedValue[]        tvsX     = rbPoly3d.AsArray();
                List <string>       nameApps = null;
                List <TypedValue[]> lstTVs   = xData.parseXData(tvsX, out nameApps);

                AeccSites sites  = db.Sites;
                AeccSite  site   = null;
                bool      exists = false;

                foreach (AeccSite s in sites)
                {
                    if (s.Name == "Site1")
                    {
                        site   = s;
                        exists = true;
                        break;
                    }
                }
                if (!exists)
                {
                    site = sites.Add("Site1");
                }

                AeccLandFeatureLines  features = site.FeatureLines;
                AeccFeatureLineStyles styles   = db.FeatureLineStyles;
                AeccFeatureLineStyle  style    = styles[0];

                long idOldPoly3d = (long)idPoly3d.OldIdPtr;

                AeccLandFeatureLine feature = features.AddFromPolyline(idOldPoly3d, style);
                feature.Layer = idPoly3d.getLayer();



                short[]  varType = null;
                object[] varVal  = null;

                for (int i = 0; i < lstTVs.Count; i++)
                {
                    TypedValue[] tvs     = lstTVs[i];
                    string       nameApp = tvs[0].Value.ToString();
                    if (nameApp == apps.lnkBrks)
                    {
                        myUtility.tvsToList(tvs, ref varType, ref varVal);
                        feature.SetXData(varType, varVal);
                        break;
                    }
                }



                Polyline3d poly3d = (Polyline3d)idPoly3d.getEnt();

                foreach (Handle hCgPnt in hCgPnts)
                {
                    ObjectId idCgPnt = hCgPnt.getObjectId();
                    idCgPnt.replaceHandleInXdata(apps.lnkBrks, feature.Handle.stringToHandle(), poly3d.Handle);
                }

                rbPoly3d = idPoly3d.getXData(apps.lnkBrks3);
                if (rbPoly3d == null)
                {
                    return;
                }

                TypedValue[] tvsPoly3d  = rbPoly3d.AsArray();
                ObjectId     idPoly3dFL = tvsPoly3d[1].getObjectId();

                idPoly3dFL.replaceHandleInXdata(apps.lnkBrks3, feature.Handle.stringToHandle(), poly3d.Handle);

                varType = new short[2];
                varVal  = new object[2];

                varType[0] = 1001;
                varVal[0]  = apps.lnkBrks3;
                varType[1] = 1005;
                varVal[1]  = idPoly3dFL.getHandle().ToString();

                feature.SetXData(varType, varVal);

                idPoly3d.delete();
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " cmdCBF.cs: line: 107");
            }
        }
예제 #12
0
        objPnt_Modified(ObjectId idCogoPnt, string nameApp, ref List <ObjectId> idsPoly3dSLP)
        {
            ObjectId     idPoly3d = ObjectId.Null;
            ResultBuffer rb       = idCogoPnt.getXData(nameApp);

            if (rb != null)
            {
                List <Handle> handles = rb.rb_handles();
                switch (nameApp)
                {
                case apps.lnkBrks:

                    foreach (Handle handle in handles)
                    {
                        try
                        {
                            idPoly3d = update3dPoly_lnkBrks1_2(apps.lnkBrks, idCogoPnt, handle);
                        }
                        catch (System.Exception ex)
                        {
                            BaseObjs.writeDebug(ex.Message + " Grading_Utility.cs: line: 38");
                        }
                    }

                    ResultBuffer rbSLP = idPoly3d.getXData(apps.lnkSLP);
                    if (rbSLP != null)
                    {
                        if (!idsPoly3dSLP.Contains(idPoly3d))
                        {
                            idsPoly3dSLP.Add(idPoly3d);
                        }
                    }

                    break;

                case apps.lnkBrks2:

                    foreach (Handle handle in handles)
                    {
                        try
                        {
                            idPoly3d = update3dPoly_lnkBrks1_2(apps.lnkBrks2, idCogoPnt, handle);
                        }
                        catch (System.Exception ex)
                        {
                            BaseObjs.writeDebug(ex.Message + " Grading_Utility.cs: line: 61");
                        }
                    }

                    bool     exists    = false;
                    ObjectId idDictM   = Dict.getNamedDictionary(apps.lnkBrks3, out exists);
                    ObjectId idDictPnt = Dict.getSubEntry(idDictM, idCogoPnt.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");
                        TypedValue[] 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 = tvs[0].Value.ToString().stringToHandle();

                        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;

                        Handle h3dPoly = entry.Key.ToString().stringToHandle();
                        update3dPoly_lnkBrks3(h3dPoly, offset, deltaZ, handleFL, beg, end);
                    }
                    break;
                }
            }
        }
예제 #13
0
        doDelete(List <EM_EData> enData)
        {
            List <Handle> hDeletes = new List <Handle>();

            foreach (var edata in enData)
            {
                hDeletes.Add(edata.h);
            }

            bool pass = false;

            foreach (EM_EData eData in enData)
            {
                if (pass)
                {
                    return;
                }
                List <ObjectId> ids = null;
                ObjectId        idEnt, idDict, idTxTop, idTxBot, idTxBot2, idLdr, idLdr1, idLdr2, idCgPnt1, idCgPnt2;
                List <Handle>   handles = null;

                TypedValue[] tvs = eData.tvs;

                string       nameApp = tvs[0].Value.ToString();
                string       nameObj, nameCmd;
                ObjectId     id = ObjectId.Null;
                bool         exists;
                TypedValue[] tvsTx;

                try
                {
                    switch (nameApp)
                    {
                    case "AVG":
                        ObjectId idDictGRADEDOCK = Dict.getNamedDictionary("GRADEDOCK", out exists);
                        if (!exists)
                        {
                            continue;
                        }
                        Dict.delSubDict(idDictGRADEDOCK, tvs[2].Value.ToString());
                        break;

                    case apps.lnkBubs:
                        nameObj = tvs[1].Value.ToString();
                        if (nameObj == "TX")
                        {
                            BB_Events.deleteSmWoLdrs(tvs);
                        }
                        break;

                    case apps.lnkCO:
                        try
                        {
                            nameCmd = tvs[1].Value.ToString();
                            nameObj = tvs[2].Value.ToString();
                            switch (nameObj)
                            {
                            case "TX":
                                idLdr    = tvs.getObjectId(3);
                                idTxBot  = tvs.getObjectId(4);
                                idTxBot2 = tvs.getObjectId(5);
                                idCgPnt1 = tvs.getObjectId(10);
                                xData.removeCmdXDataFromCogoPoint(idCgPnt1, nameApp, nameCmd);                   //remove xdata from point for this entry
                                idLdr.delete();
                                idTxBot.delete();
                                idTxBot2.delete();
                                break;

                            case "LDR":
                                idTxTop  = tvs.getObjectId(3);
                                idTxBot  = tvs.getObjectId(4);
                                idTxBot2 = tvs.getObjectId(5);
                                tvsTx    = idTxTop.getXData(nameApp).AsArray();
                                idCgPnt1 = tvsTx.getObjectId(10);
                                xData.removeCmdXDataFromCogoPoint(idCgPnt1, nameApp, nameCmd);                   //remove xdata from point for this entry
                                idTxTop.delete();
                                idTxBot.delete();
                                idTxBot2.delete();
                                break;

                            case "CogoPoint":
                                foreach (TypedValue tv in tvs)
                                {
                                    if (tv.TypeCode == 1005)
                                    {
                                        idTxTop = tv.Value.ToString().stringToHandle().getObjectId();
                                        ResultBuffer rb       = idTxTop.getXData(nameApp);
                                        TypedValue[] tvsTxTop = rb.AsArray();
                                        tvsTxTop.deleteLinkedEnts();
                                        idTxTop.delete();
                                    }
                                }
                                break;
                            }
                            if (eData.objType == "MText")
                            {
                                idDict = Dict.getNamedDictionary(nameApp, out exists);
                                Dict.delSubDict(idDict, eData.h.ToString());
                            }
                        }
                        catch (System.Exception ex)
                        {
                            BaseObjs.writeDebug(ex.Message + " EM_Delete.cs: line: 107");
                        }
                        break;

                    case apps.lnkDimPL:
                        idLdr1 = tvs.getObjectId(11);
                        idLdr2 = tvs.getObjectId(12);
                        idLdr1.delete();
                        idLdr2.delete();
                        idDict = Dict.getNamedDictionary(nameApp, out exists);
                        Dict.delSubDict(idDict, eData.h.ToString());
                        break;

                    case apps.lnkGS:
                        if (eData.objType == "CogoPoint")
                        {
                            for (int i = 2; i < tvs.Length; i++)
                            {
                                idTxTop = tvs.getObjectId(i);
                                ResultBuffer rbTxt = idTxTop.getXData(apps.lnkGS);
                                idTxTop.delete();
                                if (rbTxt == null)
                                {
                                    continue;
                                }
                                TypedValue[] tvsTxt = rbTxt.AsArray();
                                idLdr = tvsTxt[3].getObjectId();
                                idLdr.delete();
                                handles = new List <Handle>();
                                handles.Add(tvsTxt[9].getObjectId().getHandle());
                                handles.Add(tvsTxt[10].getObjectId().getHandle());
                                handles.Remove(eData.h);
                                idCgPnt1 = handles[0].getObjectId();
                                idCgPnt1.removeHandleFromXDataGS(apps.lnkGS, eData.h);
                            }
                        }
                        if (eData.objType == "MText")
                        {
                            idLdr = tvs.getObjectId(3);
                            idLdr.delete();
                            idCgPnt1 = tvs.getObjectId(9);
                            idCgPnt1.removeHandleFromXDataGS(apps.lnkGS, eData.h);
                            idCgPnt2 = tvs.getObjectId(10);
                            idCgPnt2.removeHandleFromXDataGS(apps.lnkGS, eData.h);
                        }

                        break;

                    case apps.lnkDP:
                        break;

                    case apps.lnkLD:
                        try
                        {
                            if (tvs[2].Value.ToString() == "TX")
                            {
                                idLdr   = tvs.getObjectId(3);
                                idTxBot = tvs.getObjectId(4);
                                if (!idLdr.IsErased && idLdr != ObjectId.Null)
                                {
                                    idLdr.delete();
                                }
                                if (!idTxBot.IsErased && idTxBot != ObjectId.Null)
                                {
                                    idTxBot.delete();
                                }
                                idDict = Dict.getNamedDictionary(nameApp, out exists);
                                Dict.delSubDict(idDict, eData.h.ToString());
                            }
                            if (tvs[2].Value.ToString() == "LDR")
                            {
                                idTxTop = tvs.getObjectId(3);
                                if (!idTxTop.IsErased && idTxTop != ObjectId.Null)
                                {
                                    Handle h = idTxTop.getHandle();
                                    idTxTop.delete();
                                    idDict = Dict.getNamedDictionary(nameApp, out exists);
                                    Dict.delSubDict(idDict, h.ToString());
                                }
                                idTxBot = tvs.getObjectId(4);
                                if (!idTxBot.IsErased && idTxBot != ObjectId.Null)
                                {
                                    idTxBot.delete();
                                }
                            }
                        }
                        catch (System.Exception ex)
                        {
                            BaseObjs.writeDebug(ex.Message + " EM_Delete.cs: line: 189");
                        }
                        break;

                    case apps.lblPnts:
                    case apps.lblPntsPT:
                        try
                        {
                            switch (eData.objType)
                            {
                            case "BlockReference":
                                tvs.deleteLinkedEnts();
                                //**************need to remove BlockReference handle from point******************
                                break;

                            case "Leader":
                                tvs.deleteLinkedEnts();
                                break;

                            case "CogoPoint":
                                ObjectId idBr = tvs.getObjectId(1);
                                if (idBr == ObjectId.Null)
                                {
                                    return;
                                }
                                ResultBuffer rbBr  = idBr.getXData(apps.lblPnts); //= Point XData -> Point links BlockReference / BlockReference links Leader
                                TypedValue[] tvsBr = rbBr.AsArray();
                                idLdr = tvsBr.getObjectId(1);                     //linked handle is in position 1 for lblPnts and lblPntsPT
                                idBr.delete();
                                idLdr.delete();
                                break;
                            }
                        }
                        catch (System.Exception ex)
                        {
                            BaseObjs.writeDebug(ex.Message + " EM_Delete.cs: line: 222");
                        }
                        break;

                    case apps.lnkBrks:
                        try
                        {
                            ids = tvs.getObjectIdList();
                            if (ids.Count == 0)
                            {
                                continue;
                            }

                            //MessageBox.Show(ids[0].getType());
                            if (eData.objType == "CogoPoint")     //Deleted ent was a CogoPoint
                            {
                                foreach (ObjectId idX in ids)     //idX is poly3d(s) linked to CogoPoint
                                {
                                    if (!idX.IsValid || idX.IsErased)
                                    {
                                        continue;
                                    }
                                    foreach (EM_EData eDataX in enData)
                                    {
                                        if (eDataX.tvs[0].Value.ToString() == apps.lnkBrks3)
                                        {
                                            ObjectId      idPoly3d = eDataX.tvs[1].getObjectId();
                                            List <Handle> hBrks    = idPoly3d.getXData(apps.lnkBrks).rb_handles();   //CogoPoints on each end of BB or GT
                                            List <Handle> hBrks3   = idPoly3d.getXData(apps.lnkBrks3).rb_handles();  //FL handle

                                            Handle hFL = hBrks3[0];

                                            Handle hCgPnt1 = hBrks[0];
                                            Handle hCgPnt2 = hBrks[1];

                                            ObjectId idFL = hFL.getObjectId();

                                            idFL.removeHandleFromXdata(apps.lnkBrks3, hCgPnt1);              //remove CogoPoint from FL.lnkBrks3
                                            idFL.removeHandleFromXdata(apps.lnkBrks3, hCgPnt2);              //remove CogoPoint from FL.lnkBrks3
                                            idFL.removeHandleFromXdata(apps.lnkBrks3, idPoly3d.getHandle()); //remove poly3d from FL.lnkBrks3

                                            hBrks.Remove(eData.h);                                           //remove deleted CogoPoint from list leaving CogoPoint at opposite end of poly3d
                                            hBrks[0].getObjectId().delete();                                 //delete CogoPoint at opposite end

                                            ResultBuffer rbSLP = idPoly3d.getXData(apps.lnkSLP);
                                            if (rbSLP != null)
                                            {
                                                TypedValue[]    tvsSLP = rbSLP.AsArray();
                                                List <ObjectId> idsSLP = tvsSLP.getObjectIdList();
                                                foreach (ObjectId idSLP in idsSLP)
                                                {
                                                    idSLP.delete();
                                                }
                                            }

                                            idPoly3d.delete();                              //delete poly3d
                                            pass = true;
                                        }
                                    }
                                    if (!pass)
                                    {
                                        Handle        hP3d  = idX.getHandle();                      //poly3d handle attached to CogoPoint
                                        ResultBuffer  rbX   = idX.getXData(apps.lnkBrks);           //path to other points linked to poly3d which is going to be deleted
                                        List <Handle> hPnts = rbX.rb_handles();                     //handles of points linked to poly3d including point to be deleted
                                        foreach (Handle h in hPnts)
                                        {
                                            if (h == eData.h)
                                            {
                                                continue;
                                            }
                                            ObjectId idT = h.getObjectId();                         //id of other point linked to poly3d
                                            if (!idT.IsValid || idT.IsEffectivelyErased || idT.IsErased)
                                            {
                                                continue;
                                            }

                                            if (hDeletes.Contains(h))
                                            {
                                                continue;
                                            }

                                            ResultBuffer rbT = idT.getXData(apps.lnkBrks);
                                            if (rbT == null)
                                            {
                                                continue;
                                            }
                                            List <Handle> hPolys = rbT.rb_handles();               //list of poly3d linked to other point
                                            if (hPolys.Contains(hP3d))
                                            {
                                                hPolys.Remove(hP3d);                               //remove poly3d handle from other point list
                                            }
                                            if (hPolys.Count > 0)
                                            {
                                                idT.setXData(hPolys, apps.lnkBrks);
                                            }
                                            else
                                            {
                                                idT.clearXData(apps.lnkBrks);
                                            }
                                        }
                                        idX.delete();
                                    }
                                }
                            }
                            else if (eData.objType == "Polyline3d" || eData.objType == "FeatureLine")
                            {                                //Deleted ent was a Polyline3d or Featureline
                                ids = tvs.getObjectIdList(); //points linked to poly3d or feature line
                                foreach (ObjectId idP in ids)
                                {
                                    if (idP.IsValid && !idP.IsEffectivelyErased && !idP.IsErased)
                                    {
                                        ResultBuffer rbP = idP.getXData(apps.lnkBrks);
                                        if (rbP == null)
                                        {
                                            continue;
                                        }
                                        List <Handle> hPnts = rbP.rb_handles();
                                        if (hPnts.Contains(eData.h))
                                        {
                                            hPnts.Remove(eData.h);
                                        }
                                        if (hPnts.Count > 0)
                                        {
                                            idP.setXData(hPnts, apps.lnkBrks2);
                                        }
                                        else
                                        {
                                            idP.clearXData(apps.lnkBrks);
                                        }
                                    }
                                }
                            }
                        }
                        catch (System.Exception ex)
                        {
                            BaseObjs.writeDebug(ex.Message + " EM_Delete.cs: line: 329");
                        }

                        break;

                    case apps.lnkBrks2:
                        try
                        {
                            ids = tvs.getObjectIdList();                                //FL stores end Cogo Points / Cogo Points store FL
                            if (ids.Count == 0)
                            {
                                continue;
                            }
                            idEnt = ids[0];                                             //idEnt is either a CogoPoint or a poly3d
                            //COGOPOINT DELETED
                            if (eData.objType == "CogoPoint")
                            {     //Deleted ent was a CogoPoint - get lnkBrks3 from poly3d (FL) and delete all entities listed
                                ResultBuffer rbFL2 = idEnt.getXData(apps.lnkBrks2);
                                if (rbFL2 == null)
                                {
                                    continue;
                                }
                                List <Handle> hCgPnts = rbFL2.rb_handles();
                                if (hCgPnts.Contains(eData.h))
                                {
                                    hCgPnts.Remove(eData.h);                            //remove deleted point leaving point at other end
                                }
                                if (hCgPnts.Count == 1)
                                {
                                    ObjectId idCgPntX = hCgPnts[0].getObjectId();
                                    updateCogoPointDict3(idCgPntX, idEnt.getHandle());
                                    idCgPntX.removeHandleFromXdata(apps.lnkBrks2, idEnt.Handle);
                                }

                                ResultBuffer rbP3d3 = idEnt.getXData(apps.lnkBrks3);
                                if (rbP3d3 == null)
                                {
                                    continue;
                                }

                                TypedValue[]    tvsP3D3 = rbP3d3.AsArray();
                                List <ObjectId> idsEdge = tvsP3D3.getObjectIdList();
                                foreach (ObjectId idEdge in idsEdge)
                                {
                                    idEdge.delete();
                                }
                                idEnt.delete();                                             //delete FL
                                //POLYLINE3D DELETED
                            }
                            else if (eData.objType == "Polyline3d")
                            {     //Deleted ent was a Polyline3d   !!!!!!!!!!!!!!!!!!!!!!! SAME AS lnkBrks !!!!!!!!!!!!!!!!!!!!!!!!
                                foreach (ObjectId idP3d in ids)
                                {
                                    ResultBuffer rbP = idP3d.getXData(apps.lnkBrks2);
                                    if (rbP == null)
                                    {
                                        continue;
                                    }
                                    handles = rbP.rb_handles();
                                    if (handles.Contains(eData.h))                          // clean up xdata on points; lnkBrks3 will take care of edges
                                    {
                                        handles.Remove(eData.h);
                                    }
                                    if (handles.Count > 0)
                                    {
                                        idP3d.setXData(handles, apps.lnkBrks2);
                                    }
                                    else
                                    {
                                        idP3d.clearXData(apps.lnkBrks2);
                                    }
                                    updateCogoPointDict3(idP3d, eData.h);
                                }
                            }
                        }
                        catch (System.Exception ex)
                        {
                            BaseObjs.writeDebug(ex.Message + " EM_Delete.cs: line: 388");
                        }
                        break;

                    case apps.lnkBrks3:
                        try
                        {
                            ids = tvs.getObjectIdList();
                            switch (ids.Count)
                            {
                            case 0:
                                break;

                            case 1:
                                ids[0].removeHandleFromXdata(apps.lnkBrks3, eData.h);
                                break;

                            default:
                                foreach (ObjectId idP in ids)
                                {
                                    if (idP.getType() == "CogoPoint")
                                    {
                                        ResultBuffer rbX = null;
                                        rbX = idP.getXData(apps.lnkBrks);
                                        if (rbX != null)
                                        {
                                            TypedValue[]    tvsX = rbX.AsArray();
                                            List <ObjectId> idsX = tvsX.getObjectIdList();
                                            foreach (ObjectId idX in idsX)
                                            {
                                                idX.delete();
                                            }
                                        }
                                    }
                                    idP.delete();
                                }
                                break;
                            }
                        }
                        catch (System.Exception ex)
                        {
                            BaseObjs.writeDebug(ex.Message + " EM_Delete.cs: line: 427");
                        }
                        break;

                    case apps.lnkSLP:
                        ids = tvs.getObjectIdList();
                        foreach (ObjectId idSLP in ids)
                        {
                            idSLP.delete();
                        }
                        break;
                    }
                }
                catch (System.Exception ex)
                {
                    BaseObjs.writeDebug(ex.Message + " EM_Delete.cs: line: 440");
                }
            }
        }
예제 #14
0
        trimEdgeToCurb(ObjectId idBlockRef, ObjectIdCollection idsPoly3d, ObjectId idPoly3dRF, List <Handle> handles3)
        {
            bool     ints     = false;
            ObjectId idPolyLT = handles3[1].getObjectId();
            ObjectId idPolyRT = handles3[3].getObjectId();

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

            pnt3dBox.Add(pnt3dBox[0]);

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

            string nameLayer = "CURB-TEMP";

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

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

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

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

                        Point3dCollection pnts3dInt0 = new Point3dCollection();

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

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

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

                        case "Polyline":

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

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

                                pnts3dInt0 = new Point3dCollection();

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

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

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

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

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

                CogoPoint cogoPntBEG;

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

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

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

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

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

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

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

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

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

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

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

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

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

                        Point3d pnt3dFLbeg = cogoPntBEG.Location;

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

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

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

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


                        distance = distance * 1.1;

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

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

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

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

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

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


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

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

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

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

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

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



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

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

                idsEntTemp.delete();

                idPoly3dRF.setXData(handles3, apps.lnkBrks3);
            }
            catch (System.Exception ex) {
                BaseObjs.writeDebug(ex.Message + " Grading_GetNestedCurbObjects.cs: line: 414");
            }
            return(ints);
        }
예제 #15
0
        updateBrkLines_Pnts()
        {
            int count1 = 0;
            int count2 = 0;
            int count3 = 0;
            int count4 = 0;
            int n      = 0;

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

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

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

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

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

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

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

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

            try
            {
                SelectionSet           ss       = Select.buildSSet(typeof(MText), true);
                ObjectId[]             idsMText = ss.GetObjectIds();
                IEnumerator <ObjectId> iEn      = (IEnumerator <ObjectId>)idsMText.GetEnumerator();
                ResultBuffer           rbMTxt   = null;
                foreach (ObjectId id in idsMText)
                {
                    rbMTxt = id.getXData(apps.lnkGS);
                    if (rbMTxt == null)
                    {
                        continue;
                    }
                    TypedValue[]  tvs     = rbMTxt.AsArray();
                    List <Handle> handles = rbMTxt.rb_handles();
                    foreach (Handle h in handles)
                    {
                        ObjectId idObj = h.getObjectId();
                        if (!idObj.IsValid)
                        {
                            xData.removeHandleFromXDataGS(id, apps.lnkGS, h);
                        }
                    }
                }
            }
            catch
            {
            }
        }
예제 #16
0
파일: xData.cs 프로젝트: 15831944/EM
        checkPointXData2Nodes(ObjectId idCogoPnt, ResultBuffer RBpnt, string nameApp)
        {
            try
            {
                List <Handle> handlesP3d = RBpnt.rb_handles();

                int i = 0;
                //Working with a list of unique non-zero handles
                foreach (Handle hP3d in handlesP3d)
                {
                    //GET BREAKLINE PER STORED HANDLES
                    Polyline3d poly3d = (Polyline3d)Db.handleToObject(hP3d.ToString());

                    if ((poly3d != null))
                    {
                        if (poly3d.Length != 0)
                        {
                            ResultBuffer  RBp3d       = poly3d.ObjectId.getXData(nameApp);
                            List <Handle> handlesPnts = RBp3d.rb_handles();
                            Handle        hPnt        = idCogoPnt.getHandle();
                            // if pnt handle is in poly3d handle list then check coordinates otherwise
                            Point3dCollection pnts3d       = poly3d.getCoordinates3d();
                            Point3d           pnt3dCogoPnt = hPnt.getCogoPntCoordinates();

                            if (System.Math.Round(pnts3d[0].X, 3) == System.Math.Round(pnt3dCogoPnt.X, 3) &&
                                System.Math.Round(pnts3d[0].Y, 3) == System.Math.Round(pnt3dCogoPnt.Y, 3))
                            {
                                if (pnts3d[0].Z != pnt3dCogoPnt.Z)
                                {
                                    poly3d.setBegPnt(pnt3dCogoPnt);
                                }
                                if (!handlesPnts.Contains(hPnt))
                                {
                                    handlesPnts.Add(hPnt);
                                    poly3d.ObjectId.setXData(handlesPnts, nameApp);
                                }
                            }
                            else if (System.Math.Round(pnts3d[1].X, 3) == System.Math.Round(pnt3dCogoPnt.X, 3) &&
                                     System.Math.Round(pnts3d[1].Y, 3) == System.Math.Round(pnt3dCogoPnt.Y, 3))
                            {
                                if (pnts3d[1].Z != pnt3dCogoPnt.Z)
                                {
                                    poly3d.setEndPnt(pnt3dCogoPnt);
                                }
                                if (!handlesPnts.Contains(hPnt))
                                {
                                    handlesPnts.Add(hPnt);
                                    poly3d.ObjectId.setXData(handlesPnts, nameApp);
                                }
                            }
                            else
                            {
                                poly3d.ObjectId.delete();
                                handlesP3d.RemoveAt(i);
                                RBpnt = handlesP3d.handles_RB(nameApp);
                                idCogoPnt.setXData(handlesP3d, nameApp);
                            }
                        }
                        else
                        {
                            poly3d.ObjectId.delete();
                            handlesP3d.RemoveAt(i);
                            RBpnt = handlesP3d.handles_RB(nameApp);
                            idCogoPnt.setXData(handlesP3d, nameApp);
                        }
                    }
                    else
                    {
                        //remove bad handle from list
                        handlesP3d.RemoveAt(i);
                        RBpnt = handlesP3d.handles_RB(nameApp);
                        idCogoPnt.setXData(handlesP3d, nameApp);
                    }
                    i++;
                }
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " xData.cs: line: 145");
            }
            return(RBpnt);
        }
예제 #17
0
        addBrksToPntXDict(ObjectId idPoly3dRF, ObjectId idPoly3dTAR, double offset, double deltaZ, double beg, double end)
        {
            ResultBuffer rb = idPoly3dRF.getXData(apps.lnkBrks2);  //FL stores end Cogo Points

            if (rb == null)
            {
                return;
            }
            List <Handle> handles = rb.rb_handles();

            if (handles.Count == 0)
            {
                return;
            }

            ObjectId idDictM = ObjectId.Null;
            bool     exists  = false;

            try
            {
                idDictM = Dict.getNamedDictionary(apps.lnkBrks3, out exists);     //dictionary for storing edge parameters
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " Grading_Dict.cs: line: 34");
            }

            ObjectId idDictPntBEG = Dict.getSubEntry(idDictM, handles[0].ToString());       //Cogo Point stores edge parameters in dictionary

            if (idDictPntBEG == ObjectId.Null)
            {
                idDictPntBEG = Dict.addSubDict(idDictM, handles[0].ToString());
            }

            ObjectId idDictB = Dict.getSubEntry(idDictPntBEG, idPoly3dTAR.getHandle().ToString());

            if (idDictB == ObjectId.Null)
            {
                idDictB = Dict.addSubDict(idDictPntBEG, idPoly3dTAR.getHandle().ToString());
            }
            else
            {
                Dict.removeSubEntry(idDictPntBEG, idPoly3dTAR.getHandle().ToString());
                idDictB = Dict.addSubDict(idDictPntBEG, idPoly3dTAR.getHandle().ToString());
            }

            TypedValue tv = new TypedValue(1040, offset);

            Dict.addXRec(idDictB, "Offset", new ResultBuffer(tv));

            tv = new TypedValue(1040, deltaZ);
            Dict.addXRec(idDictB, "DeltaZ", new ResultBuffer(tv));

            tv = new TypedValue(1005, idPoly3dRF.getHandle().ToString());
            Dict.addXRec(idDictB, "HandleFL", new ResultBuffer(tv));

            tv = new TypedValue(1040, System.Math.Round(beg, 3));
            Dict.addXRec(idDictB, "Beg", new ResultBuffer(tv));

            tv = new TypedValue(1040, System.Math.Round(end, 3));
            Dict.addXRec(idDictB, "End", new ResultBuffer(tv));


            ObjectId idDictPntEND = Dict.getSubEntry(idDictM, handles[1].ToString());       //Cogo Point stores edge parameters in dictionary

            if (idDictPntEND == ObjectId.Null)
            {
                idDictPntEND = Dict.addSubDict(idDictM, handles[1].ToString());
            }

            ObjectId idDictE = Dict.getSubEntry(idDictPntEND, idPoly3dTAR.getHandle().ToString());

            if (idDictE == ObjectId.Null)
            {
                idDictE = Dict.addSubDict(idDictPntEND, idPoly3dTAR.getHandle().ToString());
            }
            else
            {
                Dict.removeSubEntry(idDictPntEND, idPoly3dTAR.getHandle().ToString());
                idDictE = Dict.addSubDict(idDictPntEND, idPoly3dTAR.getHandle().ToString());
            }

            tv = new TypedValue(1040, offset);
            Dict.addXRec(idDictE, "Offset", new ResultBuffer(tv));

            tv = new TypedValue(1040, deltaZ);
            Dict.addXRec(idDictE, "DeltaZ", new ResultBuffer(tv));

            tv = new TypedValue(1005, idPoly3dRF.getHandle().ToString());
            Dict.addXRec(idDictE, "HandleFL", new ResultBuffer(tv));

            tv = new TypedValue(1040, System.Math.Round(beg, 3));
            Dict.addXRec(idDictE, "Beg", new ResultBuffer(tv));

            tv = new TypedValue(1040, System.Math.Round(end, 3));
            Dict.addXRec(idDictE, "End", new ResultBuffer(tv));
        }
예제 #18
0
        update3dPoly_lnkBrks1_2(string nameApp, ObjectId idCogoPnt, Handle hEnt3d)
        {
            ObjectId idEnt3d = ObjectId.Null;
            Entity   ent3d   = hEnt3d.getEnt();

            if (ent3d == null)
            {
                return(idEnt3d);
            }

            if (ent3d is Polyline3d)
            {
                Polyline3d poly3d   = (Polyline3d)ent3d;
                ObjectId   idPoly3d = poly3d.ObjectId;
                idEnt3d = idPoly3d;
                Point3d pnt3dBeg = idPoly3d.getBegPnt();
                Point3d pnt3dEnd = idPoly3d.getEndPnt();
                bool    closed   = false;
                if (pnt3dBeg.isEqual(pnt3dEnd, 0.01))
                {
                    closed = true;
                }

                ResultBuffer rb = idEnt3d.getXData(nameApp);
                if (rb == null)
                {
                    return(idEnt3d);
                }
                List <Handle> handles = rb.rb_handles();
                int           n       = 0;
                for (int i = 0; i < handles.Count; i++)
                {
                    Point3d pnt3d = handles[i].getCogoPntCoordinates();
                    idPoly3d.updateVertex(i, pnt3d);
                    n = i;
                }
                if (closed)
                {
                    idPoly3d.updateVertex(n + 1, handles[0].getCogoPntCoordinates());
                }
            }
            if (ent3d is FeatureLine)
            {
                try
                {
                    DBObject            dbObj = ent3d;
                    AeccLandFeatureLine fLine = (AeccLandFeatureLine)dbObj.AcadObject;
                    idEnt3d = ent3d.ObjectId;

                    var    points  = fLine.GetPoints(AeccLandFeatureLinePointType.aeccLandFeatureLinePointPI);
                    object varType = null;
                    object varVal  = null;

                    fLine.GetXData(apps.lnkBrks, out varType, out varVal);
                    fLine = null;
                    List <Handle> handles = Base_VB.myUtility.comXDataToList(varVal);

                    using (Transaction tr = BaseObjs.startTransactionDb())
                    {
                        AeccLandFeatureLine oFL = (AeccLandFeatureLine)dbObj.AcadObject;
                        for (int i = 0; i < handles.Count; i++)
                        {
                            Point3d  pnt3d    = handles[i].getCogoPntCoordinates();
                            double[] varPoint = new double[3];
                            varPoint[0] = pnt3d.X;
                            varPoint[1] = pnt3d.Y;
                            varPoint[2] = pnt3d.Z;

                            oFL.SetPointElevation((object)varPoint);
                        }

                        tr.Commit();
                    }
                }
                catch (System.Exception ex)
                {
                    BaseObjs.writeDebug(ex.Message + " Grading_Utility.cs: line: 193");
                }
            }

            return(idEnt3d);
        }