马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
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:
- using System;
- using Autodesk.AutoCAD.Runtime;
- using Autodesk.AutoCAD.DatabaseServices;
- using Autodesk.AutoCAD.Geometry;
- namespace ClassLibrary1
- {
- public class Commands
- {
- public class MyGripOverrule : GripOverrule
- {
- public override void GetGripPoints(
- Entity entity, GripDataCollection grips,
- double curViewUnitSize, int gripSize,
- Vector3d curViewDir, GetGripPointsFlags bitFlags)
- {
- // It should not be anything else, since we are
- // filtering for block references
- BlockReference br = (BlockReference)entity;
- base.GetGripPoints(entity, grips,
- curViewUnitSize, gripSize,
- curViewDir, bitFlags);
- // We'll only remove it for dynamic blocks
- if (br.IsDynamicBlock)
- {
- GripData toRemove = null;
- foreach (GripData gd in grips)
- {
- if (gd.GripPoint == br.Position)
- {
- toRemove = gd;
- break;
- }
- }
- if (toRemove != null)
- grips.Remove(toRemove);
- }
- }
- }
- [CommandMethod("RemoveInsertionPoint")]
- public static void RemoveInsertionPoint()
- {
- Overrule.AddOverrule(
- RXClass.GetClass(typeof(BlockReference)),
- new MyGripOverrule(), true
- );
- Overrule.Overruling = true;
- }
- }
- }
|