コード例 #1
0
        resetDockLimits()
        {
            bool exists = false;

            try
            {
                using (BaseObjs._acadDoc.LockDocument())
                {
                    try
                    {
                        ObjectId idDictGRADEDOCK = Dict.getNamedDictionary("GRADEDOCK", out exists);
                        Dict.removeSubEntry(idDictGRADEDOCK, "DOCKS");
                    }
                    catch (System.Exception ex)
                    {
                        BaseObjs.writeDebug(ex.Message + " Grading_Dock.cs: line: 346");
                    }
                }
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " Grading_Dock.cs: line: 352");
            }
        }
コード例 #2
0
        addXData(ObjectId idSM, int scale, ObjectId idTX, ObjectIdCollection idsLDR, ObjectId idWO, int numSides, Handle hTarget, string layerTarget)
        {
            //link symbol to text
            TypedValue[] tvs = new TypedValue[4];
            tvs.SetValue(new TypedValue(1001, apps.lnkBubs), 0);
            tvs.SetValue(new TypedValue(1000, "TX"), 1);
            tvs.SetValue(new TypedValue(1005, idSM.getHandle()), 2);
            tvs.SetValue(new TypedValue(1070, scale), 3);
            idTX.setXData(tvs, apps.lnkBubs);

            //link wipeout, text, construction note, type of symbol, and leaders to symbol
            tvs = new TypedValue[idsLDR.Count + 6];
            tvs.SetValue(new TypedValue(1001, apps.lnkBubs), 0);
            tvs.SetValue(new TypedValue(1000, "SM"), 1);
            tvs.SetValue(new TypedValue(1005, idWO.getHandle()), 2);
            tvs.SetValue(new TypedValue(1005, idTX.getHandle()), 3);
            tvs.SetValue(new TypedValue(1005, "0000".stringToHandle()), 4); //reserved for construction note
            tvs.SetValue(new TypedValue(1070, numSides), 5);                //type of callout symbol

            for (int i = 0; i < idsLDR.Count; i++)
            {
                tvs.SetValue(new TypedValue(1005, idsLDR[i].getHandle()), i + 6);
            }

            idSM.setXData(tvs, apps.lnkBubs);

            //link symbol, text, and target to leader
            tvs = new TypedValue[5];
            tvs.SetValue(new TypedValue(1001, apps.lnkBubs), 0);
            tvs.SetValue(new TypedValue(1000, "LDR"), 1);
            tvs.SetValue(new TypedValue(1005, idTX.getHandle()), 2);
            tvs.SetValue(new TypedValue(1005, hTarget), 3);
            tvs.SetValue(new TypedValue(1000, layerTarget), 4);

            for (int i = 0; i < idsLDR.Count; i++)
            {
                idsLDR[i].setXData(tvs, apps.lnkBubs);
            }

            string h = idTX.getHandle().ToString();

            //add new callout text handle to "lnkBubs" dictionary
            bool     exists     = false;
            ObjectId idDictBubs = Dict.getNamedDictionary(apps.lnkBubs, out exists);

            try
            {
                using (Transaction tr = BaseObjs.startTransactionDb())
                {
                    DBDictionary dictBubs = (DBDictionary)tr.GetObject(idDictBubs, OpenMode.ForWrite);
                    DBDictionary dictH    = new DBDictionary();
                    dictBubs.SetAt(h, dictH);
                    tr.AddNewlyCreatedDBObject(dictH, true);
                    tr.Commit();
                }
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " Draw2.cs: line: 160");
            }
            //idTX.activateObj();
        }
