Rotation Adjusts and Fixes Conduit End

Quite a while ago, I listed a bunch of possible approaches to refresh element graphics display.

Here comes a new one to join the gang:

Applying Element Rotation to Adjust and Fix Conduit End

Question: I am creating a series of several conduit elements.

One conduit is in a different size and conduit type.

When I modify the conduit diameters before the elbow is created, one of the conduit ends exceeds the elbow.

The observed result looks like this:

Conduit end extending too far

I am expecting it to look like this:

Conduit end adjusted

If I remove the code to set the different size and type, and change diameters as usual, then this issue does not appear.

Answer by Paolo Serra: This happened to me as well on pipes and valves.

I fixed this after the fitting creation by applying a call to ElementTransformUtils.Rotate to the family instance, passing in a zero radians angle.

usingTransaction trans = new Transaction( doc ) )
{
  trans.Start( "虚假旋转线管" );
  var ids = conduits.Select( c => c.Id ).ToList();
  var axis = Line.CreateBound( XYZ.Zero, XYZ.BasisX );
  ElementTransformUtils.RotateElements( doc, ids, axis, 0 );
  trans.Commit();
}