Exemplo n.º 1
0
        public void GetMirrorEnti()
        {
            BlockReference br = GetBlockCondition("请选择要镜像的块") as BlockReference;

            if (br == null)
            {
                return;
            }

            Point3d ptPos = br.Position;

            Point3d ptFirst = GetPoint("请选择镜像线的第一个点:\n");

            Point3d ptSecond = GetPoint("请选择镜像线的第二个点:\n");

            Line mLine = new Line(ptFirst, ptSecond);



            Vector3d mVec = ptSecond - ptFirst;

            double angle = Vector3d.YAxis.GetAngleTo(mVec);

            var br2 = br.GetTransformedCopy(Matrix3d.Rotation(Math.PI + angle, Vector3d.ZAxis, ptPos)) as BlockReference;

            br2.TransformBy(Matrix3d.Rotation(Math.PI, Vector3d.YAxis, br2.Position));

            Vector3d mVecTri = mVec.RotateBy(Math.PI / 2, Vector3d.ZAxis);

            Point3d pt1 = ptPos + mVecTri.GetNormal() * 10;

            Point3d pt2 = mLine.GetClosestPointTo(ptPos, true);

            Line line2 = new Line(ptPos, pt2);

            Point3dCollection ptColl = new Point3dCollection();

            line2.IntersectWith(mLine, Intersect.ExtendBoth, ptColl, IntPtr.Zero, IntPtr.Zero);

            var vec = ptColl[0] - ptPos;

            br2.TransformBy(Matrix3d.Displacement(vec));
            mLine.ToSpace();
            br2.ToSpace();
        }