public static bool HasMergeablePropertiesWith(this IFramingElement element, IFramingElement other) { if (element == null || other == null) { return(false); //If either is null, then it can probably can't have its properties merged } if (element.GetType() != other.GetType()) { return(false); } if (element.Location == null || element.Location.ILength() < oM.Geometry.Tolerance.Distance || other.Location == null || other.Location.ILength() < oM.Geometry.Tolerance.Distance) { return(false); } if (!element.Location.IIsLinear() || !other.Location.IIsLinear()) { Engine.Reflection.Compute.RecordWarning("No merge comparison avalible for non-linear IFramingElements."); return(false); } int parallel = element.Location.IStartDir().IsParallel(other.Location.IStartDir()); if (parallel != 1) { return(false); } if (element.Normal().Angle(other.Normal()) > BH.oM.Geometry.Tolerance.Angle) { return(false); } if (element.Property == other.Property) { return(true); } if (element.Property == null || other.Property == null) { return(false); } if (element.Property.Name != other.Property.Name) { return(false); } return(Diffing.Query.DifferentProperties(element.Property, other.Property, new DiffingConfig()) == null); }
public static ICurve BoundingBoxCentreline(this IFramingElement element) { ICurve location = element?.Location; if (location == null) { return(null); } Vector normal = null; normal = element.Normal(); if (normal == null) { Engine.Reflection.Compute.RecordError("IFramingElement must have linear location line."); return(null); } Vector tangent = (location.IEndPoint() - location.IStartPoint()).Normalise(); Vector localx = tangent.CrossProduct(normal); if (element.Property is ConstantFramingProperty) { Point centre = (element.Property as ConstantFramingProperty)?.Profile?.Edges?.Bounds()?.Centre(); if (centre == null) { return(null); } Vector sectionTranslate = centre - Point.Origin; return(location.ITranslate(-localx * sectionTranslate.X + normal * sectionTranslate.Y)); } else { Engine.Reflection.Compute.RecordError("Only suitable framing property for the action is ConstantFramingProperty."); return(null); } }