Ejemplo n.º 1
0
        addLdr(Point3dCollection pnt3ds, bool isSplined = false, MText mTxt = null, string nameLayer = "0", short color = 256)
        {
            ObjectId idLdr = ObjectId.Null;
            Leader   ldr   = new Leader();
            double   scale = Misc.getCurrAnnoScale();

            try
            {
                using (Transaction tr = BaseObjs.startTransactionDb())
                {
                    BlockTableRecord MS = Blocks.getBlockTableRecordMS();

                    ldr.SetDatabaseDefaults();
                    ldr.HasArrowHead = true;
                    ldr.IsSplined    = isSplined;
                    ldr.Dimasz       = scale * 0.09;

                    Layer.manageLayers(nameLayer);
                    ldr.Layer = nameLayer;
                    ldr.Color = Color.FromColorIndex(ColorMethod.ByBlock, color);

                    foreach (Point3d pnt3d in pnt3ds)
                    {
                        ldr.AppendVertex(pnt3d);
                    }
                    idLdr = MS.AppendEntity(ldr);
                    tr.AddNewlyCreatedDBObject(ldr, true);
                    if (mTxt != null)
                    {
                        ldr.Annotation = mTxt.ObjectId;
                        ldr.Dimtad     = 0;
                        ldr.EvaluateLeader();
                    }
                    ldr.Annotative = AnnotativeStates.True;
                    tr.Commit();
                }// end using
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " Draw.cs: line: 162");
            }

            return(idLdr);
        }
Ejemplo n.º 2
0
        bubble(int numSides)
        {
            ObjectId idWO  = ObjectId.Null;             //wipeout
            ObjectId idSM  = ObjectId.Null;             //symbol
            ObjectId idTX  = ObjectId.Null;             //text
            ObjectId idLDR = ObjectId.Null;             //leader

            Object osMode = SnapMode.getOSnap();

            SnapMode.setOSnap(0);

            double  angleView = -(double)Application.GetSystemVariable("VIEWTWIST");
            Point3d pnt3d     = Pub.pnt3dO;
            Point3d pnt3dEnd  = Pub.pnt3dO;

            Handle                   hTarget     = "0000".stringToHandle();
            string                   layerTarget = "";
            ObjectIdCollection       idsLDR      = new ObjectIdCollection();
            FullSubentityPath        path        = new FullSubentityPath();
            List <FullSubentityPath> paths       = new List <FullSubentityPath>();
            int scale = Misc.getCurrAnnoScale();

            bool   canLdr = false;
            string result = bubTxt;

            try
            {
                do
                {
                    Entity ent = Ldr.getFirstLdrPoint(out pnt3d, out canLdr, out hTarget, out layerTarget, out path);
                    if (ent == null)
                    {
                        break;
                    }
                    Color color = Misc.getColorByLayer();
                    idLDR = JigSplineLeader_BB.jigSplineLeader(pnt3d, 0.09, "BUBBLE", color);

                    if (idLDR == ObjectId.Null)
                    {
                        break;
                    }

                    paths.Add(path);
                    pnt3dEnd = idLDR.getLastVertex();

                    Ldr.setLdrXData(pnt3dEnd, idLDR, idSM);

                    idsLDR.Add(idLDR);

                    bool cancel = false;

                    if (idsLDR.Count == 1)
                    {
                        if (numSides == 0)
                        {
                            cancel = UserInput.getUserInput(result, "\nEnter Callout Number: ", out result);
                            if (cancel || result == string.Empty)
                            {
                                return;
                            }
                            bubTxt = result;
                            idTX   = Txt.addMText(result, pnt3dEnd, angleView, 0.8, 0.09, AttachmentPoint.MiddleCenter, "Annotative", "BUBBLE", color, Pub.JUSTIFYCENTER);
                        }
                        else
                        {
                            cancel = UserInput.getUserInput(result, "\nEnter Callout Number", out result);
                            if (cancel || result == string.Empty)
                            {
                                return;
                            }
                            bubTxt = result;
                            idSM   = Draw.addSymbolAndWipeout(pnt3dEnd, angleView, out idWO, Pub.radius, numSides, true);
                            idSM.moveToTop();
                            idSM.moveBelow(new ObjectIdCollection {
                                idWO
                            });
                            idTX = Txt.addMText(result, pnt3dEnd, angleView, 0.0, 0.09, AttachmentPoint.MiddleCenter, "Annotative", "BUBBLE", color, Pub.JUSTIFYCENTER);
                        }
                    }
                }while (!canLdr);
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " Draw2.cs: line: 91");
            }
            finally
            {
                Application.SetSystemVariable("OSMODE", osMode);
                xRef.unHighlightNestedEntity(paths);
            }

            if (idTX.IsValid)
            {
                addXData(idSM, scale, idTX, idsLDR, idWO, numSides, hTarget, layerTarget);
            }
        }