コード例 #3
0
        updateDictGRADEDOCK(Handle HANDLE3D, double dblSlope, Point3d pnt3dBase0, Point3d pnt3dBase1)
        {
            ResultBuffer rb = null;

            TypedValue[] tvs;
            int          numBldgs    = 0;
            int          numBldgCurr = 0;

            using (BaseObjs._acadDoc.LockDocument())
            {
                try
                {
                    using (Transaction tr = BaseObjs.startTransactionDb())
                    {
                        bool exists = false;
                        Dict.removeNamedDictionary("GRADEDOCK");
                        ObjectId idDictGRADEDOCK = Dict.getNamedDictionary("GRADEDOCK", out exists);
                        if (exists)
                        {
                            rb       = Dict.getXRec(idDictGRADEDOCK, "BLDGCOUNT");
                            tvs      = rb.AsArray();
                            numBldgs = int.Parse(tvs[0].Value.ToString());
                            rb       = new ResultBuffer();
                            rb.Add(new TypedValue(1070, numBldgs + 1));
                            Dict.addXRec(idDictGRADEDOCK, "BLDGCOUNT", rb);
                        }
                        else
                        {
                            rb = new ResultBuffer();
                            rb.Add(new TypedValue(1070, 1));
                            Dict.addXRec(idDictGRADEDOCK, "BLDGCOUNT", rb);
                        }

                        numBldgCurr = numBldgs + 1;
                        ObjectId idDictBLDG = Dict.addSubDict(idDictGRADEDOCK, numBldgCurr.ToString(CultureInfo.InvariantCulture));

                        rb = new ResultBuffer();
                        rb.Add(new TypedValue((int)DxfCode.Handle, HANDLE3D));
                        Dict.addXRec(idDictBLDG, "HANDLE3D", rb);

                        rb = new ResultBuffer();
                        rb.Add(new TypedValue((int)DxfCode.Real, dblSlope));
                        Dict.addXRec(idDictBLDG, "SLOPE", rb);

                        rb = new ResultBuffer();
                        rb.Add(new TypedValue((int)DxfCode.Real, pnt3dBase0.X));
                        rb.Add(new TypedValue((int)DxfCode.Real, pnt3dBase0.Y));
                        rb.Add(new TypedValue((int)DxfCode.Real, pnt3dBase0.Z));
                        Dict.addXRec(idDictBLDG, "CENtrOID", rb);

                        rb = new ResultBuffer();
                        rb.Add(new TypedValue((int)DxfCode.Real, pnt3dBase1.X));
                        rb.Add(new TypedValue((int)DxfCode.Real, pnt3dBase1.Y));
                        rb.Add(new TypedValue((int)DxfCode.Real, pnt3dBase1.Z));
                        Dict.addXRec(idDictBLDG, "TARGET", rb);

                        tr.Commit();
                    }
                }
                catch (System.Exception ex)
                {
                    BaseObjs.writeDebug(ex.Message + " Grading_Floor.cs: line: 243");
                }
            }
            return(numBldgCurr);
        }
コード例 #4
0
        getDockLimits(int intNumDocks)
        {
            bool     exists          = false;
            ObjectId idDictGRADEDOCK = Dict.getNamedDictionary("GRADEDOCK", out exists);
            ObjectId idDictX         = default(ObjectId);

            if ((idDictGRADEDOCK == ObjectId.Null))
            {
                Autodesk.AutoCAD.ApplicationServices.Core.Application.ShowAlertDialog("GRADEDOCK dictionary missing - run AVG");
            }
            Point3d pnt3dPick;

            Entity ent = Select.selectEntity(typeof(Polyline3d), "\nSelect Finish Floor 3d Polyline: ",
                                             "3d Polyline selection failed.  Exiting...", out pnt3dPick);

            Polyline3d poly3d = (Polyline3d)ent;

            ResultBuffer rb = poly3d.ObjectId.getXData("AVG");

            if (rb == null)
            {
                return;
            }
            TypedValue[] tvs = rb.AsArray();

            bldgNum = tvs[2].Value.ToString();

            ObjectId idDictBLDG = Dict.getSubDict(idDictGRADEDOCK, bldgNum);

            ObjectId idDictDOCKS = Dict.getSubEntry(idDictBLDG, "DOCKS");

            if (idDictDOCKS == ObjectId.Null)
            {
                idDictDOCKS = Dict.addSubDict(idDictBLDG, "DOCKS");
            }

            using (BaseObjs._acadDoc.LockDocument())
            {
                Object selectCycling = Application.GetSystemVariable("SELECTIONCYCLING");
                Application.SetSystemVariable("SELECTIONCYCLING", 0);
                PromptStatus ps;
                try
                {
                    for (int i = 1; i < intNumDocks + 1; i++)
                    {
                        idDictX = Dict.addSubDict(idDictDOCKS, i.ToString(CultureInfo.InvariantCulture));

                        bool    escape   = false;
                        Point3d pnt3dRet = UserInput.getPoint(string.Format("\nSelect Dock {0} : Begin point (CCW orientation)", i), Pub.pnt3dO, out escape, out ps, osMode: 0);
                        BaseObjs.write("\n");

                        TypedValue[] TVs = new TypedValue[] {
                            new TypedValue(1040, pnt3dRet.X),
                            new TypedValue(1040, pnt3dRet.Y),
                            new TypedValue(1040, pnt3dRet.Z)
                        };

                        Dict.addXRec(idDictX, "BEG", TVs);

                        pnt3dRet = UserInput.getPoint(string.Format("\nSelect Dock {0} : End point (CCW orientation)", i), pnt3dRet, out escape, out ps, osMode: 0);
                        BaseObjs.write("\n");

                        TVs = new TypedValue[] {
                            new TypedValue(1040, pnt3dRet.X),
                            new TypedValue(1040, pnt3dRet.Y),
                            new TypedValue(1040, pnt3dRet.Z)
                        };

                        Dict.addXRec(idDictX, "END", TVs);
                    }
                }
                catch (System.Exception ex)
                {
                    BaseObjs.writeDebug(ex.Message + " Grading_Dock.cs: line: 85");
                }
                finally
                {
                    Application.SetSystemVariable("SELECTIONCYCLING", selectCycling);
                }
            }
        }
