/***************************************************/ private IFGeometry[] GetAssignedObjects(IElementLoad <BHoMObject> loads) { List <IFGeometry> assignedGeometry = new List <IFGeometry>(); foreach (BHoMObject element in loads.Objects.Elements) { if (element is Node) { IFGeometry lusasPoint = d_LusasData.getPointByNumber( element.AdapterId <int>(typeof(LusasId))); assignedGeometry.Add(lusasPoint); } else if (element is Bar) { IFGeometry lusasBar = d_LusasData.getLineByNumber( element.AdapterId <int>(typeof(LusasId))); assignedGeometry.Add(lusasBar); } else if (element is Panel) { IFGeometry lusasSurface = d_LusasData.getSurfaceByNumber( element.AdapterId <int>(typeof(LusasId))); assignedGeometry.Add(lusasSurface); } } IFGeometry[] arrayGeometry = assignedGeometry.ToArray(); return(arrayGeometry); }
public static bool HasAssignedObjectIds <T>(this IElementLoad <T> load, Type adapterIdType) where T : IBHoMObject { if (load.IsNull()) { return(false); } if (load.Objects == null || load.Objects.Elements == null || load.Objects.Elements.Any(x => x == null)) { Reflection.Compute.RecordError("At least one of the provided objects assigned to the load is null. Id assignment could not be evaluated."); return(false); } if (adapterIdType == null) { Reflection.Compute.RecordError("The provided AdapterId type is null. Could not check object id assignment for the load."); return(false); } if (!typeof(IAdapterId).IsAssignableFrom(adapterIdType)) { Reflection.Compute.RecordError($"The `{adapterIdType.Name}` is not a valid `{typeof(IAdapterId).Name}`."); return(false); } return(load.Objects.Elements.All(x => x.Fragments.Contains(adapterIdType))); }
/***************************************************/ private object[] GetAssignedSurfaces(IElementLoad <IAreaElement> loads) { int[] lusasIDs = loads.Objects.Elements.Select(x => x.AdapterId <int>(typeof(LusasId))).ToArray(); object[] arrayGeometry = d_LusasData.getObjects("Surface", lusasIDs); return(arrayGeometry); }