public TrussInfo CreateTrussInfo(Document doc, XYZ currentPointOnHip, EdgeInfo currentRidgeEdgeInfo, Element firstSupport, Element secondSupport, TrussType tType) { TrussInfo currentTrussInfo = TrussInfo.BuildTrussAtHip(currentPointOnHip, currentRidgeEdgeInfo, firstSupport, secondSupport); using (Transaction t = new Transaction(doc, "Criar treliça")) { t.Start(); if (currentTrussInfo != null) { SketchPlane stkP = SketchPlane.Create(doc, currentRidgeEdgeInfo.CurrentRoof.LevelId); double levelHeight = currentRidgeEdgeInfo.GetCurrentRoofHeight(); XYZ firstPoint = new XYZ(currentTrussInfo.FirstPoint.X, currentTrussInfo.FirstPoint.Y, levelHeight); XYZ secondPoint = new XYZ(currentTrussInfo.SecondPoint.X, currentTrussInfo.SecondPoint.Y, levelHeight); Truss currentTruss = Truss.Create(doc, tType.Id, stkP.Id, Line.CreateBound(firstPoint, secondPoint)); currentTruss.get_Parameter(BuiltInParameter.TRUSS_HEIGHT).Set(currentTrussInfo.Height); } t.Commit(); } //DEBUG.CreateDebugPoint(doc, currentPointOnHip); return(currentTrussInfo); }
public TrussInfo CreateTrussFromRidgeWithSupports(XYZ currentPointOnRidge, EdgeInfo currentRidgeEdgeInfo, TrussType tType, Line support0, Line support1) { TrussInfo currentTrussInfo = null; Document doc = currentRidgeEdgeInfo.CurrentRoof.Document; if (doc == null) { return(currentTrussInfo); } IList <XYZ> currentSupportPoints = new List <XYZ>(); double roofheight = currentRidgeEdgeInfo.GetCurrentRoofHeight(); Line currentRidgeLineFlatten = (currentRidgeEdgeInfo.Curve as Line).Flatten(roofheight); if (currentRidgeLineFlatten == null) { return(currentTrussInfo); } XYZ crossDirection = currentRidgeLineFlatten.Direction.CrossProduct(XYZ.BasisZ); XYZ currentPointOnRidgeFlatten = new XYZ(currentPointOnRidge.X, currentPointOnRidge.Y, roofheight); Line currentCrossedLineInfinite = Line.CreateBound(currentPointOnRidgeFlatten, currentPointOnRidgeFlatten.Add(crossDirection)); currentCrossedLineInfinite.MakeUnbound(); if (support0 != null) { IntersectionResultArray iResultArr = new IntersectionResultArray(); SetComparisonResult iResulComp = currentCrossedLineInfinite.Intersect(support0.Flatten(roofheight), out iResultArr); if (iResultArr != null && iResultArr.Size == 1) { currentSupportPoints.Add(iResultArr.get_Item(0).XYZPoint); } } if (support1 != null) { IntersectionResultArray iResultArr = new IntersectionResultArray(); SetComparisonResult iResulComp = currentCrossedLineInfinite.Intersect(support1.Flatten(roofheight), out iResultArr); if (iResultArr != null && iResultArr.Size == 1) { currentSupportPoints.Add(iResultArr.get_Item(0).XYZPoint); } } using (Transaction t = new Transaction(doc, "Criar treliça")) { t.Start(); currentTrussInfo = CreateTrussInfo(doc, currentPointOnRidge, currentRidgeEdgeInfo, currentSupportPoints, tType); t.Commit(); } return(currentTrussInfo); }
/// <summary> /// Creates trusses along a specific ridge edge and stores them on a list of truss info /// </summary> /// <param name="currentRidgeEdgeInfo">The specific edge ridge to create trusses</param> /// <param name="doc">The target document to create the trusses</param> /// <param name="tType">The target truss type to be used on creation</param> /// <returns>The list of info of the created trusses</returns> private IList <TrussInfo> CreateTrussInfoList(EdgeInfo currentRidgeEdgeInfo, Document doc, TrussType tType) { IList <TrussInfo> trussInfoList = new List <TrussInfo>(); if (currentRidgeEdgeInfo.RoofLineType == RoofLineType.RidgeSinglePanel || currentRidgeEdgeInfo.RoofLineType == RoofLineType.Ridge) { Line currentRidgeLineShortenedBySupports = currentRidgeEdgeInfo.Curve as Line; if (currentRidgeLineShortenedBySupports == null) { return(trussInfoList); } IList <EdgeInfo> startConditions = currentRidgeEdgeInfo.GetEndConditions(0); IList <EdgeInfo> endConditions = currentRidgeEdgeInfo.GetEndConditions(1); currentRidgeLineShortenedBySupports = ShortenRidgeIfNecessary(currentRidgeLineShortenedBySupports, startConditions, endConditions); Tuple <int, double> iterations = Utils.Utils.EstabilishIterations(currentRidgeLineShortenedBySupports.ApproximateLength, trussDistance); int numPoints = iterations.Item1; double distance = iterations.Item2; for (int i = 0; i <= numPoints; i++) { double currentParam = i * distance; XYZ currentPointOnRidge = currentRidgeLineShortenedBySupports.Evaluate(currentRidgeLineShortenedBySupports.GetEndParameter(0) + currentParam, false); TrussInfo currentTrussInfo = TrussInfo.BuildTrussAtRidge(currentPointOnRidge, currentRidgeEdgeInfo, null); if (currentTrussInfo != null) { SketchPlane stkP = SketchPlane.Create(doc, currentRidgeEdgeInfo.CurrentRoof.LevelId); double levelHeight = currentRidgeEdgeInfo.GetCurrentRoofHeight(); XYZ firstPoint = new XYZ(currentTrussInfo.FirstPoint.X, currentTrussInfo.FirstPoint.Y, levelHeight); XYZ secondPoint = new XYZ(currentTrussInfo.SecondPoint.X, currentTrussInfo.SecondPoint.Y, levelHeight); Truss currentTruss = Truss.Create(doc, tType.Id, stkP.Id, Line.CreateBound(firstPoint, secondPoint)); currentTruss.get_Parameter(BuiltInParameter.TRUSS_HEIGHT).Set(currentTrussInfo.Height); trussInfoList.Add(currentTrussInfo); } #region DEBUG ONLY else { #if DEBUG FamilySymbol fs = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_GenericModel).WhereElementIsElementType().Where(type => type.Name.Contains("DebugPoint")).FirstOrDefault() as FamilySymbol; fs.Activate(); doc.Create.NewFamilyInstance(currentPointOnRidge, fs, Autodesk.Revit.DB.Structure.StructuralType.NonStructural); #endif } #endregion } } return(trussInfoList); }
private TrussInfo CreateTrussInfo(Document doc, XYZ currentPointOnRidge, EdgeInfo currentRidgeEdgeInfo, IList <XYZ> currentSupportPoints, TrussType tType) { TrussInfo currentTrussInfo = TrussInfo.BuildTrussAtRidge(currentPointOnRidge, currentRidgeEdgeInfo, currentSupportPoints); if (currentTrussInfo != null) { SketchPlane stkP = SketchPlane.Create(doc, currentRidgeEdgeInfo.CurrentRoof.LevelId); double levelHeight = currentRidgeEdgeInfo.GetCurrentRoofHeight(); XYZ firstPoint = new XYZ(currentTrussInfo.FirstPoint.X, currentTrussInfo.FirstPoint.Y, levelHeight); XYZ secondPoint = new XYZ(currentTrussInfo.SecondPoint.X, currentTrussInfo.SecondPoint.Y, levelHeight); Truss currentTruss = Truss.Create(doc, tType.Id, stkP.Id, Line.CreateBound(firstPoint, secondPoint)); currentTruss.get_Parameter(BuiltInParameter.TRUSS_HEIGHT).Set(currentTrussInfo.Height); } return(currentTrussInfo); }
static internal TrussInfo GetTrussInfo(XYZ currentTopPoint, XYZ supportPoint0, XYZ supportPoint1) { if (currentTopPoint.DistanceTo(supportPoint0) < 0.5 || currentTopPoint.DistanceTo(supportPoint1) < 0.5 || supportPoint0.DistanceTo(supportPoint1) < 0.5) { return(null); } CurveArray topChords = new CurveArray(); CurveArray bottomChords = new CurveArray(); topChords.Append(Line.CreateBound(currentTopPoint, supportPoint0)); topChords.Append(Line.CreateBound(currentTopPoint, supportPoint1)); bottomChords.Append(Line.CreateBound(supportPoint0, supportPoint1)); double height = currentTopPoint.DistanceTo(new XYZ(currentTopPoint.X, currentTopPoint.Y, supportPoint0.Z)); TrussInfo trussInfo = new TrussInfo(supportPoint0, supportPoint1, height); trussInfo.TopChords = topChords; trussInfo.BottomChords = bottomChords; return(trussInfo); }