Пример #1
0
        updateDesignCallout(CogoPoint cogoPnt, string strApp)
        {
            ResultBuffer RB = null;

            MText mText = null;

            string[] strLines;
            string[] strFieldsTop;
            string[] strFieldsBot;
            string   strCalloutX = "";

            string strElev = cogoPnt.Location.Z.ToString("#,###.00");

            try
            {
                using (Transaction tr = BaseObjs.startTransactionDb())
                {
                    RB = cogoPnt.GetXDataForApplication(strApp);

                    string strCallout0 = "";
                    foreach (TypedValue TV in RB)
                    {
                        if (TV.TypeCode.ToString() == "1005")
                        {
                            string   strHandle = TV.Value.ToString();
                            ObjectId objID     = Misc.getObjectIdFromHandle(strHandle);

                            Autodesk.AutoCAD.DatabaseServices.DBObject dbObj = tr.GetObject(objID, OpenMode.ForRead);

                            mText       = (MText)dbObj;
                            strCallout0 = mText.Contents;
                            if (strApp == "FL")
                            {
                                strLines    = Txt.splitLines(strCallout0);
                                strCalloutX = string.Format("{0}\\P{1}", strElev, strLines[1]);
                            }
                            if (strApp == "FF")
                            {
                                strLines     = Txt.splitLines(strCallout0);
                                strFieldsTop = Txt.splitFields(strLines[0], ' ');
                                strFieldsBot = Txt.splitFields(strLines[1], ' ');
                            }

                            if (strApp == "G")
                            {
                                strLines     = Txt.splitLines(strCallout0);
                                strFieldsTop = Txt.splitFields(strLines[0], ' ');
                                strFieldsBot = Txt.splitFields(strLines[1], ' ');
                            }

                            Events.deactivateMText("*", mText);
                            mText.UpgradeOpen();
                            mText.Contents = strCalloutX;
                            mText.DowngradeOpen();
                            Events.activateMText("*", mText);
                        }
                    }

                    RB = mText.GetXDataForApplication(strApp);
                    foreach (TypedValue TV in RB)
                    {
                        if (TV.TypeCode.ToString() == "1005")
                        {
                            string   strHandle = TV.Value.ToString();
                            ObjectId objID     = Misc.getObjectIdFromHandle(strHandle);

                            Autodesk.AutoCAD.DatabaseServices.DBObject dbObj = tr.GetObject(objID, OpenMode.ForRead);

                            Leader LDR = (Leader)dbObj;
                            Events.deactivateLdr("*", LDR);
                            LDR.UpgradeOpen();
                            LDR.SetVertexAt(0, new Point3d(cogoPnt.Location.X, cogoPnt.Location.Y, 0.0));
                            LDR.DowngradeOpen();
                            Events.activateLdr("*", LDR);
                        }
                    }

                    tr.Commit();
                }                //end using tr
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " Mod.cs: line: 1004");
            }
        }        //end updateDesignCallout