/***************************************************/ /**** Public methods ****/ /***************************************************/ public static ICurve AdjustedLocationCurveFraming(this IFramingElement framingElement, FamilyInstance familyInstance, RevitSettings settings = null) { settings = settings.DefaultIfNull(); ICurve curve = framingElement?.Location; if (curve == null || (!(curve is NurbsCurve) && curve.ILength() <= settings.DistanceTolerance)) { framingElement.FramingCurveNotFoundWarning(); return(null); } BH.oM.Geometry.Line line = curve as BH.oM.Geometry.Line; if (line == null) { familyInstance.NonLinearFramingOffsetWarning(); return(curve); } Output <Vector, Vector> offsets = familyInstance.FramingOffsetVectors(); Vector startOffset = -offsets.Item1; Vector endOffset = -offsets.Item2; double startOffsetLength = startOffset.Length(); double endOffsetLength = endOffset.Length(); if (startOffsetLength > settings.DistanceTolerance || endOffsetLength > settings.DistanceTolerance) { if ((startOffset - endOffset).Length() > settings.DistanceTolerance) { BH.Engine.Reflection.Compute.RecordError(String.Format("Adjusted location curve of a Revit framing element could not be found because it has non-uniform offsets at ends. Revit ElementId: {0}", familyInstance.Id)); return(null); } Transform transform = familyInstance.GetTotalTransform(); Vector yOffsetStart = new Vector { X = transform.BasisY.X * startOffset.Y, Y = transform.BasisY.Y * startOffset.Y, Z = transform.BasisY.Z * startOffset.Y }; Vector zOffsetStart = new Vector { X = transform.BasisZ.X * startOffset.Z, Y = transform.BasisZ.Y * startOffset.Z, Z = transform.BasisZ.Z * startOffset.Z }; Vector yOffsetEnd = new Vector { X = transform.BasisY.X * endOffset.Y, Y = transform.BasisY.Y * endOffset.Y, Z = transform.BasisY.Z * endOffset.Y }; Vector zOffsetEnd = new Vector { X = transform.BasisZ.X * endOffset.Z, Y = transform.BasisZ.Y * endOffset.Z, Z = transform.BasisZ.Z * endOffset.Z }; line = new BH.oM.Geometry.Line { Start = line.Start.Translate(yOffsetStart + zOffsetStart), End = line.End.Translate(yOffsetEnd + zOffsetEnd) }; } Vector dir = line.Direction(); double startExtension = familyInstance.LookupParameterDouble(BuiltInParameter.START_EXTENSION); if (!double.IsNaN(startExtension)) { line.Start = line.Start + dir * startExtension; } double endExtension = familyInstance.LookupParameterDouble(BuiltInParameter.END_EXTENSION); if (!double.IsNaN(endExtension)) { line.End = line.End - dir * endExtension; } return(line); }