We have a few samples of our blog showing how create drawable overrule. But what’s the skeleton to set up? This is actually a recurrent question on our support, so I decided to share what is my recommendation.
To make it work you’ll need a class that implements the DrawableOverrule class and the WorldDraw method (and the ViewportDraw is more specific). I prefer have a command to active/deactivate the overrule and make it as startup command (using bundle format). The command will check the variable and Add or Remove the overrule. Finally, remember to call Regen(), otherwise the new geometry will not appear.
The sample below should work for MText (for other types, just replace the class name).
[CommandMethod("simpleOverrule")]
public void CmdSimpleOverrule()
{
if (_overrule == null)
{
_overrule = new TextOverrule();
Overrule.AddOverrule(
RXClass.GetClass(typeof(MText)),
_overrule, false);
}
else
{
Overrule.RemoveOverrule(
RXClass.GetClass(typeof(MText)),
_overrule);
_overrule = null;
}
Application.DocumentManager.MdiActiveDocument.Editor.Regen();
}
private static TextOverrule _overrule = null;
public class TextOverrule : DrawableOverrule
{
public override bool WorldDraw(Drawable drawable, WorldDraw wd)
{
// draw the base class
bool ret = base.WorldDraw(drawable, wd);
// your custom code here
//
//
// return the base
return ret;
}
}