Ejemplo n.º 1
0
            public ObjectId DisplayArrow(Point3d position, Point3d valuePoint, string tag, Autodesk.AutoCAD.GraphicsInterface.TransientDrawingMode viewMod = Autodesk.AutoCAD.GraphicsInterface.TransientDrawingMode.DirectShortTerm)
            {
                ObjectId       brId = AppendBlock(position, valuePoint);
                BlockReference br;

                using (Transaction trans = Tools.StartTransaction())
                {
                    br = (BlockReference)brId.GetObject(OpenMode.ForWrite, false, true);
                    br.Erase(true);
                    trans.Commit();
                }
                using (Transaction trans = Tools.StartTransaction())
                {
                    ObjectId btrId = BlockTools.GetAnonymCopy(brId, trans, false);
                    brId = BlockTools.AddBlockRefToModelSpace(btrId, new[] { "N" }.ToList(), br.Position, this.Matrix);
                    trans.Commit();
                }

                using (Transaction trans = Tools.StartTransaction())
                {
                    br = (BlockReference)brId.GetObject(OpenMode.ForWrite, false, true);
                    br.Erase(true);
                    trans.Commit();
                }

                using (Transaction trans = Tools.StartTransaction())
                {
                    br = (BlockReference)brId.GetObject(OpenMode.ForWrite, true, true);
                    this.DynTransient.ClearTransientGraphics();
                    this.DynTransient.AddMarker((DBObject)br, tag, viewMod);
                    this.DynTransient.Display();
                }

                return(brId);
            }
Ejemplo n.º 2
0
        public void TestAnonyBlock()
        {
            Polyline pline = new Polyline(3);

            pline.AddVertexAt(0, new Point2d(0, 0), 0, 0, 0);
            pline.AddVertexAt(1, new Point2d(pline.GetPoint2dAt(0).X + 3, pline.GetPoint2dAt(0).Y), 0, 0.4, 0);
            pline.AddVertexAt(2, new Point2d(pline.GetPoint2dAt(1).X + 1.5, pline.GetPoint2dAt(1).Y), 0, 0, 0);
            pline.LineWeight = LineWeight.LineWeight020;

            AttributeDefinition ad = _createAttribute(pline.StartPoint, pline);

            Matrix3d ucs = CoordinateSystem.CoordinateTools.GetCurrentUcs();

            var btrId = BlockTools.CreateBlockTableRecordEx(Point3d.Origin, "test11111", new[] { (Entity)pline, (Entity)ad }.ToList(), AnnotativeStates.True);
            var brId  = BlockTools.AddBlockRefToModelSpace(btrId, new[] { "3" }.ToList(), new Point3d(10, 10, 10), ucs);

            using (Transaction trans = Tools.StartTransaction())
            {
                BlockReference br = (BlockReference)brId.GetObject(OpenMode.ForRead, false, true);
                br.UpgradeOpen();
                br.TransformBy(Matrix3d.Rotation(Math.PI / 2d, ucs.CoordinateSystem3d.Zaxis, br.Position));
                //br.Erase(true);
                trans.Commit();
            }

            AttributeReference ar;

            using (Transaction trans = Tools.StartTransaction())
            {
                BlockReference br = (BlockReference)brId.GetObject(OpenMode.ForRead, true, true);
                ar = br.GetAttributeByTag(ad.Tag, trans);
                ar = (AttributeReference)ar.Id.GetObject(OpenMode.ForRead, true, true);
                var anBtrId = BlockTools.GetAnonymCopy(brId, trans, false);
                var anBrId  = BlockTools.AddBlockRefToModelSpace(anBtrId, new[] { ar.TextString }.ToList(), new Point3d(0, 0, 0), ucs);

                trans.Commit();
            }
        }