Ejemplo n.º 3
0
        addSymbolAndWipeout(Point3d pnt3d, double angleView, out ObjectId idWO, double radius, int numSides, bool addWipeOut = false)
        {
            ObjectId idSYM = ObjectId.Null;

            double            pi         = System.Math.PI;
            double            pi2        = pi * 2.0;
            double            angleBase  = 0;
            double            length     = 0;
            double            delta      = 0;
            double            scale      = Misc.getCurrAnnoScale();
            double            deltaBegin = 0;
            Point2d           pnt2dBase  = Point2d.Origin;
            Point2dCollection pnts2d     = new Point2dCollection();
            Point2d           pnt2dCen   = new Point2d(pnt3d.X, pnt3d.Y);

            delta = 2 * pi / numSides;
            idWO  = ObjectId.Null;

            switch (numSides)
            {
            case 3:
                length    = 1.33 * scale * 2 * radius;
                pnt2dBase = pnt2dCen.traverse(angleView - pi / 2, length / 4);
                pnt2dBase = pnt2dBase.traverse(angleView, length / 2);
                pnts2d.Add(pnt2dBase);
                deltaBegin = delta + angleView;
                break;

            case 4:
                angleBase = angleView + 7.0 / 8.0 * pi2;
                length    = 0.5 * 1.68 * scale * radius * System.Math.Sqrt(2);
                pnt2dBase = pnt2dCen.traverse(angleBase, length);
                pnts2d.Add(pnt2dBase);
                length     = scale * 1.68 * radius;
                deltaBegin = delta + angleView;
                break;

            case 6:
                angleBase = angleView + 10.0 / 12.0 * pi2;
                //angleBase = angleView;
                length    = 1.03 * scale * radius / System.Math.Cos(delta / 3);
                pnt2dBase = pnt2dCen.traverse(angleBase, length);
                pnts2d.Add(pnt2dBase);     //pnt0
                deltaBegin = angleBase + 2 * delta;
                break;

            case 1024:
                //angleBase = angleView + 3.0 / 2.0 * pi;
                angleBase = angleView;
                length    = scale * 2.0 * radius * System.Math.Sin(delta / 2);
                pnt2dBase = pnt2dCen.traverse(angleBase, scale * radius);
                pnts2d.Add(pnt2dBase);
                deltaBegin = angleBase + delta + pi / 2;
                break;

            default:
                break;
            }

            //adjust first segment to account for viewtwist
            pnt2dBase = pnt2dBase.traverse(deltaBegin, length);
            pnts2d.Add(pnt2dBase); //pnt1
            //pnt2dBase.addPointNode(34, 0.01);

            double deltaTotal = deltaBegin;

            //from then on it is
            for (int i = 1; i < numSides; i++)
            {
                deltaTotal = deltaTotal + delta;
                pnt2dBase  = pnt2dBase.traverse(deltaTotal, length);
                pnts2d.Add(pnt2dBase); //pnts 2-6
                //pnt2dBase.addPointNode(34, 0.01);
            }

            if (numSides < 1024)
            {
                idSYM = addPoly(pnts2d, "BUBBLE", 5);
            }
            else
            {
                idSYM = Draw.addCircle(pnt3d, scale * radius, "BUBBLE", 5);
            }

            if (addWipeOut)
            {
                Wipeout wo = new Wipeout();
                try
                {
                    using (Transaction tr = BaseObjs.startTransactionDb())
                    {
                        BlockTableRecord ms = Blocks.getBlockTableRecordMS();
                        wo.SetFrom(pnts2d, Vector3d.ZAxis);
                        wo.Layer = "BUBBLE";
                        wo.Color = Color.FromColorIndex(ColorMethod.ByBlock, 8);
                        ms.AppendEntity(wo);
                        tr.AddNewlyCreatedDBObject(wo, true);
                        idWO = wo.ObjectId;
                        tr.Commit();
                    }
                }
                catch (System.Exception ex)
                {
                    BaseObjs.writeDebug(ex.Message + " Draw.cs: line: 804");
                }
            }

            return(idSYM);
        }
