public class TestDrawJig : DrawJig
{
public Point3d cp;
public TestDrawJig()
{
cp = Point3d.Origin;
}
protected override bool WorldDraw(WorldDraw draw)
{
return true;
}
protected override SamplerStatus Sampler(JigPrompts prompts)
{
PromptPointResult ppRes = prompts.AcquirePoint("\n[ Jig ] Pick a point : ");
if (cp != null)
{
double dDistance = ppRes.Value.DistanceTo(cp);
if (dDistance < 0.00001)
{
return SamplerStatus.NoChange;
}
}
cp = ppRes.Value;
return SamplerStatus.OK;
}
}
public class GrpOver : GripOverrule
{
private static GrpOver _gripOverrule = null;
private static TestDrawJig _testDrawJig = null;
public override bool IsApplicable(RXObject overruledSubject)
{
bool isApplicable = false;
DBPoint point = overruledSubject as DBPoint;
if (point != null)
{
isApplicable = true;
}
return isApplicable;
}
public static void AttachOverrule()
{
_gripOverrule = new GrpOver();
Overrule.AddOverrule(RXClass.GetClass(typeof(DBPoint)), _gripOverrule, true);
Overrule.Overruling = true;
}
public static void RemoveOverrule()
{
Overrule.RemoveOverrule(RXClass.GetClass(typeof(DBPoint)), _gripOverrule);
Overrule.Overruling = false;
_gripOverrule = null;
}
public override void MoveGripPointsAt(Entity ent, IntegerCollection ic, Vector3d vct)
{
DBPoint point = ent as DBPoint;
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
ed.WriteMessage(String.Format("{0}MoveGripPointsAt...", Environment.NewLine));
if (point != null && point.ObjectId.IsValid)
{
if (_testDrawJig == null)
_testDrawJig = new TestDrawJig();
PromptResult pr = ed.Drag(_testDrawJig);
if (pr.Status == PromptStatus.OK)
{
Point3d pt = _testDrawJig.cp;
ed.WriteMessage(String.Format("Point selected : {0} {1} {2}", pt.X, pt.Y, pt.Z));
}
}
base.MoveGripPointsAt(ent, ic, vct);
}
}
public class Commands : IExtensionApplication
{
void IExtensionApplication.Initialize()
{
GrpOver.AttachOverrule();
}
void IExtensionApplication.Terminate()
{
GrpOver.RemoveOverrule();
}
}