Create a Pipe Cap

Things have been a bit hectic for me in the last few days, with several complex cases to solve.
I also suddenly and unexpectedly had to find out how to apply for a visa to Saudi Arabia, which is a kind of interesting process.
Apparently, you start out with the inviting company in Saudi Arabia, which has to issue an invitation letter. This has to include a reference number, for which a form needs to be filled in and submitted to the Ministry of Foreign Affairs.
With that in place, a letter from my company addressed to the embassy of Saudi Arabia in Bern can be submitted to request the visa. This letter must be legalised by the chamber of commerce in Switzerland.
So quite an impressive process before I can even get started applying…

Anyway, another thing that came up today that was immediately solvable is the following simple question on how to create a new cap on a pipe in the Revit MEP context:

Question: The Revit SDK samples do not include any example showing how to create a cap on as pipe.
Can you show me how to do it in C#?

Let’s say I create a pipe as follows:


  UIApplication uiapp = commandData.Application;
  Document rvtDoc = uiapp.ActiveUIDocument.Document;
 
  XYZ start = new XYZ( 0, 0, 0 );
  XYZ end = new XYZ( 6, 0, 4 );
 
  FilteredElementCollector collector
    = new FilteredElementCollector( rvtDoc );
 
  collector.OfClass( typeof( ElementType ) );
 
  PipeType pipeType = collector.FirstElement()
    as PipeType;
 
  Pipe pipe = rvtDoc.Create.NewPipe(
    start, end, pipeType );
 
  pipe.get_Parameter(
    BuiltInParameter.RBS_PIPE_DIAMETER_PARAM )
    .Set( 0.1667 ); // revise to 2" dia pipe

In the project browser I see the node Families > Pipe Fittings > M_Cap – Generic > Standard.

How can I use that family to create a 2″ dia cap at the start point of the 2″ dia pipe in C#?

Answer: The solution is simple, actually, in the following two steps:

  1. Insert a cap family instance.
  2. Connect it to the pipe.

By the way, in your code, you are selecting the pipe type from a collector returning all element types.
That seems a bit liberal to me.
I would suggest adding a filter for the built-in category as well.

Here is my code that does just that.
First, I need to define a few constants to identify and load the cap symbol:


  const string _libFolder = "C:/Documents and Settings"
    + "/All Users/Application Data/Autodesk/RME 2011"
    + "/Metric Library/Pipe/Fittings/Generic";
 
  const string _rfaExtension = ".rfa";
  const string _capFamilyName = "M_Cap - Generic";
  const string _capSymbolName = "Standard";

I then create the pipe like before, select the cap family symbol, and insert an instance of it at the end point of the pipe:


  UIApplication uiapp = commandData.Application;
  Document doc = uiapp.ActiveUIDocument.Document;
 
  PipeType pipeType
    = new FilteredElementCollector( doc )
    .OfClass( typeof( ElementType ) )
    .OfCategory( BuiltInCategory.OST_PipeCurves )
    .FirstElement() as PipeType;
 
  XYZ start = new XYZ( 0, 0, 0 );
  XYZ end = new XYZ( 6, 0, 4 );
 
  Transaction t = new Transaction( doc,
    "Create Pipe Cap" );
 
  t.Start();
 
  Pipe pipe = doc.Create.NewPipe(
    start, end, pipeType );
 
  pipe.get_Parameter(
    BuiltInParameter.RBS_PIPE_DIAMETER_PARAM )
    .Set( 0.1667 ); // revise to 2" dia pipe
 
  // get cap symbol:
 
  List<FamilySymbol> symbols = new List<FamilySymbol>(
    new FilteredElementCollector( doc )
      .OfCategory( BuiltInCategory.OST_PipeFitting )
      .OfClass( typeof( FamilySymbol ) )
      .OfType<FamilySymbol>()
      .Where<FamilySymbol>( s
        => s.Family.Name.Equals( _capFamilyName ) ) );
 
  FamilySymbol capSymbol = null;
 
  if( 0 < symbols.Count )
  {
    capSymbol = symbols[0];
  }
  else
  {
    string filename = Path.Combine( _libFolder,
      _capFamilyName + _rfaExtension );
 
    // requires a transaction, obviously:
 
    doc.LoadFamilySymbol( filename, _capSymbolName,
      out capSymbol );
  }
 
  Debug.Assert( capSymbol.Family.Name.Equals( _capFamilyName ),
    "expected cap pipe fitting to be of family " + _capFamilyName );
 
  FamilyInstance fi = doc.Create.NewFamilyInstance(
    end, capSymbol, StructuralType.NonStructural );

