In Revit, the concept of dividing families does not exist.
For families based on linear shapes, the cross-section remains consistent along the entire line. To segment such a family, you simply shorten the original line and then duplicate the family at the division points.
The general workflow involves first calculating evenly spaced points along the line, then shortening the family’s line accordingly, and finally copying the family instances to create evenly distributed segments. Below is a sample implementation in C#:
private void DevideFamilyInstance(FamilyInstance famIns, int n, Document revitDoc)
{
LocationCurve locationCurve = famIns.Location as LocationCurve;
XYZ startPoint = locationCurve.Curve.GetEndPoint(0);
XYZ endPoint = locationCurve.Curve.GetEndPoint(1);
IList<XYZ> dividePoints = InsertPoint(startPoint, endPoint, n);
Transaction transaction = new Transaction(revitDoc);
transaction.Start("Copy family instances to specified locations");
locationCurve.Curve = Line.CreateBound(startPoint, dividePoints[0]);
List<ElementId> elementIdsList = new List<ElementId> { famIns.Id };
ICollection<ElementId> elementIds = elementIdsList;
for (int j = 1; j < n; j++)
{
XYZ translation = new XYZ(
dividePoints[j - 1].X - startPoint.X,
dividePoints[j - 1].Y - startPoint.Y,
dividePoints[j - 1].Z - startPoint.Z
);
ElementTransformUtils.CopyElements(revitDoc, elementIds, translation);
}
transaction.Commit();
}
private List<XYZ> InsertPoint(XYZ startPoint, XYZ endPoint, int n)
{
List<XYZ> points = new List<XYZ>();
for (int i = 1; i < n; i++)
{
double x = startPoint.X + (endPoint.X - startPoint.X) * i / n;
double y = startPoint.Y + (endPoint.Y - startPoint.Y) * i / n;
double z = startPoint.Z + (endPoint.Z - startPoint.Z) * i / n;
XYZ point = new XYZ(x, y, z);
points.Add(point);
}
return points;
}
xuebim
Follow the latest BIM developments in the architecture industry, explore innovative building technologies, and discover cutting-edge industry insights.
← Scan with WeChat













Must log in before commenting!
Sign Up