Ejemplo n.º 1
0
        updateDesignCallout(MText mTxt, string strApp)
        {
            ResultBuffer      RB     = null;
            Point3dCollection pnt3ds = new Point3dCollection();
            Leader            Ldr    = null;

            try
            {
                using (Transaction tr = BaseObjs.startTransactionDb())
                {
                    RB = mTxt.GetXDataForApplication(strApp);
                    foreach (TypedValue TV in RB)
                    {
                        if (TV.TypeCode.ToString() == "1005")
                        {
                            string   strHandle = TV.Value.ToString();
                            ObjectId objID     = Misc.getObjectIdFromHandle(strHandle);
                            Ldr = (Leader)tr.GetObject(objID, OpenMode.ForRead);
                            Events.deactivateLdr("*", Ldr);
                            Ldr.UpgradeOpen();

                            double dblWidth = mTxt.ActualWidth;

                            for (int i = 0; i < Ldr.NumVertices; i++)
                            {
                                pnt3ds.Add(Ldr.VertexAt(i));
                            }

                            double  dblAngle     = Base_Tools45.Measure.getAzRadians(pnt3ds[1], pnt3ds[2]);
                            Boolean Left_Justify = Base_Tools45.Math.left_Justify(dblAngle);

                            Point3d pnt3d = Math.traverse(pnt3ds[1], dblAngle, dblWidth / 2 + mTxt.ActualHeight * 0.1);

                            pnt3d = Math.traverse(pnt3ds[1], dblAngle, dblWidth * 1.20);
                        }
                    }

                    tr.Commit();
                }
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " Mod.cs: line: 832");
            }
        }
Ejemplo 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
Ejemplo n.º 3
0
        updateDesignCallout(Leader Ldr, string strApp)
        {
            Editor ED = BaseObjs._editor;

            ResultBuffer      RB     = null;
            Point3dCollection pnt3ds = new Point3dCollection();
            MText             mTxt   = null;

            try
            {
                using (Transaction tr = BaseObjs.startTransactionDb())
                {
                    RB = Ldr.GetXDataForApplication(strApp);
                    foreach (TypedValue TV in RB)
                    {
                        if (TV.TypeCode.ToString() == "1005")
                        {
                            string   strHandle = TV.Value.ToString();
                            ObjectId objID     = Misc.getObjectIdFromHandle(strHandle);
                            mTxt = (MText)tr.GetObject(objID, OpenMode.ForRead);
                            Events.deactivateMText("*", mTxt);
                            mTxt.UpgradeOpen();

                            double dblWidth = mTxt.ActualWidth;

                            for (int i = 0; i < Ldr.NumVertices; i++)
                            {
                                pnt3ds.Add(Ldr.VertexAt(i));
                            }

                            Point3d pnt3d1 = pnt3ds[1];
                            Point3d pnt3d2 = pnt3ds[2];
                            Point3d pnt3d3 = mTxt.Location;

                            double dblAngle = Base_Tools45.Measure.getAzRadians(pnt3d1, pnt3d2);

                            double  dblRotate   = Geom.getAngle3Points(pnt3d3, pnt3d1, pnt3d2);
                            Boolean isRightHand = Base_Tools45.Math.isRightHand(pnt3d3, pnt3d1, pnt3d2);
                            if (isRightHand != true)
                            {
                                dblRotate = -dblRotate;
                            }

                            Boolean Left_Justify = Base_Tools45.Math.left_Justify(dblAngle);

                            Point3d pnt3d = Base_Tools45.Math.traverse(pnt3ds[1], dblAngle, dblWidth / 2 + mTxt.ActualHeight * 0.1);

                            if (Left_Justify != true)
                            {
                                dblRotate = dblRotate + PI;
                            }

                            Matrix3d           curUCSMatrix = ED.CurrentUserCoordinateSystem;
                            CoordinateSystem3d curUCS       = curUCSMatrix.CoordinateSystem3d;

                            mTxt.TransformBy(Matrix3d.Rotation(dblRotate, curUCS.Zaxis, pnt3ds[1]));

                            mTxt.Location = mTxt.Location.TransformBy(Matrix3d.Displacement(mTxt.Location.GetVectorTo(pnt3d)));

                            Events.activateMText("*", mTxt);
                            pnt3d = Base_Tools45.Math.traverse(pnt3ds[1], dblAngle, dblWidth * 1.20);
                        }
                    }

                    tr.Commit();
                }
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " Mod.cs: line: 911");
            }
        }
Ejemplo n.º 4
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