找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 1147|回复: 0

[分享] Remove insertion grip point using overrule

[复制链接]

已领礼包: 593个

财富等级: 财运亨通

发表于 2013-6-12 01:37:34 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

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

×
Remove insertion grip point using overrule                         By Adam Nagy
If you think that the insertion grip point of a block reference is in the way then you can use GripOverrule to remove it.
The following sample only removes the insertion grip point of dynamic block references:

  1. using System;
  2. using Autodesk.AutoCAD.Runtime;
  3. using Autodesk.AutoCAD.DatabaseServices;
  4. using Autodesk.AutoCAD.Geometry;

  5. namespace ClassLibrary1
  6. {
  7.   public class Commands
  8.   {
  9.     public class MyGripOverrule : GripOverrule
  10.     {
  11.       public override void GetGripPoints(
  12.         Entity entity, GripDataCollection grips,
  13.         double curViewUnitSize, int gripSize,
  14.         Vector3d curViewDir, GetGripPointsFlags bitFlags)
  15.       {
  16.         // It should not be anything else, since we are
  17.         // filtering for block references
  18.         BlockReference br = (BlockReference)entity;
  19.         base.GetGripPoints(entity, grips,
  20.           curViewUnitSize, gripSize,
  21.           curViewDir, bitFlags);
  22.         // We'll only remove it for dynamic blocks
  23.         if (br.IsDynamicBlock)
  24.         {
  25.           GripData toRemove = null;
  26.           foreach (GripData gd in grips)
  27.           {
  28.             if (gd.GripPoint == br.Position)
  29.             {
  30.               toRemove = gd;
  31.               break;
  32.             }
  33.           }
  34.           if (toRemove != null)
  35.             grips.Remove(toRemove);
  36.         }
  37.       }
  38.     }
  39.     [CommandMethod("RemoveInsertionPoint")]
  40.     public static void RemoveInsertionPoint()
  41.     {
  42.       Overrule.AddOverrule(
  43.         RXClass.GetClass(typeof(BlockReference)),
  44.         new MyGripOverrule(), true
  45.       );
  46.       Overrule.Overruling = true;
  47.     }
  48.   }
  49. }



评分

参与人数 1D豆 +2 收起 理由
ScmTools + 2 很给力!经验;技术要点;资料分享奖!

查看全部评分

论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-5-1 17:55 , Processed in 0.276135 second(s), 31 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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