Ejemplo n.º 1
0
        public static void TecTest()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db  = doc.Database;
            Editor   ed  = doc.Editor;

            using (Transaction Tx = db.TransactionManager.StartTransaction())
            {
                BlockTableRecord ms      = (BlockTableRecord)Tx.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(db), OpenMode.ForRead);
                RXObject         brClass = RXObject.GetClass(typeof(BlockReference));

                Point3d lastrightpt = new Point3d(0, 0, 0);

                foreach (ObjectId id in ms)
                {
                    if (id.ObjectClass == brClass)
                    {
                        BlockReference br = (BlockReference)Tx.GetObject(id, OpenMode.ForWrite);
                        ed.WriteMessage("NAME:{0}\n", br.Name);
                        Extents3d bounds = br.GeometricExtents;
                        ed.WriteMessage("BOUNDS: {0}\n", bounds.ToString());
                        Vector3d vec = (Vector3d)(lastrightpt - bounds.MinPoint);
                        ed.WriteMessage("VECTOR: {0}\n", vec.ToString());

                        Point3d  rightpt = new Point3d(bounds.MaxPoint.X, bounds.MinPoint.Y, 0);;
                        Vector3d newrp   = (Vector3d)(vec + rightpt.GetAsVector() + (new Vector3d(50, 0, 0)));
                        lastrightpt = new Point3d(newrp.X, newrp.Y, 0);
                        ed.WriteMessage("NEWLASTRIGHT SET to {0}\n", lastrightpt);
                        Matrix3d mat = Matrix3d.Displacement(vec);
                        br.TransformBy(mat);
                    }
                }
                Tx.Commit();
            }
        }