コード例 #5
0
        gradeDock(double dblWidth, double dblWallThickness)
        {
            const string nameLayer = "CPNT-BRKLINE";

            double dblAng = 0;
            double dblLEN = 0;

            Point3d pnt3dA = default(Point3d);          //point AHEAD
            Point3d pnt3dB;                             //point BACK

            int intSlopeSign = 0;

            const double pi = System.Math.PI;

            bool     exists          = false;
            ObjectId idDictGRADEDOCK = Dict.getNamedDictionary("GRADEDOCK", out exists);
            ObjectId idDictDOCKS     = default(ObjectId);

            if ((idDictGRADEDOCK == ObjectId.Null))
            {
                Autodesk.AutoCAD.ApplicationServices.Core.Application.ShowAlertDialog("Dock limits not yet defined  - exiting .....");
            }

            ObjectId idDictBLDG = Dict.getSubDict(idDictGRADEDOCK, bldgNum);

            TypedValue[] TVs = new TypedValue[3];
            using (BaseObjs._acadDoc.LockDocument())
            {
                try
                {
                    using (Transaction tr = BaseObjs.startTransactionDb())
                    {
                        ResultBuffer RB = Dict.getXRec(idDictBLDG, "HANDLE3D");
                        TVs = RB.AsArray();

                        RB  = Dict.getXRec(idDictBLDG, "SLOPE");
                        TVs = RB.AsArray();
                        double dblSlope = (double)TVs[0].Value;

                        RB  = Dict.getXRec(idDictBLDG, "CENtrOID");
                        TVs = RB.AsArray();
                        Point3d pnt3dCEN = new Point3d((double)TVs[0].Value, (double)TVs[1].Value, (double)TVs[2].Value);

                        RB  = Dict.getXRec(idDictBLDG, "TARGET");
                        TVs = RB.AsArray();
                        Point3d pnt3dTAR = new Point3d((double)TVs[0].Value, (double)TVs[1].Value, (double)TVs[2].Value);

                        double dblAngBase = Measure.getAzRadians(pnt3dCEN, pnt3dTAR);

                        idDictDOCKS = Dict.getSubEntry(idDictBLDG, "DOCKS");

                        if ((idDictDOCKS == ObjectId.Null))
                        {
                            Autodesk.AutoCAD.ApplicationServices.Core.Application.ShowAlertDialog("Dock limits not yet defined  - exiting .....");
                            return;
                        }

                        DBDictionary objDictDOCKS = (DBDictionary)tr.GetObject(idDictDOCKS, OpenMode.ForRead);

                        for (int i = 1; i < objDictDOCKS.Count + 1; i++)
                        {
                            ObjectId           idDictX    = Dict.getSubEntry(idDictDOCKS, i.ToString());
                            ObjectIdCollection idsPoly3dX = new ObjectIdCollection();
                            Point3dCollection  pnts3d     = new Point3dCollection();

                            try
                            {
                                RB  = Dict.getXRec(idDictX, "BEG");
                                TVs = RB.AsArray();

                                Point3d pnt3dBEG = new Point3d((double)TVs[0].Value, (double)TVs[1].Value, (double)TVs[2].Value);

                                RB  = Dict.getXRec(idDictX, "END");
                                TVs = RB.AsArray();
                                Point3d pnt3dEND = new Point3d((double)TVs[0].Value, (double)TVs[1].Value, (double)TVs[2].Value);

                                dblAng = Measure.getAzRadians(pnt3dBEG, pnt3dEND);
                                dblLEN = pnt3dBEG.getDistance(pnt3dEND) - (2 * dblWallThickness / 12.0);
                                pnt3dB = pnt3dBEG;

                                pnt3dA = Geom.traverse_pnt3d(pnt3dBEG, dblAng - pi / 2, dblWallThickness / 12.0);
                                pnt3dA = Geom.traverse_pnt3d(pnt3dA, dblAng, dblWallThickness / 12.0);
                                if (pnt3dTAR != Pub.pnt3dO)
                                {
                                    pnt3dA = new Point3d(pnt3dA.X, pnt3dA.Y, pnt3dTAR.Z + Geom.getCosineComponent(pnt3dCEN, pnt3dTAR, pnt3dA) * (dblSlope * -1) - 4.04);
                                }
                                else
                                {
                                    pnt3dA = new Point3d(pnt3dA.X, pnt3dA.Y, pnt3dCEN.Z - 4.04);
                                }

                                pnts3d.Add(pnt3dA);           //CgPnt 1
                            }
                            catch (System.Exception ex)
                            {
                                BaseObjs.writeDebug(ex.Message + " Grading_Dock.cs: line: 186");
                            }

                            ObjectId idPoly3d = ObjectId.Null;

                            if (dblSlope != 0)
                            {
                                if (System.Math.Round(dblAng, 2) == System.Math.Round(dblAngBase, 2))
                                {
                                    intSlopeSign = 1;
                                }
                                if (System.Math.Round(dblAng, 2) == System.Math.Round(dblAngBase - pi, 2))
                                {
                                    intSlopeSign = -1;
                                }
                                if (System.Math.Round(dblAng, 2) == System.Math.Round(dblAngBase + pi, 2))
                                {
                                    intSlopeSign = -1;
                                }
                                if (System.Math.Round(dblAng, 2) == System.Math.Round(dblAngBase - 2 * pi, 2))
                                {
                                    intSlopeSign = 1;
                                }

                                dblAng = dblAng - pi / 2;
                                pnt3dB = pnt3dA;
                                pnt3dA = Geom.traverse_pnt3d(pnt3dB, dblAng, dblWidth);
                                pnt3dA = new Point3d(pnt3dA.X, pnt3dA.Y, pnt3dB.Z + dblWidth * -0.01);

                                pnts3d.Add(pnt3dA);           //CgPnt 2

                                dblAng = dblAng + pi / 2;
                                pnt3dB = pnt3dA;
                                pnt3dA = Geom.traverse_pnt3d(pnt3dB, dblAng, dblLEN);
                                pnt3dA = new Point3d(pnt3dA.X, pnt3dA.Y, pnt3dB.Z + dblLEN * dblSlope * intSlopeSign * 1);

                                pnts3d.Add(pnt3dA);           //Pnt3

                                dblAng = dblAng + pi / 2;
                                pnt3dB = pnt3dA;
                                pnt3dA = Geom.traverse_pnt3d(pnt3dB, dblAng, dblWidth);
                                pnt3dA = new Point3d(pnt3dA.X, pnt3dA.Y, pnt3dB.Z + dblWidth * 0.01);

                                pnts3d.Add(pnt3dA);           //CgPnt 4

                                dblAng = dblAng + pi / 2;
                                pnt3dB = pnt3dA;
                                pnt3dA = Geom.traverse_pnt3d(pnt3dB, dblAng, dblLEN);
                                pnt3dA = new Point3d(pnt3dA.X, pnt3dA.Y, pnt3dB.Z + dblLEN * dblSlope * intSlopeSign * -1);

                                pnts3d.Add(pnt3dA);           //Pnt5

                                idPoly3d = Draw.addPoly3d(pnts3d, nameLayer);
                                idsPoly3dX.Add(idPoly3d);
                            }
                            else
                            {
                                dblAng = dblAng - pi / 2;
                                pnt3dB = pnt3dA;
                                pnt3dA = Geom.traverse_pnt3d(pnt3dB, dblAng, dblWidth);
                                pnt3dA = new Point3d(pnt3dA.X, pnt3dA.Y, pnt3dB.Z + dblWidth * -0.005);

                                pnts3d.Add(pnt3dA);

                                int intDivide = (int)System.Math.Truncate(dblLEN / 84) + 1;

                                if (intDivide % 2 != 0)
                                {
                                    intDivide = intDivide + 1;
                                }

                                int x = 0;
                                for (x = 0; x <= intDivide - 1; x++)
                                {
                                    int intMultiplier = 0;
                                    switch (x % 2)
                                    {
                                    case 0:
                                        intMultiplier = -1;
                                        break;

                                    default:
                                        intMultiplier = 1;
                                        break;
                                    }

                                    if (x == 0)
                                    {
                                        dblAng = dblAng + pi / 2;
                                    }

                                    pnt3dB = pnt3dA;
                                    pnt3dA = Geom.traverse_pnt3d(pnt3dB, dblAng, dblLEN / intDivide);
                                    pnt3dA = new Point3d(pnt3dA.X, pnt3dA.Y, pnt3dB.Z + dblLEN / intDivide * 0.005 * intMultiplier);

                                    pnts3d.Add(pnt3dA);
                                }

                                dblAng = dblAng + pi / 2;
                                pnt3dB = pnt3dA;
                                pnt3dA = Geom.traverse_pnt3d(pnt3dB, dblAng, dblWidth);
                                pnt3dA = new Point3d(pnt3dA.X, pnt3dA.Y, pnt3dB.Z + dblWidth * 0.005);

                                pnts3d.Add(pnt3dA);

                                for (x = 0; x <= intDivide - 1; x++)
                                {
                                    if (x == 0)
                                    {
                                        dblAng = dblAng + pi / 2;
                                    }

                                    pnt3dB = pnt3dA;
                                    pnt3dA = Geom.traverse_pnt3d(pnt3dB, dblAng, dblLEN / intDivide);
                                    pnt3dA = new Point3d(pnt3dA.X, pnt3dA.Y, pnt3dB.Z);

                                    pnts3d.Add(pnt3dA);
                                }

                                idPoly3d = Draw.addPoly3d(pnts3d, nameLayer);
                                idsPoly3dX.Add(idPoly3d);

                                Point3dCollection pnts3dX = new Point3dCollection();

                                pnts3dX.Add(pnts3d[0]);

                                int intUBnd = pnts3d.Count - 1;
                                x = -1;
                                int n = 1;

                                for (int j = 1; j <= intUBnd / 2 - 1; j++)
                                {
                                    x = x * -1;
                                    n = n + (intUBnd - 2 * j) * x;

                                    pnts3dX.Add(pnts3d[n]);
                                }

                                idPoly3d = Draw.addPoly3d(pnts3d, nameLayer);
                                idsPoly3dX.Add(idPoly3d);
                            }
                            Grading_Floor.modSurface("CPNT-ON", "Finish Surface", idsPoly3dX, false);
                        }
                        tr.Commit();
                    }
                }
                catch (System.Exception ex)
                {
                    BaseObjs.writeDebug(ex.Message + " Grading_Dock.cs: line: 326");
                }
            }
        }
