Using this simple overrule skeleton we can change the pipe or structure representation on a profile view. We just need to overrule the ProfilePartView class and do some additional geometry. Here is a quick sample.
class PipePartOverrule : DrawableOverrule
{
public override bool WorldDraw(
Drawable drawable, WorldDraw wd)
{
bool ret = base.WorldDraw(drawable, wd);
ProfileViewPart viewPart = drawable as ProfileViewPart;
if (viewPart == null) return ret; // for safety
// get the database
// if the entity is database resident, if not,
// then get the active on
Database db = (viewPart.Database != null ?
viewPart.Database :
Application.DocumentManager.
MdiActiveDocument.Database);
// get the model part type
if (viewPart.ModelPartId.ObjectClass ==
RXClass.GetClass(typeof(Pipe)))
{
// ok, this view part represents a Pipe
// let's draw something... just a crossing line
wd.Geometry.WorldLine(
viewPart.Bounds.Value.MinPoint,
viewPart.Bounds.Value.MaxPoint);
}
// if you consider handle Structures
//else if (viewPart.ModelPartId.ObjectClass ==
// RXClass.GetClass(typeof(Structure)))
//{
//}
return ret;
}
}
And here is the command based on the skeleton
public class Commads
{
[CommandMethod("profilePartOverrule")]
public static void CmdProfilePartOverrule()
{
if (_overrule == null)
{
_overrule = new PipePartOverrule();
Overrule.AddOverrule(
RXClass.GetClass(typeof(ProfileViewPart)),
_overrule, false);
}
else
{
Overrule.RemoveOverrule(
RXClass.GetClass(typeof(ProfileViewPart)),
_overrule);
_overrule = null;
}
Application.DocumentManager.
MdiActiveDocument.Editor.Regen();
}
private static PipePartOverrule _overrule = null;
}