示例#1
0
        public void TransformEnties()
        {
            Vector3d UserXaxis = db.Ucsxdir;
            Vector3d WXaxis    = new Vector3d(1, 0, 0);
            Vector3d Zaxis     = new Vector3d(0, 0, 1);
            double   Rangle    = UserXaxis.GetAngleTo(WXaxis);

            if (UserXaxis.Y < 0)
            {
                Zaxis = Zaxis.Negate();                                           //1.03版修改,修正角度旋转正负问题
            }
            Matrix3d Rmat = Matrix3d.Rotation(Rangle, Zaxis, mdragPT);            //旋转矩阵

            if (mdragPT.TransformBy(UCS.Inverse()).X >= mbasePT.TransformBy(UCS.Inverse()).X)
            {
                mIsRight = true;
                Matrix3d mat = Matrix3d.Displacement(mbasePT.GetVectorTo(mdragPT)).PreMultiplyBy(Rmat);  //旋转矩阵左乘位移矩阵
                foreach (Entity ent in mEntities)
                {
                    ent.TransformBy(mat);
                }
            }
            else
            {
                mIsRight = false;
                Line     L   = (Line)mEntitiesL[0];
                Vector3d Vt  = new Vector3d(L.Length, 0, 0);
                Matrix3d mat = Matrix3d.Displacement(mbasePT.GetVectorTo(mdragPT) - Vt).PreMultiplyBy(Rmat);//旋转矩阵左乘位移矩阵,然后镜像矩阵左乘前结果
                foreach (Entity ent in mEntitiesL)
                {
                    ent.TransformBy(mat);
                }
            }
        }
示例#2
0
        protected override AcEd.SamplerStatus Sampler(AcEd.JigPrompts prompts)
        {
            AcEd.JigPromptPointOptions jppo = new AcEd.JigPromptPointOptions();
            AcEd.PromptPointResult     ppr;

            jppo.Message      = this.methodConstructing.GetMessage();
            jppo.UseBasePoint = false;

            ppr = prompts.AcquirePoint(jppo);

            if (ppr.Status == AcEd.PromptStatus.Cancel || ppr.Status == AcEd.PromptStatus.Error)
            {
                return(AcEd.SamplerStatus.Cancel);
            }
            AcGe.Point3d tmpPt = ppr.Value.TransformBy(UCS.Inverse());
            if (!this.diagonalPoint.IsEqualTo(tmpPt, new AcGe.Tolerance(10e-10, 10e-10)))
            {
                this.diagonalPoint = tmpPt;
                return(AcEd.SamplerStatus.OK);
            }
            else
            {
                return(AcEd.SamplerStatus.NoChange);
            }
        }
示例#3
0
        protected override bool WorldDraw(Autodesk.AutoCAD.GraphicsInterface.WorldDraw draw)
        {
            mleader.EndPoint = mdragPT;
            Vector3d UserXaxis = db.Ucsxdir;
            Vector3d WXaxis    = new Vector3d(1, 0, 0);
            Vector3d Zaxis     = new Vector3d(0, 0, 1);
            double   Rangle    = UserXaxis.GetAngleTo(WXaxis);

            if (UserXaxis.Y < 0)
            {
                Zaxis = Zaxis.Negate();                                           //1.03版修改,修正角度旋转正负问题
            }
            Matrix3d Rmat = Matrix3d.Rotation(Rangle, Zaxis, mdragPT);            //旋转矩阵

            if (mdragPT.TransformBy(UCS.Inverse()).X >= mbasePT.TransformBy(UCS.Inverse()).X)
            {
                Matrix3d      mat = Matrix3d.Displacement(mbasePT.GetVectorTo(mdragPT)).PreMultiplyBy(Rmat); //旋转矩阵左乘位移矩阵
                WorldGeometry geo = draw.Geometry;
                if (geo != null)
                {
                    geo.Draw(mleader);
                    geo.PushModelTransform(mat);
                    foreach (Entity ent in mEntities)
                    {
                        geo.Draw(ent);
                    }
                    geo.PopModelTransform();
                }
            }
            else
            {
                Line          L   = (Line)mEntitiesL[0];
                Vector3d      Vt  = new Vector3d(L.Length, 0, 0);
                Matrix3d      mat = Matrix3d.Displacement(mbasePT.GetVectorTo(mdragPT) - Vt).PreMultiplyBy(Rmat);//旋转矩阵左乘位移矩阵
                WorldGeometry geo = draw.Geometry;
                if (geo != null)
                {
                    geo.Draw(mleader);
                    geo.PushModelTransform(mat);
                    foreach (Entity ent in mEntitiesL)
                    {
                        geo.Draw(ent);
                    }
                    geo.PopModelTransform();
                }
            }
            return(true);
        }