コード例 #6
0
        addXDataLnks(string nameApp, string nameCmd, ObjectId idLDR, ObjectId idTxTop, ObjectId idTxBot, ObjectId idTxBot2, Point3d pnt3dTop, double scale,
                     double deltaZ, List <Point3d> pnts3dLdr, List <ObjectId> idsCgPnts, double station, double offset, List <Point3d> pnts3dX = null)
        {
            ResultBuffer rb     = null;
            Point3d      pnt3d  = Pub.pnt3dO;
            bool         exists = false;
            ObjectId     idDict = Dict.getNamedDictionary("checkCOs", out exists);

            #region MText

            //MText
            if (nameApp != apps.lnkGS)
            {
                TypedValue[] tvsTxTop = new TypedValue[11];
                tvsTxTop.SetValue(new TypedValue(1001, nameApp), 0);
                tvsTxTop.SetValue(new TypedValue(1000, nameCmd), 1);
                tvsTxTop.SetValue(new TypedValue(1000, "TX"), 2);
                if (nameCmd == "cmdFFD")
                {
                    tvsTxTop.SetValue(new TypedValue(1005, "0".stringToHandle()), 3);
                }
                else
                {
                    tvsTxTop.SetValue(new TypedValue(1005, idLDR.getHandle()), 3);
                }

                if (idTxBot.IsValid)
                {
                    tvsTxTop.SetValue(new TypedValue(1005, idTxBot.getHandle()), 4);
                }
                else
                {
                    tvsTxTop.SetValue(new TypedValue(1005, "0".stringToHandle()), 4);
                }

                if (idTxBot2.IsValid)
                {
                    tvsTxTop.SetValue(new TypedValue(1005, idTxBot2.getHandle()), 5);
                }
                else
                {
                    tvsTxTop.SetValue(new TypedValue(1005, "0".stringToHandle()), 5);
                }

                tvsTxTop.SetValue(new TypedValue(1070, scale), 6);
                tvsTxTop.SetValue(new TypedValue(1040, pnt3dTop.X), 7);
                tvsTxTop.SetValue(new TypedValue(1040, pnt3dTop.Y), 8);
                tvsTxTop.SetValue(new TypedValue(1040, deltaZ), 9);                 //thickness of floor slab, etc.

                if (idsCgPnts != null && idsCgPnts.Count > 0)
                {
                    tvsTxTop.SetValue(new TypedValue(1005, idsCgPnts[0].getHandle()), 10);
                }
                else
                {
                    tvsTxTop.SetValue(new TypedValue(1005, "0".stringToHandle()), 10);
                }

                idTxTop.setXData(tvsTxTop, nameApp);
            }
            else if (nameApp == apps.lnkGS)
            {
                TypedValue[] tvsTxTop = new TypedValue[12];
                tvsTxTop.SetValue(new TypedValue(1001, nameApp), 0);
                tvsTxTop.SetValue(new TypedValue(1000, nameCmd), 1);
                tvsTxTop.SetValue(new TypedValue(1000, "TX"), 2);
                tvsTxTop.SetValue(new TypedValue(1005, idLDR.getHandle()), 3);
                tvsTxTop.SetValue(new TypedValue(1070, scale), 4);
                tvsTxTop.SetValue(new TypedValue(1040, station), 5);
                tvsTxTop.SetValue(new TypedValue(1040, offset), 6);
                tvsTxTop.SetValue(new TypedValue(1040, pnt3dTop.X), 7);
                tvsTxTop.SetValue(new TypedValue(1040, pnt3dTop.Y), 8);
                if (idsCgPnts[0].IsValid)
                {
                    tvsTxTop.SetValue(new TypedValue(1005, idsCgPnts[0].getHandle()), 9);       //to allow picking any object i.e. endpoint, nearest
                }
                else
                {
                    tvsTxTop.SetValue(new TypedValue(1005, "0".stringToHandle()), 9);
                    pnt3d = pnts3dX[0];
                }
                if (idsCgPnts[1].IsValid)
                {
                    tvsTxTop.SetValue(new TypedValue(1005, idsCgPnts[1].getHandle()), 10);
                }
                else
                {
                    tvsTxTop.SetValue(new TypedValue(1005, "0".stringToHandle()), 10);
                    pnt3d = pnts3dX[1];
                }

                string xyz = string.Format("{0} {1} {2}", pnt3d.X, pnt3d.Y, pnt3d.Z);
                tvsTxTop.SetValue(new TypedValue(1000, xyz), 11);

                idTxTop.setXData(tvsTxTop, nameApp);
            }

            #endregion MText

            #region Leader

            //Leader
            TypedValue[] tvsLdr = null;
            if (nameCmd != "cmdFFD")
            { //cmdFFD does not have a leader
                if (nameApp == apps.lnkCO || nameApp == apps.lnkDP || nameApp == apps.lnkLD)
                {
                    tvsLdr = new TypedValue[6 + pnts3dLdr.Count * 2];

                    tvsLdr.SetValue(new TypedValue(1001, nameApp), 0);
                    tvsLdr.SetValue(new TypedValue(1000, nameCmd), 1);
                    tvsLdr.SetValue(new TypedValue(1000, "LDR"), 2);
                    tvsLdr.SetValue(new TypedValue(1005, idTxTop.getHandle()), 3);

                    if (idTxBot.IsValid)
                    {
                        tvsLdr.SetValue(new TypedValue(1005, idTxBot.getHandle()), 4);
                    }
                    else
                    {
                        tvsLdr.SetValue(new TypedValue(1005, "0".stringToHandle()), 4);
                    }

                    if (idTxBot2.IsValid)
                    {
                        tvsLdr.SetValue(new TypedValue(1005, idTxBot2.getHandle()), 5);
                    }
                    else
                    {
                        tvsLdr.SetValue(new TypedValue(1005, "0".stringToHandle()), 5);
                    }

                    for (int i = 0; i < pnts3dLdr.Count; i++)
                    {
                        tvsLdr.SetValue(new TypedValue(1040, pnts3dLdr[i].X), i * 2 + 6);
                        tvsLdr.SetValue(new TypedValue(1040, pnts3dLdr[i].Y), i * 2 + 7);
                    }
                    idLDR.setXData(tvsLdr, nameApp);
                }
                else if (nameApp == apps.lnkGS)
                {
                    tvsLdr = new TypedValue[11];
                    tvsLdr.SetValue(new TypedValue(1001, nameApp), 0);
                    tvsLdr.SetValue(new TypedValue(1000, nameCmd), 1);
                    tvsLdr.SetValue(new TypedValue(1000, "LDR"), 2);
                    tvsLdr.SetValue(new TypedValue(1005, idTxTop.getHandle()), 3);
                    tvsLdr.SetValue(new TypedValue(1040, pnts3dLdr[0].X), 4);
                    tvsLdr.SetValue(new TypedValue(1040, pnts3dLdr[0].Y), 5);
                    tvsLdr.SetValue(new TypedValue(1040, pnts3dLdr[1].X), 6);
                    tvsLdr.SetValue(new TypedValue(1040, pnts3dLdr[1].Y), 7);
                    tvsLdr.SetValue(new TypedValue(1040, pnts3dLdr[2].X), 8);      //case cmdsGS -> pnt3dM
                    tvsLdr.SetValue(new TypedValue(1040, pnts3dLdr[2].Y), 9);
                    tvsLdr.SetValue(new TypedValue(1040, pnts3dLdr[0].getDirection(pnts3dLdr[1])), 10);

                    idLDR.setXData(tvsLdr, nameApp);
                }
            }

            #endregion Leader

            #region CogoPoint

            //CogoPoint
            if (idsCgPnts != null && idsCgPnts.Count > 0)
            {
                ResultBuffer rbPNT   = null;
                TypedValue[] tvsPNT  = null;
                TypedValue[] tvsTemp = null;
                switch (nameApp)
                {
                case apps.lnkCO:
                    rbPNT = idsCgPnts[0].getXData(nameApp);
                    if (rbPNT != null)
                    {
                        int k = 0;
                        tvsTemp = rbPNT.AsArray();
                        for (int i = 1; i < tvsTemp.Length; i++)
                        {
                            if (nameCmd == tvsTemp[i].Value.ToString())
                            {     //delete existing callout
                                ObjectId     idTx = tvsTemp[i + 2].getObjectId();
                                ResultBuffer rbTx = idTx.getXData(nameApp);
                                if (rb == null)
                                {
                                    return;
                                }
                                TypedValue[] tvsTx = rbTx.AsArray();
                                ObjectId     idLdr = tvsTx.getObjectId(3);
                                idTxBot  = tvsTx.getObjectId(4);
                                idTxBot2 = tvsTx.getObjectId(5);
                                idTx.delete();
                                idLdr.delete();
                                idTxBot.delete();
                                idTxBot2.delete();
                                k = i;
                                break;
                            }
                        }
                        if (k != 0)
                        {     //k != 0 -> existing callout deleted
                            tvsPNT = new TypedValue[tvsTemp.Length];
                            tvsTemp.CopyTo(tvsPNT, 0);
                            tvsPNT.SetValue(new TypedValue(1005, idTxTop.getHandle()), k + 2);          //replace old handle with new one
                        }
                        else
                        {
                            tvsPNT = new TypedValue[tvsTemp.Length + 3];
                            tvsTemp.CopyTo(tvsPNT, 0);
                            tvsPNT.SetValue(new TypedValue(1000, nameCmd), tvsPNT.Length - 3);
                            tvsPNT.SetValue(new TypedValue(1000, "CogoPoint"), tvsPNT.Length - 2);
                            tvsPNT.SetValue(new TypedValue(1005, idTxTop.getHandle()), tvsPNT.Length - 1);
                        }
                    }
                    else
                    {
                        tvsPNT = new TypedValue[4];
                        tvsPNT.SetValue(new TypedValue(1001, nameApp), 0);
                        tvsPNT.SetValue(new TypedValue(1000, nameCmd), 1);
                        tvsPNT.SetValue(new TypedValue(1000, "CogoPoint"), 2);
                        tvsPNT.SetValue(new TypedValue(1005, idTxTop.getHandle()), 3);
                    }

                    idsCgPnts[0].setXData(tvsPNT, nameApp);
                    break;

                case apps.lnkDP:
                    // if xdata already exists delete callout and replace
                    tvsPNT = new TypedValue[6];
                    tvsPNT.SetValue(new TypedValue(1001, nameApp), 0);
                    tvsPNT.SetValue(new TypedValue(1000, nameCmd), 1);
                    tvsPNT.SetValue(new TypedValue(1000, "Primary"), 2);
                    tvsPNT.SetValue(new TypedValue(1005, idTxTop.getHandle()), 3);
                    tvsPNT.SetValue(new TypedValue(1005, idLDR.getHandle()), 4);
                    tvsPNT.SetValue(new TypedValue(1005, idsCgPnts[1].getHandle()), 5);

                    idsCgPnts[0].setXData(tvsPNT, nameApp);

                    tvsPNT = new TypedValue[4];
                    tvsPNT.SetValue(new TypedValue(1001, nameApp), 0);
                    tvsPNT.SetValue(new TypedValue(1000, nameCmd), 1);
                    tvsPNT.SetValue(new TypedValue(1000, "Secondary"), 2);
                    tvsPNT.SetValue(new TypedValue(1005, idsCgPnts[0].getHandle()), 3);

                    idsCgPnts[1].setXData(tvsPNT, nameApp);
                    break;

                case apps.lnkGS:
                    //get all xdata for each point
                    foreach (ObjectId idCgPnt in idsCgPnts)
                    {
                        if (!idCgPnt.IsValid)
                        {
                            continue;
                        }
                        rbPNT = idCgPnt.getXData(nameApp);
                        if (rbPNT != null)
                        {
                            tvsTemp = rbPNT.AsArray();
                            tvsPNT  = new TypedValue[tvsTemp.Length + 1];
                            tvsTemp.CopyTo(tvsPNT, 0);
                            tvsPNT.SetValue(new TypedValue(1005, idTxTop.getHandle()), tvsTemp.Length);
                        }
                        else
                        {
                            tvsPNT = new TypedValue[3];
                            tvsPNT.SetValue(new TypedValue(1001, nameApp), 0);
                            tvsPNT.SetValue(new TypedValue(1000, nameCmd), 1);
                            tvsPNT.SetValue(new TypedValue(1005, idTxTop.getHandle()), 2);
                        }
                        idCgPnt.setXData(tvsPNT, nameApp);
                    }
                    break;

                case apps.lnkLD:
                    break;
                }
            }

            #endregion CogoPoint
        }