明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 874|回复: 0

[JIG] 请问怎样实现在屏幕上指定旋转角度?

[复制链接]
发表于 2015-1-1 02:44 | 显示全部楼层 |阅读模式
这是我写的?在屏幕上指定旋转角度不会了(现在是错误的) 请指点下
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.GraphicsInterface;
namespace XXXX
{
  public  class EntJip:DrawJig
    {
        public BlockReference m_blo;
        private Point3d m_pt1, m_pt2;
        public EntJip(Point3d pt1,  BlockReference blo)
        {
            m_pt1 = pt1;//块的插入点
            m_blo = blo;
        }

        protected override bool WorldDraw(Autodesk.AutoCAD.GraphicsInterface.WorldDraw draw)
        {
            draw.Geometry.Draw(m_blo);
            return true;
        }

        protected override SamplerStatus Sampler(JigPrompts prompts)
        {
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            //Matrix3d mt = ed.CurrentUserCoordinateSystem;
            JigPromptPointOptions optJigPoint = new JigPromptPointOptions("\n请制定插入角度:");
            optJigPoint.Cursor = CursorType.NoSpecialCursor;            
            optJigPoint.UserInputControls =  UserInputControls.NoZeroResponseAccepted | UserInputControls.NoNegativeResponseAccepted;
            //optJigPoint.BasePoint = m_pt1.TransformBy(mt);//指定块参照的插入点
            optJigPoint.BasePoint = m_pt1;
            optJigPoint.UseBasePoint = true;
            //获得点
            PromptPointResult resJigPoint = prompts.AcquirePoint(optJigPoint);
            Point3d tempt = resJigPoint.Value;
            //拖拽取消
            if (resJigPoint.Status == PromptStatus.Cancel)
            {
                return SamplerStatus.Cancel;
            }
            //进行拖拽
            if (m_pt2 != tempt)
            {
                m_pt2 = tempt;
                m_blo.Position = m_pt1;
                double rotationAngle = m_pt2.AngleFromXAxis(m_pt1);
                m_blo.TransformBy(Matrix3d.Scaling(1, m_pt1) * Matrix3d.Rotation(rotationAngle-rotationAngle, Vector3d.ZAxis, m_pt1));               
                return SamplerStatus.OK;
            }
            else
            {
                return SamplerStatus.NoChange;
            }
        }

    }
}


您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-3-29 20:59 , Processed in 0.175936 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表