/// <summary> /// Create the handle corresponding to the "Axis" IfcRepresentation for a structural member objects, if possible. /// </summary> /// <param name="exporterIFC">The ExporterIFC class.</param> /// <param name="element">The structural member element.</param> /// <param name="catId">The structural member category id.</param> /// <param name="axisInfo">The optional structural member axis information.</param> /// <param name="offsetTransform">The optional offset transform applied to the "Body" representation.</param> /// <returns>The handle, or null if not created.</returns> public static IFCAnyHandle CreateStructuralMemberAxis(ExporterIFC exporterIFC, Element element, ElementId catId, StructuralMemberAxisInfo axisInfo, Transform newTransformLCS) { if (axisInfo == null) { return(null); } // This Axis should have been transformed into its ECS position previously (in GetStructuralMemberAxisTransform()) Curve curve = axisInfo.Axis; Transform offset = Transform.Identity; if (newTransformLCS != null) { // We need to flip the Left-handed transform to the right-hand one as IFC only support right-handed coordinate system if (newTransformLCS.Determinant < 0) { XYZ orig = newTransformLCS.Origin; newTransformLCS.Origin = XYZ.Zero; offset = FlipYTrf().Multiply(newTransformLCS); offset.Origin = orig; } else { offset = newTransformLCS; } } // Calculate the transformation matrix to tranform the original Axis Curve at its ECS into the new ECS assigned in the offset curve = curve.CreateTransformed(offset.Inverse.Multiply(axisInfo.LCSAsTransform)); IDictionary <IFCFuzzyXYZ, IFCAnyHandle> cachePoints = new Dictionary <IFCFuzzyXYZ, IFCAnyHandle>(); IFCAnyHandle ifcCurveHnd; try { ifcCurveHnd = GeometryUtil.CreateIFCCurveFromRevitCurve(exporterIFC.GetFile(), exporterIFC, curve, true, cachePoints); } catch { ifcCurveHnd = GeometryUtil.OutdatedCreateIFCCurveFromRevitCurve(exporterIFC.GetFile(), exporterIFC, curve, true, cachePoints); } IList <IFCAnyHandle> axis_items = new List <IFCAnyHandle>(); if (!(IFCAnyHandleUtil.IsNullOrHasNoValue(ifcCurveHnd))) { axis_items.Add(ifcCurveHnd); } if (axis_items.Count > 0) { string identifierOpt = "Axis"; // This is by IFC2x2+ convention. string representationTypeOpt = "Curve3D"; // This is by IFC2x2+ convention. IFCAnyHandle axisRep = RepresentationUtil.CreateShapeRepresentation(exporterIFC, element, catId, exporterIFC.Get3DContextHandle(identifierOpt), identifierOpt, representationTypeOpt, axis_items); return(axisRep); } return(null); }