The result of running the code so far looks like this:

Pipe cap unconnected

This implements the first step above.
As you can see, the cap is not connected to the pipe, and it also has a wrong diameter.

To implement the second step, we need to pick the suitable connectors on the cap and the pipe and hook them up with each other.
On the cap, there is just one connector, so that is easy.

On the pipe, there are two, and it is more complex.
The order of connectors returned by the connector manager may change, so one should always use a location or some other criterion to select the right one.
In this case, we check the distance of the pipe connectors to the endpoint we are capping and pick the closest one.

Once the two connectors have been selected, we can connect them to each other:


  // pick connector on cap:
 
  ConnectorSet connectors
    = fi.MEPModel.ConnectorManager.Connectors;
 
  Debug.Assert( 1 == connectors.Size,
    "expected nly one connector on pipe cap element" );
 
  Connector cap_end = null;
 
  foreach( Connector c in connectors )
  {
    cap_end = c;
  }
 
  // pick closest connector on pipe:
 
  connectors = pipe.ConnectorManager.Connectors;
 
  Connector pipe_end = null;
 
  // the order of connectors returned by the 
  // connector manager may change, so we 
  // always use a location (or even more 
  // information if several connectors are 
  // at the same location) to get the right
  // connector!
 
  double dist = double.MaxValue;
 
  foreach( Connector c in connectors )
  {
    XYZ p = c.Origin;
    double d = p.DistanceTo( end );
 
    if( d < dist )
    {
      dist = d;
      pipe_end = c;
    }
    break;
  }
 
  cap_end.ConnectTo( pipe_end );
 
  t.Commit();
 
  return Result.Succeeded;

The result of running the complete code looks like this:

Pipe cap connected

As you can see, the cap is now automatically positioned and dimensioned correctly with no further input required from my side.

Here is
CreatePipeCap.zip
containing the entire source code and Visual Studio solution implementing this command.


Comments

