Hi everyone,
I am trying to get to center point of an elbow. I have check all the data of the elbow from Revit Lookup tool but did not find anything. So is there anyway I can get that information ?
Thank you so much for your help 😊
Best Regards,
Sino
Solved! Go to Solution.
Solved by jeremytammik. Go to Solution.
Yes.
This is a pretty simple geometrical exercise.
You have the full information about the start and end point, specifically including location and direction == face normal.
The start and end point directions are not parallel. Therefore, they define a 2D plane. The centre point will normally lie in that plane, so you just have a (simpler) 2D task to solve, not 3D.
In the 2D plane, you can determine the normal vector to the start and end directions. Extend those two normal vectors to define infinite lines and determine their intersection. That is your centre point.
Dear @jeremytammik ,
Thank you for your answer. But I just finally find out that actually the elbow has the center point information under the Geometry information:
So my working code is:
static public XYZ GetCenterofElbow (FamilyInstance selectedDuct)
{
XYZ output = null;
List<Connector> allConnectors = selectedDuct.MEPModel.ConnectorManager.Connectors.Cast<Connector>().ToList();
Connector connectorA = allConnectors[0];
Connector connectorB = allConnectors[0];
GeometryElement geometryElement = selectedDuct.get_Geometry(new Options());
List<GeometryInstance> ginsList = selectedDuct.get_Geometry(new Options()).Where(o => o is GeometryInstance).Cast<GeometryInstance>().ToList();
foreach (GeometryInstance gins in ginsList)
{
foreach (GeometryObject ge in gins.GetInstanceGeometry())
{
try
{
Arc centerArc = ge as Arc;
output = centerArc.Center;
}
catch (Exception)
{
}
}
}
return output;
}
Thank you for letting us know that simple solution!
Oh dear. I wasted some effort, then.
I implemented a geometrical solution for you based on the elbow connectors and their coordinate systems:
/// <summary>
/// Return elbow connectors.
/// Return null if the given element is not a
/// family instance with exactly two connectors.
/// </summary>
List<Transform> GetElbowConnectors( Element e )
{
List<Transform> xs = null;
FamilyInstance fi = e as FamilyInstance;
if( null != fi )
{
MEPModel m = fi.MEPModel;
if( null != m )
{
ConnectorManager cm = m.ConnectorManager;
if( null != cm )
{
ConnectorSet cs = cm.Connectors;
if( 2 == cs.Size )
{
xs = new List<Transform>( 2 );
bool first = true;
foreach( Connector c in cs )
{
if( first )
{
xs[0] = c.CoordinateSystem;
}
else
{
xs[1] = c.CoordinateSystem;
}
}
}
}
}
}
return xs;
}
/// <summary>
/// Return elbow centre point.
/// Return null if the start and end points
/// and direction vectors are not all coplanar.
/// </summary>
XYZ GetElbowCentre( Element e )
{
XYZ pc = null;
List<Transform> xs = GetElbowConnectors( e );
if( null != xs )
{
// Get start and end point and direction
XYZ ps = xs[ 0 ].Origin;
XYZ vs = xs[ 0 ].BasisZ;
XYZ pe = xs[ 1 ].Origin;
XYZ ve = xs[ 1 ].BasisZ;
XYZ vd = pe - ps;
// For a regular elbow, Z vector is normal
// of the 2D plane spanned by the coplanar
// start and end points and direction vectors.
XYZ vz = vs.CrossProduct( vd );
if( !vz.IsZeroLength() )
{
XYZ vxs = vs.CrossProduct( vz );
XYZ vxe = ve.CrossProduct( vz );
pc = Util.LineLineIntersection(
ps, vxs, pe, vxe );
}
}
return pc;
}
Would you like to test my code and see whether it returns the same result?
Thank you!
Hi,
there may be elbow families which consist of two 45°-segments, connected by a cylindrical part between them.
In this case, there would be two arcs with different center points, so the connector based approach seems more flexible for different family content.
Revitalizer
Hi,
for example:
Source: https://www.ofenseite.com/1020147-pelletofenrohr-90-bogen-mit-kesselanschluss-muffe
Revitalizer
In this case, there isn't any arc at all.
Dear @jeremytammik and @Revitalizer ,
Thank you so much for your great solution. I am very appreciate your kindly help 😊
Thank you for your appreciation, and many thanks to Revitalizer for the nice example!
My code would solve the task for that as well.
Please confirm that it works.
I have not tested it myself.
Thank you!
Can't find what you're looking for? Ask the community or share your knowledge.