Ejemplo n.º 4
0
        addLdrText(string nameCmd, string nameApp, ObjectId idLdr, List <ObjectId> idsCgPnts, string top = "", string bot = "", string bot2 = "",
                   double deltaZ = 0.0, double xFactor = 0.8, bool useBackgroundFill = false, List <Point3d> pnts3dX = null)
        {
            string resultTop  = top.ToUpper();
            string resultBot  = bot.ToUpper();
            string resultBot2 = bot2.ToUpper();

            Point3d pnt3dTop = Pub.pnt3dO;
            Point3d pnt3dBot = Pub.pnt3dO;

            Point3d pnt3dLdrMid = Pub.pnt3dO;
            Point3d pnt3dLdrIns = Pub.pnt3dO;       //text insertion point on Ldr before offset
            Point3d pnt3dLdrEnd = Pub.pnt3dO;

            Point3d pnt3d1 = Pub.pnt3dO;
            Point3d pnt3d2 = Pub.pnt3dO;

            ObjectId idTxTop  = ObjectId.Null; //text
            ObjectId idTxBot  = ObjectId.Null;
            ObjectId idTxBot2 = ObjectId.Null;

            double         angle     = 0.0;
            double         scale     = Misc.getCurrAnnoScale();
            double         gapTop    = 0.09;
            double         gapBot    = 0.09;
            List <Point3d> pnts3dLdr = new List <Point3d>();

            int n = 0;
            //Application.ShowAlertDialog(idLDR.IsErased.ToString() + idLDR.IsEffectivelyErased.ToString() + idLDR.ToString());
            PromptStatus ps = PromptStatus.Cancel;

            if (nameCmd == "cmdFFD")
            {
                pnt3d1 = UserInput.getPoint("Pick Insertion Point for Label: ", out ps, osMode: 0);
                //Line line = LdrText_JigLine.jigLine(pnt3d1);
                //angle = line.Angle;
                //line.ObjectId.delete();
                angle = (double)Application.GetSystemVariable("VIEWTWIST");
            }
            else
            {
                if (idLdr.IsEffectivelyErased || idLdr.IsErased)
                {
                    return;
                }

                pnts3dLdr   = idLdr.getCoordinates3dList();
                n           = pnts3dLdr.Count;
                angle       = pnts3dLdr[n - 2].getDirection(pnts3dLdr[n - 1]); //angle opposite direction arrow is pointing for GS or direction of 2nd segment of leader if 3 points
                pnt3dLdrEnd = pnts3dLdr[n - 1];
            }

            double angleTx = 0;

            AttachmentPoint apTop;
            AttachmentPoint apBot;
            string          justifyTop = string.Empty;
            string          justifyBot = string.Empty;

            bool left_justify = Base_Tools45.Math.left_Justify(angle);

            if (left_justify)
            {
                apTop      = AttachmentPoint.BottomLeft;
                apBot      = AttachmentPoint.TopLeft;
                angleTx    = angle + pi;
                justifyTop = Pub.JUSTIFYLEFT;
                justifyBot = Pub.JUSTIFYLEFT;
            }
            else
            {
                apTop      = AttachmentPoint.BottomRight;
                apBot      = AttachmentPoint.TopRight;
                angleTx    = angle;
                justifyTop = Pub.JUSTIFYRIGHT;
                justifyBot = Pub.JUSTIFYRIGHT;
            }

            if (cmdsGS.Contains(nameCmd))
            { // overrides for GS commands
                apTop      = AttachmentPoint.BottomCenter;
                justifyTop = Pub.JUSTIFYCENTER;
            }

            if (nameCmd == "cmdFFD")
            {
                apTop      = AttachmentPoint.MiddleCenter;
                justifyTop = Pub.JUSTIFYCENTER;
            }

            if (nameCmd == "cmdDEP")
            {
                justifyTop = Pub.JUSTIFYCENTER;
            }
            if (bot.Length < 4)
            {
                justifyBot = Pub.JUSTIFYCENTER;
            }

            double widthTop = 0;
            double widthBot = 0;
            double station  = 0.0;
            double offset   = 0.0;

            Txt.setAnnoStyle();

            Color color = Misc.getColorByLayer();

            switch (nameCmd)
            {
            case "cmdFFD":
                string txtTop = string.Format("{0}{1}{2}", resultTop, @"\P", resultBot);
                idTxTop = Txt.addMText(txtTop, pnt3d1, angleTx, 0.0, 0.50, apTop, "Annotative", "GRADES", color, justifyTop, AnnotativeStates.True, 0.8, true, backgroundFill: useBackgroundFill);
                station = 0.0;
                offset  = 0.0;
                return;

            case "cmdGS3":
                pnt3dLdrMid = idLdr.getBegPnt().getMidPoint2d(idLdr.getEndPnt());
                pnt3dLdrIns = pnt3dLdrMid.traverse(angle, (0.09 * scale / 2.4));
                if (left_justify)
                {
                    pnt3dTop = pnt3dLdrIns.traverse(angle - pi / 2, (gapTop * scale / 5));
                }
                else
                {
                    pnt3dLdrIns = pnt3dLdrMid.traverse(angle, (0.09 * scale / 2.4));
                    pnt3dTop    = pnt3dLdrIns.traverse(angle + pi / 2, (gapTop * scale / 5));
                }
                idTxTop = Txt.addMText(top, pnt3dTop, angleTx, 0.0, 0.085, apTop, "Annotative", "GRADES", color, justifyTop, AnnotativeStates.True, 0.7, backgroundFill: useBackgroundFill);
                Geom.getStaOff(idsCgPnts, pnt3dLdrIns, ref station, ref offset);
                pnts3dLdr = new List <Point3d> {
                    idLdr.getBegPnt(),
                        idLdr.getEndPnt(),
                        pnt3dLdrIns
                };
                break;

            case "cmdGS":
            case "cmdGS0":
            case "cmdGSE":
            case "cmdGSS":
            case "cmdGSX":
            case "cmdSL":
            case "cmdSS":
                if (nameCmd == "cmdGSX")
                {
                    gapTop = 0.01;
                }
                else
                {
                    gapTop = 0.09;
                }
                pnt3dLdrMid = idLdr.getBegPnt().getMidPoint2d(idLdr.getEndPnt());
                pnt3dLdrIns = pnt3dLdrMid.traverse(angle, (0.09 * scale / 2.4));
                if (left_justify)
                {
                    pnt3dTop = pnt3dLdrIns.traverse(angle - pi / 2, (gapTop * scale / 4));
                }
                else
                {
                    pnt3dTop = pnt3dLdrIns.traverse(angle + pi / 2, (gapTop * scale / 4));
                }
                idTxTop = Txt.addMText(top, pnt3dTop, angleTx, 0.0, 0.09, apTop, "Annotative", "GRADES", color, justifyTop, backgroundFill: useBackgroundFill);

                Geom.getStaOff(idsCgPnts, pnt3dLdrIns, ref station, ref offset);
                pnts3dLdr = new List <Point3d> {
                    idLdr.getBegPnt(),
                        idLdr.getEndPnt(),
                        pnt3dLdrIns                //pnt3dM - on ldr opposite text insertion point
                };
                break;

            default:
                idTxTop  = Txt.addMText(resultTop, pnt3dLdrEnd, angleTx, 0.0, 0.09, apTop, "Annotative", "GRADES", color, justifyTop, backgroundFill: useBackgroundFill);
                widthTop = idTxTop.getMTextWidth();
                if (resultBot != string.Empty)
                {
                    idTxBot = Txt.addMText(resultBot, pnt3dLdrEnd, angleTx, 0.0, 0.09, apBot, "Annotative", "GRADES", color, justifyBot, backgroundFill: useBackgroundFill);
                }
                if (resultBot2 != string.Empty)
                {
                    pnt3dBot = pnt3dLdrEnd.traverse(angleTx - pi / 2, (.14 * scale));
                    idTxBot2 = Txt.addMText(resultBot2, pnt3dBot, angleTx, 0.0, 0.09, apBot, "Annotative", "GRADES", color, justifyBot, backgroundFill: useBackgroundFill);
                }
                station = 0.0;
                offset  = 0.0;
                break;
            }
            if (resultBot == string.Empty || nameCmd == "cmdFFD")
            {
                widthBot = 0;
            }
            else
            {
                widthBot = idTxBot.getMTextWidth();
            }

            double width = 0;

            if (widthBot > widthTop)
            {
                width = widthBot;
            }
            else
            {
                width = widthTop;
            }

            //Adjust callout leader length
            if (!cmdsGS.Contains(nameCmd))
            {
                if (nameCmd == "cmdFLX" || nameCmd == "cmdGX")
                {
                    gapTop = 0.01;
                    gapBot = 0.08;
                }
                else
                {
                    gapTop = 0.09;
                    gapBot = 0.09;
                }

                Point3d pnt3dLdrEndAdj = pnts3dLdr[n - 2].traverse(angle, width);  //reseting leader endpoint based on text width

                idLdr.adjLdrEndPnt(pnt3dLdrEndAdj);
                pnts3dLdr = idLdr.getCoordinates3dList();

                if (left_justify)
                {
                    pnt3dTop = pnt3dLdrEndAdj.traverse(angle - pi / 2, gapTop * scale / 4);
                    pnt3dBot = pnt3dLdrEndAdj.traverse(angle + pi / 2, gapBot * scale / 4);
                }
                else
                {
                    pnt3dTop = pnt3dLdrEndAdj.traverse(angle + pi / 2, gapTop * scale / 4);
                    pnt3dBot = pnt3dLdrEndAdj.traverse(angle - pi / 2, gapBot * scale / 4);
                }

                idTxTop.adjMTextXYandAngle(pnt3dTop, angleTx, width);
                if (idTxBot != ObjectId.Null)
                {
                    idTxBot.adjMTextXYandAngle(pnt3dBot, angleTx, width);
                }
                if (idTxBot2 != ObjectId.Null)
                {
                    if (left_justify)
                    {
                        pnt3dBot = pnt3dLdrEndAdj.traverse(angle + pi / 2, 0.14 * scale);
                    }
                    else
                    {
                        pnt3dBot = pnt3dLdrEndAdj.traverse(angle - pi / 2, 0.14 * scale);
                    }

                    idTxBot2.adjMTextXYandAngle(pnt3dBot, angleTx, width);
                }
            }

            idLdr.moveToTop();

            //Add XData
            if (nameCmd != "cmdRDR" && nameCmd != "cmdSW")
            {
                if (idTxTop.IsValid)
                {
                    addXDataLnks(nameApp, nameCmd, idLdr, idTxTop, idTxBot, idTxBot2, pnt3dTop, scale, deltaZ, pnts3dLdr, idsCgPnts, station, offset, pnts3dX);
                }
                else
                {
                    return;
                }
                //addMTextIdToAppDict(nameApp, idTxTop);
            }
        }