[摘要] ****其实在revit里是不存在分割族的概念。对于基于线形的族,截面沿线都是一样,要想达到分割的状态,只需要把族基于线的那条线变短,
****
其实在revit里是不存在分割族的概念。
对于基于线形的族,截面沿线都是一样,要想达到分割的状态,只需要把族基于线的那条线变短,然后再在分割点复制一个新的族即可。
过程是先获得线的均分点,然后把族的线缩短,接着再复制族,即可变成均分的效果。主要方法见代码:
private void DevideFamilyInstance(FamilyInstance famIns,int n, Document revitDoc) { LocationCurve locationCurve = famIns.Location as LocationCurve; XYZ stratPoint = locationCurve.Curve.GetEndPoint(0); XYZ endPoint = locationCurve.Curve.GetEndPoint(1); IList<XYZ> devidePoint = InsertPoint(stratPoint, endPoint,n); Transaction transaction = new Transaction(revitDoc); transaction.Start("将族复制到相应位置"); locationCurve.Curve = Line.CreateBound(stratPoint, devidePoint[0]); List<ElementId> list = new List<ElementId>(); list.Add(famIns.Id); ICollection<ElementId> elementIds = list; for (int j=1;j<n;j++) { XYZ tanslation = new XYZ(devidePoint[j - 1].X - stratPoint.X, devidePoint[j - 1].Y - stratPoint.Y, devidePoint[j - 1].Z - stratPoint.Z); ElementTransformUtils.CopyElements(revitDoc, elementIds, tanslation); } transaction.Commit(); } private List<XYZ> InsertPoint(XYZ stratPoint, XYZ endPoint,int n) { List<XYZ> listPoint = new List<XYZ>(); double x, y, z; for(int i=1;i<n;i++) { x = stratPoint.X+(endPoint.X- stratPoint.X)*i/n; y = stratPoint.Y + (endPoint.Y - stratPoint.Y) * i / n; z= stratPoint.Z + (endPoint.Z - stratPoint.Z) * i / n; XYZ point = new XYZ(x,y,z); listPoint.Add(point); }