Simpler Rolling Offset Using NewElbowFitting

I continue the work on my MEP CASE BIM Hackathon project to calculate a rolling offset between two pipes, insert the rolling offset pipe segment, connect it to its neighbours and explicitly placing elbow fittings.

The explicit fitting placement was pretty hard and fiddly to implement, requiring the following steps:

It worked, but only after a lot of research and effort.

As pointed out by Tate in the comment on connecting the rolling offset pipe to its neighbours, almost all that effort can be avoided by using the NewElbowFitting method instead. It selects, creates, adapts, places and connects an elbow fitting automatically, with the additional advantage of taking all the Revit pipe routing preferences and other settings into account.

We touched on the topic of new fitting creation methods now and then in the past, but never presented an example using NewElbowFitting in context like this, so it is actually rather overdue:

Rolling Offset Fitting Placement Using NewElbowFitting

I expanded my previous code that calculates and places the rolling offset pipe segment.

Last time I discussed it, it connected a pipe directly to the neighbouring original pipes with no fittings in between.

To make use of NewElbowFitting, I simply replaced the code hooking up the connectors by six new lines that (twice) select the appropriate connector pairs and invoke the method like this:

  pipe = doc.Create.NewPipe( q0, q1,
    pipe_type_standard );
  pipe.get_Parameter( bipDiameter )
    .Set( diameter );
  // Connect rolling offset pipe segment
  // directly with the neighbouring original
  // pipes
  //Util.Connect( q0, pipes[0], pipe );
  //Util.Connect( q1, pipe, pipes[1] );
  // NewElbowFitting performs the following:
  // - select appropriate fitting family and type
  // - place and orient a family instance
  // - set its parameters appropriately
  // - connect it with its neighbours
  Connector con0 = Util.GetConnectorClosestTo(
    pipes[0], q0 );
  Connector con = Util.GetConnectorClosestTo(
    pipe, q0 );
  doc.Create.NewElbowFitting( con0, con );
  Connector con1 = Util.GetConnectorClosestTo(
    pipes[1], q1 );
  con = Util.GetConnectorClosestTo(
    pipe, q1 );
  doc.Create.NewElbowFitting( con, con1 );

As you can see, all the questionable hard-coded calculations required to explicitly place the fittings are now eliminated.

The resulting model looks exactly the same as the one presented yesterday, generated by explicitly placing the elbow fittings.

The new method to place the elbow fittings and properly connect the rolling offset is included in The Building Coder samples GitHub repository, in the external command CmdRollingOffset, and the version discussed here is release 2014.0.106.5.

That just about concludes this project, except for the question on how to use Pipe.Create instead of Document.Create.NewPipe, which is still open.