Exemplo n.º 1
0
        editExistCalloutsByDatumAdj(SelectionSet SS, double dblAdj)
        {
            BlockReference BR = null;

            string strElev = string.Empty;
            double dblElev = 0.0;

            try
            {
                using (Transaction tr = BaseObjs.startTransactionDb())
                {
                    ObjectId[] objIDs = SS.GetObjectIds();
                    foreach (ObjectId objID in objIDs)
                    {
                        BR = (BlockReference)tr.GetObject(objID, OpenMode.ForWrite);

                        if (BR != null)
                        {
                            AttributeCollection AC = BR.AttributeCollection;
                            foreach (ObjectId arID in AC)
                            {
                                AttributeReference AR        = (AttributeReference)tr.GetObject(arID, OpenMode.ForWrite);
                                string             strAttVal = AR.TextString.ToString();
                                if (strAttVal != string.Empty)
                                {
                                    if (strAttVal.StartsWith("("))
                                    {
                                        if (strAttVal.Contains(" ") == true)
                                        {
                                            string[] strFields = Txt.splitFields(strAttVal, ' ');
                                            if (strFields[0] != string.Empty)
                                            {
                                                string strVal = strFields[0];

                                                strElev = strVal.Substring(1, strVal.Length - 1);

                                                Boolean boolDbl = double.TryParse(strElev, out dblElev);
                                                if (boolDbl == true)
                                                {
                                                    dblElev       = dblElev + dblAdj;
                                                    strElev       = dblElev.ToString();
                                                    strAttVal     = string.Format("({0} {1}", strElev, strFields[1]);
                                                    AR.TextString = strAttVal;
                                                    BR.Color      = Autodesk.AutoCAD.Colors.Color.FromRgb(255, 200, 200);
                                                }
                                            }
                                        }
                                        else
                                        {
                                            strElev = strAttVal.Substring(1, strAttVal.Length - 2);
                                            Boolean boolDbl = double.TryParse(strElev, out dblElev);
                                            if (boolDbl == true)
                                            {
                                                dblElev       = dblElev + dblAdj;
                                                strElev       = dblElev.ToString();
                                                strAttVal     = string.Format("({0})", strElev);
                                                AR.TextString = strAttVal;
                                                BR.Color      = Autodesk.AutoCAD.Colors.Color.FromRgb(255, 200, 200);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }

                    tr.Commit();
                }                //end using tr
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " Mod.cs: line: 337");
            }
        }
Exemplo n.º 2
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
Exemplo n.º 3
0
        updateExistCallouts(SelectionSet SS)
        {
            ResultBuffer RB = null;

            BlockReference BR      = null;
            CogoPoint      cogoPnt = null;

            string strAppName = string.Empty;
            string strElev    = string.Empty;

            try
            {
                using (Transaction tr = BaseObjs.startTransactionDb())
                {
                    ObjectId[] objIDs = SS.GetObjectIds();
                    foreach (ObjectId objID in objIDs)
                    {
                        cogoPnt = (CogoPoint)tr.GetObject(objID, OpenMode.ForRead);
                        strElev = cogoPnt.Location.Z.ToString("#,###.00");

                        RB = cogoPnt.GetXDataForApplication("lblPnts");
                        if (RB != null)
                        {
                            strAppName = "lblPnts";
                        }
                        else
                        {
                            RB         = cogoPnt.GetXDataForApplication("lblPntsPT");
                            strAppName = "lblPntsPT";
                        }
                        if (RB != null)
                        {
                            try
                            {
                                foreach (TypedValue TV in RB)
                                {
                                    if (TV.TypeCode.ToString() == "1005")
                                    {
                                        try
                                        {
                                            string   strHandle = TV.Value.ToString();
                                            ObjectId brID      = Misc.getObjectIdFromHandle(strHandle);

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

                                            BR = (BlockReference)dbObj;
                                            if (BR != null)
                                            {
                                                AttributeCollection AC = BR.AttributeCollection;
                                                foreach (ObjectId arID in AC)
                                                {
                                                    AttributeReference AR        = (AttributeReference)tr.GetObject(arID, OpenMode.ForWrite);
                                                    string             strAttVal = AR.TextString.ToString();
                                                    if (strAttVal != string.Empty)
                                                    {
                                                        string[] strFields = Txt.splitFields(strAttVal, ' ');
                                                        if (strFields[0] != string.Empty)
                                                        {
                                                            string strVal = strFields[0];
                                                            if (strVal.StartsWith("("))
                                                            {
                                                                string  strChr = strVal[1].ToString();
                                                                int     num;
                                                                Boolean isNum = strChr.isInteger(out num);
                                                                if (isNum == true)
                                                                {
                                                                    strAttVal     = string.Format("({0} {1}", strElev, strFields[1]);
                                                                    AR.TextString = strAttVal;
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        catch (System.Exception ex)
                                        {
                                            BaseObjs.writeDebug(ex.Message + " Mod.cs: line: 1091");
                                        }
                                    }
                                }
                            }
                            catch (System.Exception ex)
                            {
                                BaseObjs.writeDebug(ex.Message + " Mod.cs: line: 1098");
                            }
                        }
                    }

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