/***************************************************/ 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); }
/***************************************************/ /**** Private Methods ****/ /***************************************************/ public static IEnumerable <BHoMObject> GetGeometryAssignments(IEnumerable <IFAssignment> lusasAssignments, Dictionary <string, Node> nodes, Dictionary <string, Bar> bars, Dictionary <string, Panel> panels) { List <BHoMObject> assignedObjects = new List <BHoMObject>(); Node node; Bar bar; Panel panel; foreach (IFAssignment lusasAssignment in lusasAssignments) { IFGeometry lusasGeometry = (IFGeometry)lusasAssignment.getDatabaseObject(); if (lusasGeometry is IFPoint) { nodes.TryGetValue(lusasGeometry.getID().ToString(), out node); assignedObjects.Add(node); } else if (lusasGeometry is IFLine) { bars.TryGetValue(lusasGeometry.getID().ToString(), out bar); assignedObjects.Add(bar); } else if (lusasGeometry is IFSurface) { panels.TryGetValue(lusasGeometry.getID().ToString(), out panel); assignedObjects.Add(panel); } } return(assignedObjects); }
/***************************************************/ /**** Private Methods ****/ /***************************************************/ private void AssignObjectSet(IFGeometry newGeometry, HashSet <string> tags) { foreach (string tag in tags) { IFObjectSet objectSet = d_LusasData.getGroupByName(tag); objectSet.add(newGeometry); } }
/***************************************************/ /**** Private Methods ****/ /***************************************************/ private static HashSet <string> IsMemberOf(IFGeometry lusasGeometry, HashSet <string> tags) { HashSet <string> geometryTag = new HashSet <string>(); foreach (string tag in tags) { if (lusasGeometry.isMemberOfGroup(tag)) { geometryTag.Add(tag); } } return(geometryTag); }
/***************************************************/ /**** Private Methods ****/ /***************************************************/ private static List <string> GetAttributeAssignments(IFGeometry lusasGeometry, string attributeType) { object[] lusasAssignments = lusasGeometry.getAssignments(attributeType); List <string> attributeNames = new List <string>(); int n = lusasAssignments.Count(); for (int i = 0; i < n; i++) { IFAssignment lusasAssignment = lusasGeometry.getAssignments(attributeType)[i]; IFAttribute lusasAttribute = lusasAssignment.getAttribute(); string attributeName = GetName(lusasAttribute); attributeNames.Add(attributeName); } return(attributeNames); }
/***************************************************/ /**** Private Methods ****/ /***************************************************/ private void DeletePointAssignments(object[] lusasAttributes) { for (int i = 0; i < lusasAttributes.Count(); i++) { IFAttribute lusasAttribute = (IFAttribute)lusasAttributes[i]; object[] lusasAssignments = lusasAttribute.getAssignments(); for (int j = 0; j < lusasAssignments.Count(); j++) { IFAssignment lusasAssignment = (IFAssignment)lusasAssignments[j]; IFGeometry lusasGeometry = (IFGeometry)lusasAssignment.getDatabaseObject(); if (lusasGeometry is IFPoint) { Engine.Base.Compute.RecordWarning(lusasAttribute.getName() + " has been deleted because it was assigned to a point"); d_LusasData.Delete(lusasAttribute); break; } } } }