zoukankan      html  css  js  c++  java
  • 单纯的1个或多个实体移动的Jig

    using System;
    using Autodesk.AutoCAD.ApplicationServices;
    using Autodesk.AutoCAD.DatabaseServices;
    using Autodesk.AutoCAD.EditorInput;
    using Autodesk.AutoCAD.Geometry;
    using Autodesk.AutoCAD.GraphicsInterface;
    using Autodesk.AutoCAD.Runtime;
    using System.Collections.Generic;
    namespace ArxHlb
    {
        
    public class CADJig
        {
            
    /// <summary>
            
    ///  入口函数
            
    /// </summary>
            
    /// <param name="ed">ed</param>
            
    /// <param name="lstEnt">实体列表</param>
            
    /// <param name="promp">提示</param>
            
    /// <returns></returns>
            public static bool Jig(Editor ed, List<Entity> lstEnt, Point3d pt, string promp)
            {
                Jig jig 
    = new Jig();
                jig.lstEnt 
    = lstEnt;
                jig.ptBase 
    = pt;
                jig.promp 
    = promp;
                PromptResult prJig 
    = ed.Drag(jig);
                
    if (prJig.Status != PromptStatus.OK)
                {
                    
    return false;
                }
                
    else
                {
                    
    return true;
                }
            }
        }




        
    //本类是Jig,单独的实体或实体列表均可调用
        public class Jig : DrawJig
        {

            
    private List<Entity> _lstEnt; //移动的实体
            private Point3d _ptBase;   //基点
            private string _promp;   //提示


            
    /// <summary>
            
    /// 移动的实体
            
    /// </summary>
            public List<Entity> lstEnt
            {
                
    set { _lstEnt = value; }
            }

            
    /// <summary>
            
    /// 基点
            
    /// </summary>
            public Point3d ptBase
            {
                
    set { _ptBase = value; }
                
    get { return _ptBase; }
            }


            
    /// <summary>
            
    /// /提示
            
    /// </summary>
            public string promp
            {
                
    set { _promp = value; }
            }




            
    private Point3d ptTo;   //插入点

            
    protected override SamplerStatus Sampler(JigPrompts prompts)
            {
                JigPromptPointOptions optJigPoint 
    = new JigPromptPointOptions(_promp);
                
    //optJigPoint.Cursor = CursorType.RubberBand;

                optJigPoint.UserInputControls 
    =
                       UserInputControls.Accept3dCoordinates 
    |
                       UserInputControls.NoZeroResponseAccepted 
    |
                       UserInputControls.NoNegativeResponseAccepted 
    |
                       UserInputControls.NullResponseAccepted;

                optJigPoint.Keywords.Add(
    "Undo""Undo""放弃(U)");


                PromptPointResult resJigPoint 
    = prompts.AcquirePoint(optJigPoint);
                Point3d curPt 
    = resJigPoint.Value;
                
    if (ptTo != curPt)
                {
                    ptTo 
    = curPt;
                    
    return SamplerStatus.OK;
                }
                
    else
                {
                    ptBase 
    = ptTo;
                    
    return SamplerStatus.NoChange;
                }
            }


            
    protected override bool WorldDraw(WorldDraw draw)
            {
                
    try
                {
                    Matrix3d mat 
    = Matrix3d.Displacement(ptTo - ptBase);
                    
    foreach (Entity ent in _lstEnt)
                    {
                        
    //移动每个实体
                        ent.TransformBy(mat);
                        ent.RecordGraphicsModified(
    true);
                        draw.Geometry.Draw(ent);
                    }
                }
                
    catch (System.Exception)
                {
                    
    return false;
                }
                
    return true;
            }


        }
    }
     
     
  • 相关阅读:
    题目:输入一个链表,从尾到头打印链表每个节点的值
    【转】 文档与笔记利器 reStructuredText 和 Sphinx
    自动化selenium开发
    Sublime 3 打造成 Python/Django IDE开发利器
    python中的StringIO模块
    python检查IP地址正确性
    python2.7 使用super关键词 报错 TypeError: must be type, not&n
    【转】python time模块详解
    [黑群晖经典教程] 一步一步建立自己的黑群晖
    【转】NAS群晖DSM 5.0-4458安装教程
  • 原文地址:https://www.cnblogs.com/houlinbo/p/1667178.html
Copyright © 2011-2022 走看看