Overrule pipe network part in profile view

By Augusto Goncalves

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;}

Comments

5 responses to “Overrule pipe network part in profile view”

  1. rafrbu Avatar
    rafrbu

    There is only one ProfileViewPart per Network Part? So the Bounds of the ProfileViewPart spans across all the Profile Views where the Pipe is set to be drawn…

  2. Actually it’s 1-N
    You can have N profile part view showing a specific pipe or structure, use Part.GetProfileViewsDisplayingMe to get all profile view part.
    Regards,
    Augusto Goncalves

  3. rafrbu Avatar
    rafrbu

    1-N ProfileViewParts per NetworkPart? So at least 1 ProfileViewPart per NetworkPart…?
    I observe that if you select one certain ProfileViewPart in a Profile View, then all ‘ProfileViewParts’ for the corresponding NetworkPart is selected. So there seems to be only one ProfileViewPart object “behind the scenes”..
    And my point is that ProfileViewPart.Bounds includes the Bounds for all the ‘ProfileViewParts’ of a NetworkPart. Hence if the NetworkPart is set to be drawn in say two Profile Views, then the line you draw above will span from View number 1 to View number 2.

  4. Looks like it’s getting very specific… would you mind discuss on ADN support case? Please attach a non-confidential sample drawing? Looking forward to your reply.
    Regards
    Augusto Goncalves

  5. Hi Rafbru,
    Have this issue been resolved?

Leave a Reply

Discover more from Autodesk Developer Blog

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

Continue reading