明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 821|回复: 0

[JIG] 在进行块参照拖拽即时绘图时有时会出现如下错误?

[复制链接]
发表于 2015-2-12 14:03 | 显示全部楼层 |阅读模式
错误行代码如下:
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 标准化单机版
{
  public  class EntJip:DrawJig
    {
      public Entity m_blo;
        //public BlockReference m_blo;
        private Point3d m_pt1, m_pt2;
        private double rotate;
        private double scale;
        public EntJip(Point3d pt1,  BlockReference blo,double sc)
        {
            m_pt1 = pt1;//块的插入点
            m_blo = blo as Entity;
            rotate = 0;
            scale = sc;
        }
        protected override bool WorldDraw(WorldDraw draw)
        {
            draw.Geometry.Draw(m_blo);  
             return false;
        }
        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.Accept3dCoordinates
                | UserInputControls.NoZeroResponseAccepted
                | UserInputControls.NoNegativeResponseAccepted;
            optJigPoint.BasePoint = m_pt1.TransformBy(mt);//基点必须是WCS点
            optJigPoint.UseBasePoint = true;
            //获得点
            //try
            //{
                PromptPointResult resJigPoint = prompts.AcquirePoint(optJigPoint);//错误信息中说在这行出错
                m_pt2 = resJigPoint.Value;
                if (resJigPoint.Status != PromptStatus.OK) return SamplerStatus.Cancel;
                Point3d ucsPt = m_pt2.TransformBy(mt.Inverse());
                double temprotate = ucsPt.AngleFromXAxis(m_pt1);
                //拖拽取消
                if (resJigPoint.Status == PromptStatus.Cancel)
                {
                    return SamplerStatus.Cancel;
                }
                //进行拖拽
                if (rotate != temprotate)
                {
                    double rotateangle = temprotate - rotate;
                    rotate = temprotate;
                    m_blo.TransformBy(Matrix3d.Scaling(scale, m_pt1.TransformBy(mt)) * Matrix3d.Rotation(rotateangle, Vector3d.ZAxis, m_pt1.TransformBy(mt)));
                    return SamplerStatus.OK;
                }
                else
                {
                    return SamplerStatus.NoChange;
                }
            //}
            //catch (Exception ex)
            //{
            //    Application.ShowAlertDialog(ex.Message);
            //    return SamplerStatus.NoChange;
            //}
       }
    }
}
还请高手抽时间给分析一下! 多谢

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

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

本版积分规则

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

GMT+8, 2024-4-20 21:31 , Processed in 0.184404 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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