Exemplo n.º 1
0
        /// <summary>
        /// Возвращает маскировку, созданную по контуру с указанным отступом
        /// </summary>
        /// <param name="extents3d">Крайние границы</param>
        /// <param name="offset">Отступ</param>
        private static Wipeout GetBackgroundMask(Extents3d extents3d, double offset)
        {
            try
            {
                var minPoint         = extents3d.MinPoint;
                var maxPoint         = extents3d.MaxPoint;
                var bottomLeftPoint  = new Point2d(minPoint.X - offset, minPoint.Y - offset);
                var topLeftPoint     = new Point2d(minPoint.X - offset, maxPoint.Y + offset);
                var topRightPoint    = new Point2d(maxPoint.X + offset, maxPoint.Y + offset);
                var bottomRightPoint = new Point2d(maxPoint.X + offset, minPoint.Y - offset);

                var wipeout = new Wipeout();
                wipeout.SetFrom(
                    new Point2dCollection
                {
                    bottomLeftPoint, topLeftPoint, topRightPoint, bottomRightPoint, bottomLeftPoint
                }, Vector3d.ZAxis);
                return(wipeout);
            }
            catch (Autodesk.AutoCAD.Runtime.Exception ex)
            {
                if (ex.Message == "eNullExtents")
                {
                    return(null);
                }

                throw;
            }
        }
Exemplo n.º 2
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);
        }