98 responses to “Create a Pipe Cap”

  1. Kailash Kute Avatar
    Kailash Kute

    hi jeremy,
    i m new in revit programming
    i have a pipe with 45 degree angle
    i want to place a coupling at 6 mtr distance its getting placed but it is not getting rotated perpendicular to axis of pipe,
    i have rotated it using rotate function but it is not getting placed properly in proper angle.
    how to get the angle to rotate it so it breaks the pipe and gets placed properly in document.
    thanks
    Kailash Kute.

  2. Kailash Kute Avatar
    Kailash Kute

    in above mentioned question i came to know while testing my program is that while i rotate the coupling, its x axis is rotating it in that direction,, but actully its y axis should be rotated how to do that plz help
    thanks in advance

  3. Dear Kailash,
    If you wish the coupling to break the pipe, I assume it is a tee of some kind, i.e. a pipe tap or spud. Please look at the discussion in
    http://forums.autodesk.com/t5/Autodesk-Revit-MEP/Pipe-Taps/mp/2073690/highlight/true#M2508
    The thread includes a sample “Pipe Spud” family which you can save locally and test on a project. This is the recommended family type and category to use for now for a pipe outlet part.
    For an example on using it manually, you can look at this video showing how to load the fitting into a project and use it when drawing a pipe:
    http://www.screencast.com/t/TApTeKqy
    Basically, you do the following:
    Load the family into a project
    Select Pipe from the ribbon
    Select Edit Type
    Change the preferred type to Tap
    Set the pipe spud as the default tap
    Click Apply/OK
    Now when you draw a branch pipe off of the main, the spud will be placed at the intersection.
    When the proper family is loaded, you can use the same approach for pipes as I did for ducts in
    http://thebuildingcoder.typepad.com/blog/2011/02/use-of-newtakeofffitting-on-a-duct.html
    Cheers, Jeremy.

  4. Kailash Kute Avatar
    Kailash Kute

    hi jeremy,
    Regards for the Day.
    thanks for the previous reply i learned a lot from that,
    below is the code for placing a coupling in all the 4 quadrants over a pipe
    if (angleinDegree = 0)
    {
    if (!endPoint.X.ToString().Contains(“-“))// !startPoint.X.ToString().Contains(“-“) && !startPoint.Y.ToString().Contains(“-“))
    {
    //1 Quadrant
    //MessageBox.Show(“1st condition”);
    x = startPoint.X + 6 * Math.Cos(angle);
    y = startPoint.Y + 6 * Math.Sin(angle);
    z = startPoint.Z;
    Pos = new XYZ(x, y, z);
    }
    else
    {
    //MessageBox.Show(“2 condition”);
    //3 Quadrant
    x = startPoint.X – 6 * Math.Cos(angle);
    y = startPoint.Y – 6 * Math.Sin(angle);
    z = startPoint.Z;
    Pos = new XYZ(x, y, z);
    }
    }
    else if (angleinDegree = -90)
    {
    if (!endPoint.Y.ToString().Contains(“-“))
    {
    //2 Quadrant
    //MessageBox.Show(“3 condition”);
    x = startPoint.X – 6 * Math.Cos(angle);
    y = startPoint.Y – 6 * Math.Sin(angle);
    z = startPoint.Z;
    Pos = new XYZ(x, y, z);
    }
    else
    {
    //4 Quadrant
    //MessageBox.Show(“4 condition”);
    x = startPoint.X + 6 * Math.Cos(angle);
    y = startPoint.Y + 6 * Math.Sin(angle);
    z = startPoint.Z;
    Pos = new XYZ(x, y, z);
    }
    }
    else
    {
    }
    and below is the line by which i am rotating a coupling around axis of pipe
    Line axis = _rvtDoc.Application.Create.NewLineBound(strtpnt, endpnt);
    bool flag = _rvtDoc.Rotate(f, axis, angle);
    now here the f is my coupling which i want to place in such a position that it should break the pipe in two piece
    i m not able to do that
    plz help appreciated
    Thanks
    kailash

  5. Kailash Kute Avatar
    Kailash Kute

    if (angleinDegree = 0)
    {
    if (!endPoint.X.ToString().Contains(“-“))
    {
    //1 Quadrant
    //MessageBox.Show(“1st condition”);
    x = startPoint.X + 6 * Math.Cos(angle);
    y = startPoint.Y + 6 * Math.Sin(angle);
    z = startPoint.Z;
    Pos = new XYZ(x, y, z);
    }
    else
    {
    //MessageBox.Show(“2 condition”);
    //3 Quadrant
    x = startPoint.X – 6 * Math.Cos(angle);
    y = startPoint.Y – 6 * Math.Sin(angle);
    z = startPoint.Z;
    Pos = new XYZ(x, y, z);
    }
    }
    else if (angleinDegree = -90)
    {
    if (!endPoint.Y.ToString().Contains(“-“))
    {
    //2 Quadrant
    //MessageBox.Show(“3 condition”);
    x = startPoint.X – 6 * Math.Cos(angle);
    y = startPoint.Y – 6 * Math.Sin(angle);
    z = startPoint.Z;
    Pos = new XYZ(x, y, z);
    }
    else
    {
    //4 Quadrant
    //MessageBox.Show(“4 condition”);
    x = startPoint.X + 6 * Math.Cos(angle);
    y = startPoint.Y + 6 * Math.Sin(angle);
    z = startPoint.Z;
    Pos = new XYZ(x, y, z);
    }
    }
    else
    {
    any message
    }

  6. Kailash Kute Avatar
    Kailash Kute

    hi jeremy,
    Regards for the day,
    i am able to cut the pipe at the specified distance but the rest of the pipe is getting removed or deleted which i want for connecting it to coupling.
    public virtual Autodesk.Revit.UI.Result Execute ( ExternalCommandData commandData
    , ref string message, Autodesk.Revit.DB.ElementSet elements )
    {
    try
    {
    _rvtApp = commandData.Application;
    _uidoc = _rvtApp.ActiveUIDocument;
    _app = _rvtApp.Application;
    _rvtDoc = _uidoc.Document;
    // Process[ ] processlist = Process.GetProcesses();
    // Verify if the active document is null
    UIDocument activeDoc = commandData.Application.ActiveUIDocument;
    if (activeDoc == null)
    {
    // MessageBox.Show(“There’s no active document in Revit.”, “No Active Document”,
    // MessageBoxButtons.OK, MessageBoxIcon.Warning);
    return Autodesk.Revit.UI.Result.Failed;
    }
    // Verify the number of selected elements
    Autodesk.Revit.UI.Selection.SelElementSet selElements = activeDoc.Selection.Elements;
    //FamilyInstance f = null;
    foreach (Element elem in selElements)
    {
    if (elem is Pipe)
    {
    eid = elem.Id;
    Type type = elem.GetType ( );
    t = elem.GetType();
    LocationCurve lc = elem.Location as LocationCurve;
    XYZ startPoint = lc.Curve.get_EndPoint ( 0 );
    XYZ endPoint = lc.Curve.get_EndPoint ( 1 );
    Double lenOfPipe = GetLength ( startPoint, endPoint );
    double angleinDegree = getAngle ( startPoint,endPoint);
    k1 = startPoint.X;
    k2 = startPoint.Y;
    k3 = startPoint.Z;
    // below is used for placing a coupling in the respective quadrant
    if (angleinDegree = 0)
    {
    if (!endPoint.X.ToString().Contains(“-“))// !startPoint.X.ToString().Contains(“-“) && !startPoint.Y.ToString().Contains(“-“))
    {
    //1 Quadrant
    //MessageBox.Show(“1st condition”);
    x = startPoint.X + 6 * Math.Cos(angle);
    y = startPoint.Y + 6 * Math.Sin(angle);
    z = startPoint.Z;
    Pos = new XYZ(x, y, z);
    }
    else
    {
    //MessageBox.Show(“2 condition”);
    //3 Quadrant
    x = startPoint.X – 6 * Math.Cos(angle);
    y = startPoint.Y – 6 * Math.Sin(angle);
    z = startPoint.Z;
    Pos = new XYZ(x, y, z);
    }
    }
    else if (angleinDegree = -90)
    {
    if (!endPoint.Y.ToString().Contains(“-“))
    {
    //2 Quadrant
    //MessageBox.Show(“3 condition”);
    x = startPoint.X – 6 * Math.Cos(angle);
    y = startPoint.Y – 6 * Math.Sin(angle);
    z = startPoint.Z;
    Pos = new XYZ(x, y, z);
    //angle = (-angle);
    }
    else
    {
    //4 Quadrant
    //MessageBox.Show(“4 condition”);
    x = startPoint.X + 6 * Math.Cos(angle);
    y = startPoint.Y + 6 * Math.Sin(angle);
    z = startPoint.Z;
    Pos = new XYZ(x, y, z);
    //angle = (-angle);
    }
    }
    else
    {
    }
    myangle = (90 – angleinDegree);
    newangleinradian = myangle * Math.PI / 180;
    strtpnt = startPoint;
    endpnt = endPoint;
    }
    }
    Previw objPreview = new Previw ( );
    objPreview.ShowDialog ( );
    if (objPreview.familyName != String.Empty)
    {
    AddFamilytoApplication ( objPreview.familyName );
    }
    Transaction trans = new Transaction ( _rvtDoc, “Load” );
    trans.Start ( );
    Autodesk.Revit.DB.Structure.StructuralType structureType = Autodesk.Revit.DB.Structure.StructuralType.NonStructural;
    FamilyInstance f = _rvtDoc.Create.NewFamilyInstance(Pos, (FamilySymbol)(m_familySymbolList[0]), structureType);
    #region for test
    // below code is used to put the connector and break the pipe but it is deleting rest of the pipe
    ConnectorSet connector = f.MEPModel.ConnectorManager.Connectors;
    Connector cntr = null;
    foreach (Connector cntrs in connector)
    {
    cntr = cntrs;
    }
    foreach (Element elem in selElements)
    {
    if (elem is Pipe)
    {
    Pipe pipe = (Pipe)_rvtDoc.get_Element(elem.Id);
    double len = GetLength(strtpnt, endpnt);
    connector = pipe.ConnectorManager.Connectors;
    }
    }
    Connector pipeend = null;
    double dist = double.MaxValue;
    foreach (Connector contrs in connector)
    {
    XYZ p = contrs.Origin;
    double d = p.DistanceTo(endpnt);
    if (d < dist)
    {
    dist = d;
    pipeend = contrs;
    }
    break;
    }
    cntr.ConnectTo(pipeend);
    #endregion
    // statrt here
    // below code is used to place the coupling in a proper angle on the pipe with respect to pipe
    bool rotated = false;
    XYZ aa = Pos;
    XYZ cc = new XYZ(aa.X, aa.Y, aa.Z + 6);
    Line axis = _rvtApp.Application.Create.NewLineBound(aa, cc);
    rotated = _rvtDoc.Rotate(f, axis, angle);
    _uidoc.Selection.Elements.Add(f);
    // end here
    //below code is used to resolve the cut or defects in joints of pipe and connector
    #region for resolve
    Resolver objpres = new Resolver(commandData);
    objpres.Resolve();
    #endregion
    trans.Commit ( );
    #region For Connectors
    #endregion
    return Autodesk.Revit.UI.Result.Succeeded;
    }
    catch (Exception ex)
    {
    message = ex.Message;
    return Autodesk.Revit.UI.Result.Failed;
    }
    }
    any help appreciated
    thanks
    kailash

  7. Dear Kailash,
    I am glad that you found the first answer helpful.
    I cannot say much about the code that you sent, I’m afraid … I am not a computer myself, you know :-)
    To get us a bit more synchronised again, or rather to try catching up with you, I at least published the first solution that I provided to you:
    http://thebuildingcoder.typepad.com/blog/2011/04/use-of-newtakeofffitting-on-a-pipe.html
    Maybe that will provide a better place to continue this discussion.
    Please let me know how you get on with this. Thank you!
    Cheers, Jeremy.

  8. Kailash Kute Avatar
    Kailash Kute

    i used the above code of your’s published in http://thebuildingcoder.typepad.com/blog/2011/02/create-a-pipe-cap.html.
    now my coupling is getting placed but my rest of the pipe is getting deleted which i want for further process how to get that.
    regards
    kailash

  9. Kailash Kute Avatar
    Kailash Kute

    HI jeremy,
    Regards for the day,
    i have placed 3 coupling at 6 inch distance respectively on 20 inch pipe now my coupling and pipe is at proper angle now only one thing is remaining that is to break the pipe at position where my coupling resides but i used u r pipe cap code it deleted the rest of pipe just let me know how to put one coupling on a pipe and breaking pipe into two pieces
    rest i will complete
    Thanks
    kailash kute

  10. Kailash Kute Avatar
    Kailash Kute

    one more thing i would like to know how i will be able to set the family instance host property.
    regards
    kailash kute

  11. Kailash Kute Avatar
    Kailash Kute

    hi sir,
    warm regards for the day
    i want to put a family instance into combinable element how to do that
    in below line i am getting family instance in elemItr
    but when i check ce i get as null
    CombinableElement ce = (Element)elemItr.Current as CombinableElement;
    i just want to put the combinale element in combinableelementarray
    Thanks
    Kailash

  12. Dear Kailash,
    Look at the CombinableElement in the Revit API help file. It is a base class for GenericForm and GeomCombination. If your selected element is not one of these two, the cast will return null.
    Cheers, Jeremy.

  13. Dear Kailash,
    Possibly the host can only be specified in the call to the NewFamilyInstance method at the time of creation of the new family instance.
    Cheers, Jeremy.

  14. Kailash Kute Avatar
    Kailash Kute

    Hi sir
    Warm Regards for the day
    i just want to know
    how to get an single element as selected element programmatically
    Thanks
    Kailash Kute

  15. Dear Kailash,
    How about PickObject?
    It is amply documented in the Revit API help file RevitAPI.chm, the developer guide, the SDK samples, The Building Coder samples, and a number of blog posts.
    Cheers, Jeremy.

  16. Kailash Kute Avatar
    Kailash Kute

    Hi Sir,
    Greetings for the day,
    i have completed my basic task of placing a coupling over pipe at distance 6″ Depending on length of pipe. so that many couplings get added also my pipe is breaking.
    well under guidance of our sir i changed my approach of coding now i am rather than breaking pipe i am creating new pipe in between couplings. but i must mentioned all was possible because of this Blog posts and your replies which gave me basic idea what is revit programming about thanks for creating such a blog. :)
    also now i am going for enhancements in my task for that i will be sending u my queries if any
    Thanks
    Kailash Kute

  17. Dear Kailash,
    Thank you very much for letting us know, and many congratulations on successfully resolving this complex task!
    If you would like to share a simplified version of your final code, that might be of interest to others as well.
    Best regards and Happy Easter to you!
    Cheers, Jeremy.

  18. Kailash Kute Avatar
    Kailash Kute

    hi sir,
    regards for the day
    well i want to reduce the diameter of family instance(coupling) programmatically i saw the code in pdf file but it gives me an error of transaction in my above project which we are discussing on this page i tried to change through coding but still getting error also i like to ask that can we assign the look up table to this family instance created dynamically if yes then how
    thanks
    kailash kute

  19. Kailash Kute Avatar
    Kailash Kute

    hi sir,
    regards for the day.
    actually as per the diameter of pipe my coupling that is family instance diameter should be set. for 6″ coupling diameter should be 6″ for 8″ pipe it should be 8″. well right now when i placed my all coupling on pipe. i get all couplings of 8″ now one of my pipe is 6″ in the drawing. so by design view with the help of lookup table i am able to change the diameter of my coupling to 6″. but the task is like it should be done programmatically automatically it should accept the diameter of pipe.
    i done whole thing inside one transaction but no success. it is giving me an error that is “”A transaction or sub-transaction was opened but not closed. All changes to the active document made by External Command will be discarded.””
    your guidance appreciated needed
    Thanks in advance
    Kailash kute

  20. Kailash Kute Avatar
    Kailash Kute

    hello sir,
    greetings,
    well i came to know that we don’t have to change any couplings diameter we just have to change the size of a coupling as per the diameter of pipe. but now how to change the size of coupling dynamically is a big task.
    any suggesstion.
    regards
    kailash kute

  21. Hello Sir,
    Greetings for the day,
    can i assign lookuptable in revit mep 2012 to a family instance programmtically so it will load the family instance in my project according to the pipe size
    Regards’
    Kailash kute

  22. kailash n kute Avatar
    kailash n kute

    hi sir,
    greetings for the day
    finally i have changed the diameter of my family instance (coupling) programmatically… well diameter doesnt worked for me. so i tried changing its nominal radius and guess what it worked…
    great na
    Regards
    Kailash Kute

  23. Dear Kailash Kute,
    Many congratulations on getting this to work. Have you seen the handling of the diameter parameters demonstrated by the pipe to conduit converter?
    http://thebuildingcoder.typepad.com/blog/2010/05/pipe-to-conduit-converter.html
    Are you using the same approach?
    If you would care to share your solution with us, I will be glad to publish it! Thank you!
    Cheers, Jeremy.

  24. Kailash Kute Avatar
    Kailash Kute

    hello sir,
    Greetings for the day
    i have applied following logic for changing coupling diameter programmatically the logic is below
    below are the comments
    Parameter couplingnominalradius = ficoupling.get_Parameter(“Nom Radius”);
    double piperadius = selectedpipediameter / 2;
    couplingnominalradius.Set(piperadius);
    here selectedpipediameter is my pipe diameter.
    Regards
    Kailash kute

  25. Dear Kailash,
    Thank you very much for the explanation. It looks good to me. I am glad it is working for you now.
    Cheers, Jeremy.

  26. Kailash Kute Avatar
    Kailash Kute

    hello sir,
    greetings for the day.
    well final thing remaining in my solution to implement is joining the pipe and couplings programmatically.
    i read the link
    http://thebuildingcoder.typepad.com/blog/2010/05/autojoinelements.html
    and i found it very useful, i came to know how to implement the regeneration and autojoin.
    also i went through the zip file AecDevCamp2010-RevitPerformanceTipsTricks.zip where i came to know how to implement in program.
    still my pipe and couplings are not getting joined in it
    i am applying it before return succeeded also my transaction and regeneration is manual
    Regards
    Kailash Kute

  27. Kailash Kute Avatar
    Kailash Kute

    Dear Sir,
    well my question to you is
    1> can i change the hanger’s vertical rod, length programmatically i want to extend it to the height of ceiling.
    2> can i change the diameter of hanger programmatically if user adds the insulation to the pipe,, after placing hanger the diameter of hanger should change if yes then which is the best event to do that
    Regards
    Kailash Kute

  28. Kailash Kute Avatar
    Kailash Kute

    hello sir,
    can i create a insulation over a pipe programmatically
    in revit mep 2012 if yes then how.
    Regards
    Kailash kute

  29. Dear Kailash,
    As always, I would suggest exploring that yourself by
    1. creating the desired situation manually through the user interface, then
    2. analysing what elements were added by that operation and what their properties are.
    Approaches are described in many places, e.g.
    http://thebuildingcoder.typepad.com/blog/2008/11/exploring-element-parameters.html
    http://thebuildingcoder.typepad.com/blog/2009/11/title-block-of-sheet.html
    I hope this helps.
    Cheers, Jeremy.

  30. Dear Kailash,
    In Revit 2012, the new PipeInsulation class and related types support read, write and create access to pipe insulation. These objects are accessible as standalone elements related to their parent pipe or fitting. I hope this helps.
    Cheers, Jeremy.

  31. Kailash Kute Avatar
    Kailash Kute

    Hi Sir,
    Greetings for the day.
    thanks for reply i went through the links and insulation class you mentioned…., great Help from that.
    well i placed the hanger over a pipe programmatically also diameter has been changed with respect to pipe insulation ,also i changed the vertical rod length accordingly by looking at properties ,well adding a pipe insulation dynamically has been removed from my solution because Revit Mep 2012 gives us that facility.
    Best Regards
    Kailash Kute

  32. Dear Kailash,
    A little additional note on this:
    Of course it would be better to use a built-in parameter enumeration value to identify it rather than the language dependent name string “Nom Radius”.
    Cheers, Jeremy.

  33. Dear Kailash,
    Wow, congratulations! Sounds as if you are all sorted, then.
    Cheers, Jeremy.

  34. Dear Kailash,
    Sorry for not responding to some of your comments!
    Did you solve this issue, or any of the other ones that I have not yet answered?
    If so, I would be interested in hearing about the solution you found.
    The most wonderful thing would be if you would like to summarise some of the results that you have achieved in your numerous investigations, and publish them as a guest blog post.
    Thank you!
    Cheers, Jeremy.

  35. Kailash Kute Avatar
    Kailash Kute

    hi sir,
    greetings for the day,
    how to get the angle of a pipe which is placed above the ceiling ,i am getting BasisX angle as 90 degree only.but actual i drawn is 45 degree.
    how to retrieve the slanting pipe angle when ceiling is added
    Regards
    Kailash kute

  36. Dear Kailash,
    It sounds to me as if you are trying to retrieve the angle of the pipe itself. Is that correct?
    Furthermore, it sounds to me as if you are trying to obtain its angle from one of its connectors, yes?
    Well, the first suggestion I can make is that a pipe is a curve driven element, and therefore the value of its Location property should be a LocationCurve with an underlying geometry line which should provide the pipe start and end points.
    From those, you can easily determine the angle.
    Alternatively, if you prefer working from the connectors only, how about simply determining the pipe start and end points from the connector locations, and again using those two points to determine the angle?
    Cheers, Jeremy.

  37. Kailash Kute Avatar
    Kailash Kute

    hi sir,
    well i am considering startpoint and endpoint for the angle retrievation of pipe.
    how to place the hanger over the slanted pipe in between structural floor as i am placing over the horizontal pipe it is working fine
    but for slanting it is not working.
    when i debug my solution i came to know that for horizontal as well as for slanting pipe when i retrieve angle i am getting 90 degree.
    is there any solution to get actual angle for the slanting pipe in between floors.
    Regards
    Kailash kute

  38. Dear Kailash,
    Are you telling me that the location curve of a slanted pipe does not include the slope angle?
    I find that very hard to believe!
    Cheers, Jeremy.

  39. Kailash Kute Avatar
    Kailash Kute

    Hi Sir,
    Thanks for giving me the idea of slope angle i was not aware of this slope angle. which i got in built in parameters now i got that angle.
    Thank you so much
    Regards
    Kailash Kute

  40. Kailash Kute Avatar
    Kailash Kute

    Hi Sir,
    In Revit API 2012 how to retrieve the start point and end point of the Family Instance — Elbow.
    that is both the XYZ points of Elbow where it is having Opening.
    i need this points because i want to place a Coupling on this XYZ locations.
    Regards
    Kailash kute

  41. Dear Kailash,
    I would suggest using the connectors and their location points for this.
    Cheers, Jeremy.

  42. Kailash Kute Avatar
    Kailash Kute

    hi sir,
    Greetings for the day
    as you suggested i followed using connectors.
    well i got the connectors of elbow and i placed my coupling on that location but after addition of coupling my elbow got lost from the document don’t know how.any idea why this is happening also is there any property to make that elbow fix in my document so it wont get deleted from my application.
    Regards
    Kailash kute

  43. Kailash Kute Avatar
    Kailash Kute

    Hi Sir,
    Greetings for the day
    well by studying on your blog in the link http://thebuildingcoder.typepad.com/blog/2011/02/create-a-pipe-cap.html
    i came to know about filtered element collector
    well i used your logic now i am able to select the specific elements without selecting by mouse
    below is my code for selecting Pipe,Floor,Level without selecting it by mouse.
    and i am able to union them together in one list
    elemList = AddSelectionSet(selElements);
    FilteredElementCollector myCollector1 = new FilteredElementCollector(commandData.Application.ActiveUIDocument.Document);
    FilteredElementCollector myCollector2 = new FilteredElementCollector(commandData.Application.ActiveUIDocument.Document);
    FilteredElementCollector myCollector3 = new FilteredElementCollector(commandData.Application.ActiveUIDocument.Document);
    if (elemList.Count == 0)
    {
    myCollector1.OfClass(typeof(Pipe));
    myCollector2.OfClass(typeof(Floor));
    myCollector3.OfClass(typeof(Level));
    myCollector1.UnionWith(myCollector2);
    myCollector1.UnionWith(myCollector3);
    elemList = myCollector1.ToElements();
    }
    else
    {
    }
    then in elemList i get all the elements with which i proceed further for processing
    Regards
    Kailash kute

  44. Dear Kailash,
    I am glad you found a working solution and that the blog post was helpful.
    There is an easier way, actually, than creating three separate collectors and creating a union of their results.
    You can also create three ElementClassFilter instances for the pipes, floors and levels, and then unite them using a LogicalOrFilter as demonstrated in
    http://thebuildingcoder.typepad.com/blog/2010/06/retrieve-mep-elements-and-connectors.html
    For an overview of more filtered element collector examples, please refer to
    http://thebuildingcoder.typepad.com/blog/2010/12/filtered-element-collector-sample-overview.html
    Cheers, Jeremy.

  45. Kailash Kute Avatar
    Kailash Kute

    hi sir
    thanks for replying i got my code reduced because of that.
    Regards
    Kailash kute

  46. Kailash Kute Avatar
    Kailash Kute

    Hi Sir,
    Greetings for the day
    i have placed hanger over the pipe at specified distance now the hangers vertical rod get lengthen till above roof but my hangers are not associative with the pipe. if i drag hanger they get moved i want them to be joined with the pipe can i make them associative.
    if yes how to do that ?
    regards
    Kailash kute

  47. Dear Kailash,
    That is an interesting problem. Yes, you can implement your own associative behaviour using the DMU or Dynamic Model Update.
    http://thebuildingcoder.typepad.com/blog/2010/04/element-level-events.html#2
    Here is an RST sample:
    http://thebuildingcoder.typepad.com/blog/2010/08/structural-dynamic-model-update-sample.html
    Cheers, Jeremy.

  48. Kailash Kute Avatar
    Kailash Kute

    Hi sir,
    Greetings for the day.
    1> hangers are placed over the pipe
    2> now i add insulation over it
    i want to fire my addin as soon as user changes the pipe insulation or adds it, the hanger diameter or nominal radius should change.
    can i do this but which will be the better event to do this.
    i am not getting anything.
    Regards
    Kailash Kute

  49. Dear Kailash,
    Have a look at DMU, the Dynamic Model Update framework.
    Cheers, Jeremy.

  50. Kailash Kute Avatar
    Kailash Kute

    Hi Sir,
    Greetings for the day
    my pipe is in slanting position in between structural floors, but my hangers are still getting placed vertically but not on pipe, i want my hangers to be placed on pipe also slanted according to the pipe angle, i have the parameter BuiltInParameter.RBS_PIPE_SLOPE. where i get the angle in radians of the pipe. now if i add hanger over the pipe with this slope angle they get placed very nearby.
    Any link or solution
    Regards
    Kailash Kute

Leave a Reply

Discover more from Autodesk Developer Blog

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

Continue reading