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;

    }

  }

}


Comments

2 responses to “Remove insertion grip point using overrule”

  1. Adam,
    That Was Great.
    David

  2. Thanks.
    This really should be an option in the block editor.

Leave a Reply to DavidCancel reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading