/// <summary> /// Set Material set usage parameters and creates it if it doesn't exist. /// </summary> /// <param name = "model">Model of the element</param> /// <param name = "forLayerSet">Material layer set for the usage</param> /// <param name = "layerSetDirection">Direction of the material layer set in the usage</param> /// <param name = "directionSense">Sense of the direction of the usage</param> /// <param name = "offsetFromReferenceLine">Offset from the reference line of the element</param> public static void SetMaterialLayerSetUsage(this IfcRoot element, IModel model, IfcMaterialLayerSet forLayerSet, IfcLayerSetDirectionEnum layerSetDirection, IfcDirectionSenseEnum directionSense, IfcLengthMeasure offsetFromReferenceLine) { //if some input is not correct, material layer set usage is not created or changed if (element == null || forLayerSet == null) { return; } IfcMaterialLayerSetUsage materialUsage = element.GetOrCreateLayerSetUsage(model); materialUsage.ForLayerSet = forLayerSet; materialUsage.LayerSetDirection = layerSetDirection; materialUsage.DirectionSense = directionSense; materialUsage.OffsetFromReferenceLine = offsetFromReferenceLine; }
public static IfcMaterialLayerSetUsage GetOrCreateLayerSetUsage(this IfcRoot element, IModel model) { IfcMaterialLayerSetUsage result = GetMaterialLayerSetUsage(element, model); if (result != null) { return(result); } result = model.Instances.New <IfcMaterialLayerSetUsage>(); //create relation IfcRelAssociatesMaterial rel = model.Instances.New <IfcRelAssociatesMaterial>(); rel.RelatedObjects.Add(element); rel.RelatingMaterial = result; return(result); }
public static IfcClassificationNotation GetFirstClassificationNotation(this IfcRoot root, IModel model) { IfcRelAssociatesClassification rel = model.Instances.Where <IfcRelAssociatesClassification>(r => r.RelatedObjects.Contains(root)). FirstOrDefault(); if (rel == null) { return(null); } IfcClassificationNotationSelect notationSelect = rel.RelatingClassification; if (notationSelect is IfcClassificationReference) { Debug.WriteLine( "Classification relation does not contain classification notation, but it contains external reference."); return(null); } return(notationSelect as IfcClassificationNotation); }
private static String BuildName(IfcRoot ifcObject) { String name; if (ifcObject is IfcRelDecomposes) { IfcRelDecomposes rel = ifcObject as IfcRelDecomposes; name = BuildName(rel.RelatingObject); } else { name = ifcObject.Name; } if (String.IsNullOrEmpty(name)) { name = ifcObject.ToString(); } return(name); }
public List <ValidationResult> Validate(IfcRoot root) { T obj = root as T; if (obj == null) { return(null); } // Test Applicability List <ValidationResult> results = new List <ValidationResult>(); foreach (ValidationResult result in ValidateWorker(obj)) { if (result == ValidationResult.Success) { continue; } results.Add(new ValidationResult(Uuid.ToString() + " | " + Name + " | " + result.ErrorMessage)); } return(results); }
/// <summary> /// Converts a category to a classification /// </summary> /// <param name="category"></param> /// <param name="ifcElement"></param> public void ConvertCategoryToClassification(Category category, IfcRoot ifcElement) { if (String.IsNullOrEmpty(category.Classification) && string.IsNullOrEmpty(category.Code)) { return; } IfcClassification classificationSystem; if (String.IsNullOrEmpty(category.Classification) || !_classificationSystems.TryGetValue(category.Classification, out classificationSystem)) { classificationSystem = TargetRepository.Instances.New <IfcClassification>(); classificationSystem.Name = category.Classification; } IfcClassificationReference classificationReference; if (String.IsNullOrEmpty(category.Code) || !_classificationReferences.TryGetValue(category.Code, out classificationReference)) { classificationReference = TargetRepository.Instances.New <IfcClassificationReference>(); classificationReference.ItemReference = category.Code; classificationReference.Name = category.Description; classificationReference.ReferencedSource = classificationSystem; } IfcRelAssociatesClassification relationship; if (!_classificationRelationships.TryGetValue(classificationReference, out relationship)) { relationship = TargetRepository.Instances.New <IfcRelAssociatesClassification>(); relationship.RelatingClassification = classificationReference; relationship.Name = category.Code; relationship.Description = category.Description; } relationship.RelatedObjects.Add(ifcElement); }
public CompositionNode(IfcRoot entity) : base(entity, false, false) { }
public ElementNode(IfcRoot entity) : base(entity, false, true) { }
/// <summary> /// Fill sheet rows for Impact sheet /// </summary> /// <returns>COBieSheet</returns> public override COBieSheet<COBieImpactRow> Fill() { ProgressIndicator.ReportMessage("Starting Impacts..."); //create new sheet COBieSheet<COBieImpactRow> impacts = new COBieSheet<COBieImpactRow>(Constants.WORKSHEET_IMPACT); // get all IfcPropertySet objects from IFC file IEnumerable<IfcPropertySet> ifcProperties = Model.Instances.OfType<IfcPropertySet>().Where(ps => ps.Name.ToString() == "Pset_EnvironmentalImpactValues"); ProgressIndicator.Initialise("Creating Impacts", ifcProperties.Count()); foreach (IfcPropertySet propSet in ifcProperties) { ProgressIndicator.IncrementAndUpdate(); COBieImpactRow impact = new COBieImpactRow(impacts); List<IfcSimpleProperty> propertyList = propSet.HasProperties.OfType<IfcSimpleProperty>().ToList(); Interval propValues = GetPropertyValue(propertyList, "ImpactName"); impact.Name = (propValues.Value == DEFAULT_STRING) ? propSet.Name.ToString() : propValues.Value.ToString(); impact.CreatedBy = GetTelecomEmailAddress(propSet.OwnerHistory); impact.CreatedOn = GetCreatedOnDateAsFmtString(propSet.OwnerHistory); propValues = GetPropertyValue(propertyList, "ImpactType"); impact.ImpactType = propValues.Value; propValues = GetPropertyValue(propertyList, "ImpactStage"); impact.ImpactStage = propValues.Value; IfcRoot ifcRoot = GetAssociatedObject(propSet); impact.SheetName = GetSheetByObjectType(ifcRoot.GetType()); impact.RowName = (!string.IsNullOrEmpty(ifcRoot.Name.ToString())) ? ifcRoot.Name.ToString() : DEFAULT_STRING; propValues = GetPropertyValue(propertyList, "Value"); impact.Value = propValues.Value; impact.ImpactUnit = propValues.Unit; propValues = GetPropertyValue(propertyList, "LeadInTime"); impact.LeadInTime = propValues.Value; propValues = GetPropertyValue(propertyList, "Duration"); impact.Duration = propValues.Value; propValues = GetPropertyValue(propertyList, "LeadOutTime"); impact.LeadOutTime = propValues.Value; impact.ExtSystem = GetExternalSystem(propSet); impact.ExtObject = propSet.GetType().Name; impact.ExtIdentifier = propSet.GlobalId; impact.Description = (propSet.Description != null) ? propSet.Description.ToString() : DEFAULT_STRING; impacts.AddRow(impact); } impacts.OrderBy(s => s.Name); ProgressIndicator.Finalise(); return impacts; }
public static void RemoveObjectFromClassificationNotation(this IfcClassificationNotationSelect cls, IfcRoot root) { var model = cls.Model; var rel = model.Instances.FirstOrDefault <IfcRelAssociatesClassification>(r => r.RelatingClassification == cls); if (rel == null) { return; } if (rel.RelatedObjects.Contains(root)) { rel.RelatedObjects.Remove(root); } }
public static void AddObjectToClassificationNotation(this IfcClassificationNotationSelect cls, IfcRoot root) { var model = cls.Model; var rel = model.Instances.FirstOrDefault <IfcRelAssociatesClassification>(r => r.RelatingClassification == cls); if (rel == null) { model.Instances.New <IfcRelAssociatesClassification>(r => { r.RelatingClassification = cls; r.RelatedObjects.Add(root); }); } else if (!rel.RelatedObjects.Contains(root)) { rel.RelatedObjects.Add(root); } }
public AttributeHasedRoot(IfcRoot root, IfcSimpleValue value) { _root = root; _val = value; _hash = value.ToString().GetHashCode(); }
/// <summary> /// Gets the name of the application that is linked with the supplied item /// </summary> /// <param name="item"></param> /// <returns></returns> public string GetExternalSystem(IfcRoot item) { return(GetExternalSystem(item.OwnerHistory)); }
static void Main(string[] args) { string ifcFile = "", propertiesFile = ""; if (args.Length > 0) { ifcFile = args[0]; } if (string.IsNullOrEmpty(ifcFile)) { OpenFileDialog openDialog = new OpenFileDialog() { Filter = "IFC BIM Data (*.ifc,*.ifcxml)|*.ifc;*.ifcxml" }; openDialog.Title = "Nominate IFC file to test"; DialogResult dresult = openDialog.ShowDialog(); if (dresult != DialogResult.OK) { return; } ifcFile = openDialog.FileName; } if (args.Length > 1) { propertiesFile = args[1]; } else { OpenFileDialog openDialog = new OpenFileDialog() { Filter = "IFC BIM Data (*.ifc,*.ifcxml)|*.ifc;*.ifcxml" }; openDialog.Title = "Nominate Exchange Requirement Property Templates"; DialogResult dresult = openDialog.ShowDialog(); if (dresult == DialogResult.OK) { propertiesFile = openDialog.FileName; } } List <IfcPropertySetTemplate> propertySetTemplates = new List <IfcPropertySetTemplate>(); if (!string.IsNullOrEmpty(propertiesFile)) { try { DatabaseIfc dbTemplates = new DatabaseIfc(propertiesFile); propertySetTemplates.AddRange(dbTemplates.Context.Declares.SelectMany(x => x.RelatedDefinitions).OfType <IfcPropertySetTemplate>()); } catch (Exception x) { System.Windows.Forms.MessageBox.Show(x.Message, "Property Template Exception", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } DatabaseIfc db = new DatabaseIfc(ifcFile); // Future will inspect sender, receiver and purpose of file to select specific exchange requirements ExchangeRequirements_TfNSW_Drainage drainageExchangeRequirements = new ExchangeRequirements_TfNSW_Drainage(propertySetTemplates); Dictionary <IfcRoot, List <ValidationResult> > results = drainageExchangeRequirements.Validate(db.Context); if (results.Count > 0) { //TfNSW_Excel_Config config = TfNSW_Excel_Config.Load(); string assetCodePropertyName = "TfNSW_Project_AssetCode"; //config.AssetSheet.AssetPropertySet.ProjectCode.Name; string locationCodePropertyName = "TfNSW_Project_LocationCode"; //config.LocationSheet.LocationPropertySet.ProjectCode.Name; StringBuilder stringBuilder = new StringBuilder(); foreach (KeyValuePair <IfcRoot, List <ValidationResult> > pair in results) { IfcRoot root = pair.Key; string id = root.ToString(); IfcObjectDefinition obj = root as IfcObjectDefinition; if (obj != null) { IfcPropertySingleValue psv = obj.FindProperty(assetCodePropertyName) as IfcPropertySingleValue; if (psv != null && psv.NominalValue != null && !string.IsNullOrEmpty(psv.NominalValue.ValueString)) { id = psv.NominalValue.ValueString; } else { psv = obj.FindProperty(locationCodePropertyName) as IfcPropertySingleValue; if (psv != null && psv.NominalValue != null && !string.IsNullOrEmpty(psv.NominalValue.ValueString)) { id = psv.NominalValue.ValueString; } } } stringBuilder.Append("XXX " + id + "\r\n"); foreach (ValidationResult result in pair.Value) { stringBuilder.Append(" " + result + "\r\n"); } } string path = Path.Combine(Path.GetDirectoryName(ifcFile), Path.GetFileNameWithoutExtension(ifcFile) + " validation " + Path.Combine(DateTime.Now.ToString("yyMMdd hhmm") + ".txt")); File.WriteAllText(path, stringBuilder.ToString()); System.Diagnostics.Process.Start(path); } else { MessageBox.Show("Valid File", "Valid", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Add the object the document relates too /// </summary> /// <param name="row">COBieDocumentRow holding row data</param> private IfcRoot GetObjectRelationship(COBieDocumentRow row) { IfcRoot ifcRoot = null; if ((ValidateString(row.SheetName)) && (ValidateString(row.RowName))) { string sheetName = row.SheetName.ToLower().Trim(); sheetName = char.ToUpper(sheetName[0]) + sheetName.Substring(1); string rowName = row.RowName.ToLower().Trim(); string extObject = string.Empty; if (ValidateString(row.ExtObject)) //if valid change to correct type { extObject = row.ExtObject.Trim().ToUpper(); } switch (sheetName) { case Constants.WORKSHEET_TYPE: //get all types, one time only if (IfcTypeObjects == null) { IfcTypeObjects = Model.FederatedInstances.OfType <IfcTypeObject>(); } ifcRoot = IfcTypeObjects.Where(to => to.Name.ToString().ToLower().Trim() == rowName).FirstOrDefault(); if (ifcRoot == null) { string typeName = string.Empty; if (ValidateString(extObject)) { typeName = extObject; } else { typeName = "IFCBUILDINGELEMENTPROXYTYPE"; } ifcRoot = COBieXBimType.GetTypeInstance(typeName, Model); ifcRoot.Name = row.RowName; ifcRoot.Description = "Created to maintain relationship with document object from COBie information"; } break; case Constants.WORKSHEET_COMPONENT: //get all types, one time only if (IfcElements == null) { IfcElements = Model.FederatedInstances.OfType <IfcElement>(); } ifcRoot = IfcElements.Where(to => to.Name.ToString().ToLower().Trim() == rowName).FirstOrDefault(); string elementTypeName = "IFCVIRTUALELEMENT"; if (ifcRoot == null) { if (ValidateString(extObject)) //if valid change to correct type { elementTypeName = extObject; } ifcRoot = COBieXBimComponent.GetElementInstance(elementTypeName, Model); ifcRoot.Name = row.RowName; ifcRoot.Description = "Created to maintain relationship with document object from COBie information"; } else if ((ifcRoot.GetType().Name.ToUpper() == elementTypeName) && //check type, if IFCVIRTUALELEMENT and (ValidateString(extObject)) && (extObject != elementTypeName) && //not IFCVIRTUALELEMENT then delete virtual, and add correct type (ValidateString(ifcRoot.Description)) && //ensure we set to maintain relationship on another sheet (ifcRoot.Description.ToString().Contains("COBie information")) ) { try { Model.Delete(ifcRoot); //remove IFCVIRTUALELEMENT, probably added by system sheet elementTypeName = extObject; ifcRoot = COBieXBimComponent.GetElementInstance(elementTypeName, Model); ifcRoot.Name = row.RowName; ifcRoot.Description = "Created to maintain relationship with document object from COBie information"; } catch (Exception ex) { Console.WriteLine(string.Format("Failed to delete ifcRelDecomposes in AddObjectRelationship() - {0}", ex.Message)); } } break; case Constants.WORKSHEET_JOB: ifcRoot = Model.FederatedInstances.Where <IfcProcess>(to => to.Name.ToString().ToLower().Trim() == rowName).FirstOrDefault(); break; case Constants.WORKSHEET_ASSEMBLY: ifcRoot = Model.FederatedInstances.Where <IfcRelDecomposes>(to => to.Name.ToString().ToLower().Trim() == rowName).FirstOrDefault(); break; case Constants.WORKSHEET_CONNECTION: ifcRoot = Model.FederatedInstances.Where <IfcRelConnects>(to => to.Name.ToString().ToLower().Trim() == rowName).FirstOrDefault(); break; case Constants.WORKSHEET_FACILITY: ifcRoot = Model.FederatedInstances.Where <IfcBuilding>(to => to.Name.ToString().ToLower().Trim() == rowName).FirstOrDefault(); if (ifcRoot == null) { ifcRoot = Model.FederatedInstances.Where <IfcSite>(to => to.Name.ToString().ToLower().Trim() == rowName).FirstOrDefault(); } if (ifcRoot == null) { ifcRoot = Model.FederatedInstances.Where <IfcProject>(to => to.Name.ToString().ToLower().Trim() == rowName).FirstOrDefault(); } break; case Constants.WORKSHEET_FLOOR: ifcRoot = Model.FederatedInstances.Where <IfcBuildingStorey>(to => to.Name.ToString().ToLower().Trim() == rowName).FirstOrDefault(); break; case Constants.WORKSHEET_RESOURCE: ifcRoot = Model.FederatedInstances.Where <IfcConstructionEquipmentResource>(to => to.Name.ToString().ToLower().Trim() == rowName).FirstOrDefault(); break; case Constants.WORKSHEET_SPACE: ifcRoot = Model.FederatedInstances.Where <IfcSpace>(to => to.Name.ToString().ToLower().Trim() == rowName).FirstOrDefault(); break; case Constants.WORKSHEET_SPARE: ifcRoot = Model.FederatedInstances.Where <IfcConstructionProductResource>(to => to.Name.ToString().ToLower().Trim() == rowName).FirstOrDefault(); break; case Constants.WORKSHEET_SYSTEM: ifcRoot = Model.FederatedInstances.Where <IfcGroup>(to => to.Name.ToString().ToLower().Trim() == rowName).FirstOrDefault(); break; case Constants.WORKSHEET_ZONE: ifcRoot = Model.FederatedInstances.Where <IfcZone>(to => to.Name.ToString().ToLower().Trim() == rowName).FirstOrDefault(); break; //case "document": //not derived from IfcRoot // ifcRoot = Model.FederatedInstances.Where<IfcDocumentInformation>(to => to.Name.ToString().ToLower().Trim() == rowName).FirstOrDefault(); // break; //case "contact": //not derived from IfcRoot // ifcRoot = Model.FederatedInstances.Where<IfcPersonAndOrganization>(to => to.Name.ToString().ToLower().Trim() == rowName).FirstOrDefault(); // break; //case "issue": //not derived from IfcRoot // ifcRoot = Model.FederatedInstances.Where<IfcApproval>(to => to.Name.ToString().ToLower().Trim() == rowName).FirstOrDefault(); // break; default: break; } } return(ifcRoot); }
/// <summary> /// Add the data to the Document Information object /// </summary> /// <param name="row">COBieDocumentRow holding the data</param> private void AddDocument(COBieDocumentRow row) { if (CheckIfExistOnMerge(row)) { return; //already in document } IfcDocumentInformation ifcDocumentInformation = Model.Instances.New <IfcDocumentInformation>(); IfcRelAssociatesDocument ifcRelAssociatesDocument = Model.Instances.New <IfcRelAssociatesDocument>(); //Add Created By, Created On and ExtSystem to Owner History. SetUserHistory(ifcRelAssociatesDocument, row.ExtSystem, row.CreatedBy, row.CreatedOn); if (Contacts.ContainsKey(row.CreatedBy)) { ifcDocumentInformation.DocumentOwner = (IfcPersonAndOrganization)Contacts[row.CreatedBy]; } //using statement will set the Model.OwnerHistoryAddObject to IfcConstructionProductResource.OwnerHistory as OwnerHistoryAddObject is used upon any property changes, //then swaps the original OwnerHistoryAddObject back in the dispose, so set any properties within the using statement using (COBieXBimEditScope context = new COBieXBimEditScope(Model, ifcRelAssociatesDocument.OwnerHistory)) { //create relationship between Document and ifcObjects it relates too ifcRelAssociatesDocument.RelatingDocument = ifcDocumentInformation; //Add Name if (ValidateString(row.Name)) { ifcDocumentInformation.Name = row.Name; } //Add Category if (ValidateString(row.Category)) { ifcDocumentInformation.Purpose = row.Category; } //Add approved By if (ValidateString(row.ApprovalBy)) { ifcDocumentInformation.IntendedUse = row.ApprovalBy; } //Add Stage if (ValidateString(row.Stage)) { ifcDocumentInformation.Scope = row.Stage; } //Add GlobalId AddGlobalId(row.ExtIdentifier, ifcRelAssociatesDocument); //Add Object Relationship IfcRoot ifcRoot = GetObjectRelationship(row); //add to the document relationship object if (ifcRoot != null) { ifcRelAssociatesDocument.RelatedObjects.Add(ifcRoot); } //Add Document reference AddDocumentReference(row, ifcDocumentInformation); //add Description if (ValidateString(row.Description)) { ifcDocumentInformation.Description = row.Description; } //Add Reference if (ValidateString(row.Reference)) { ifcDocumentInformation.DocumentId = row.Reference; } else { ifcDocumentInformation.DocumentId = ""; //required field so add blank string } } }
/// <summary> /// Fill sheet rows for Issue sheet /// </summary> /// <returns>COBieSheet</returns> public override COBieSheet <COBieIssueRow> Fill() { ProgressIndicator.ReportMessage("Starting Issues..."); var ifcProject = Model.Instances.FirstOrDefault <IIfcProject>(); Debug.Assert(ifcProject != null); //create new sheet var issues = new COBieSheet <COBieIssueRow>(Constants.WORKSHEET_ISSUE); //IEnumerable<IfcPropertySet> ifcProperties = Model.FederatedInstances.OfType<IfcPropertySet>().Where(ps => ps.Name.ToString() == "Pset_Risk"); #region IFcApproval // get all IfcApproval objects from IFC file IEnumerable <IfcApproval> ifcApprovals = Model.FederatedInstances.OfType <IfcApproval>(); ProgressIndicator.Initialise("Creating Issues (from IfcApprovals)", ifcApprovals.Count()); List <IfcRelAssociatesApproval> ifcRelAssociatesApprovals = Model.FederatedInstances.OfType <IfcRelAssociatesApproval>().ToList(); foreach (IfcApproval ifcApproval in ifcApprovals) { ProgressIndicator.IncrementAndUpdate(); COBieIssueRow issue = new COBieIssueRow(issues); //get the associated property setIfcPropertySet var ifcPropertySet = ifcRelAssociatesApprovals .Where(ral => ral.RelatingApproval == ifcApproval) .SelectMany(ral => ral.RelatedObjects.OfType <IfcPropertySet>()) .Where(ps => ps.Name == "Pset_Risk") .FirstOrDefault(); List <IfcSimpleProperty> propertyList = new List <IfcSimpleProperty>(); if (ifcPropertySet != null) { propertyList = ifcPropertySet.HasProperties.OfType <IfcSimpleProperty>().ToList(); } issue.Name = (string.IsNullOrEmpty(ifcApproval.Name)) ? DEFAULT_STRING : ifcApproval.Name.ToString(); //lets default the creator to that user who created the project for now, no direct link to OwnerHistory on IfcApproval if (ifcPropertySet != null) { //use "Pset_Risk" Property Set as source for this issue.CreatedBy = GetTelecomEmailAddress(ifcPropertySet.OwnerHistory); issue.CreatedOn = GetCreatedOnDateAsFmtString(ifcPropertySet.OwnerHistory); } else { //if property set is null use project defaults issue.CreatedBy = GetTelecomEmailAddress(ifcProject.OwnerHistory); issue.CreatedOn = GetCreatedOnDateAsFmtString(ifcProject.OwnerHistory); } Interval propValues = GetPropertyEnumValue(propertyList, "RiskType"); issue.Type = propValues.Value; propValues = GetPropertyEnumValue(propertyList, "RiskRating"); issue.Risk = propValues.Value; propValues = GetPropertyEnumValue(propertyList, "AssessmentOfRisk"); issue.Chance = propValues.Value; propValues = GetPropertyEnumValue(propertyList, "RiskConsequence"); issue.Impact = propValues.Value; //GetIt(typeof(IfcApproval)); //Risk assessment has to be on a task so we should have one List <IfcRoot> IfcRoots = GetIfcObjects(ifcApproval); issue.SheetName1 = (IfcRoots.Count > 0) ? GetSheetByObjectType(IfcRoots[0].GetType()) : DEFAULT_STRING; issue.RowName1 = (IfcRoots.Count > 0) ? IfcRoots[0].Name.ToString() : DEFAULT_STRING; //assuming that this row is a person associated with the ifcApproval, but might be a task string email = GetContact(ifcApproval); if (email == DEFAULT_STRING) //if no email, see if we have another ifcobject { issue.SheetName2 = (IfcRoots.Count > 1) ? GetSheetByObjectType(IfcRoots[1].GetType()) : DEFAULT_STRING; issue.RowName2 = (IfcRoots.Count > 1) ? IfcRoots[1].Name.ToString() : DEFAULT_STRING; } else { issue.SheetName2 = (email != DEFAULT_STRING) ? Constants.WORKSHEET_CONTACT : DEFAULT_STRING; issue.RowName2 = (email != DEFAULT_STRING) ? email : DEFAULT_STRING; } issue.Description = (string.IsNullOrEmpty(ifcApproval.Description.ToString())) ? DEFAULT_STRING : ifcApproval.Description.ToString(); propValues = GetPropertyEnumValue(propertyList, "RiskOwner"); issue.Owner = propValues.Value; propValues = GetPropertyValue(propertyList, "PreventiveMeasures"); issue.Mitigation = propValues.Value; issue.ExtSystem = (ifcPropertySet != null) ? GetExternalSystem(ifcPropertySet) : DEFAULT_STRING; issue.ExtObject = ifcApproval.GetType().Name; issue.ExtIdentifier = ifcApproval.Identifier.ToString(); issues.AddRow(issue); } ProgressIndicator.Finalise(); #endregion #region HS_Risk_UK // get all HS_Risk_UK Issues IEnumerable <IfcPropertySet> ifcProperties = Model.FederatedInstances.OfType <IfcPropertySet>().Where(ps => ps.Name.ToString() == "HS_Risk_UK"); ProgressIndicator.Initialise("Creating Issues (from HS_Risk_UK psets)", ifcProperties.Count()); foreach (IfcPropertySet propSet in ifcProperties) { ProgressIndicator.IncrementAndUpdate(); COBieIssueRow issue = new COBieIssueRow(issues); List <IfcSimpleProperty> HSpropertyList = propSet.HasProperties.OfType <IfcSimpleProperty>().ToList(); Interval propValues = GetPropertyValue(HSpropertyList, "RiskName"); issue.Name = (propValues.Value == DEFAULT_STRING) ? propSet.Name.ToString() : propValues.Value.ToString(); // //lets default the creator to that user who created the project for now, no direct link to OwnerHistory on IfcApproval if (propSet != null) { //use "Pset_Risk" Property Set as source for this issue.CreatedBy = GetTelecomEmailAddress(propSet.OwnerHistory); issue.CreatedOn = GetCreatedOnDateAsFmtString(propSet.OwnerHistory); } else { //if property set is null use project defaults issue.CreatedBy = GetTelecomEmailAddress(ifcProject.OwnerHistory); issue.CreatedOn = GetCreatedOnDateAsFmtString(ifcProject.OwnerHistory); } propValues = GetPropertyValue(HSpropertyList, "RiskCategory"); issue.Type = propValues.Value; propValues = GetPropertyValue(HSpropertyList, "LevelOfRisk"); issue.Risk = propValues.Value; propValues = GetPropertyValue(HSpropertyList, "RiskLikelihood"); issue.Chance = propValues.Value; propValues = GetPropertyValue(HSpropertyList, "RiskConsequence"); issue.Impact = propValues.Value; //TODO: We need to extend the functionality here as right now we make some assumptions: //1. The Issue SheetName1/RowName1 refers to a Component attached to the property set (it could be something else) //2. The component has an associated space, which makes up Sheetname2/Rowname2 IfcRoot ifcRoot = GetAssociatedObject(propSet); issue.SheetName1 = GetSheetByObjectType(ifcRoot.GetType()); issue.RowName1 = (!string.IsNullOrEmpty(ifcRoot.Name.ToString())) ? ifcRoot.Name.ToString() : DEFAULT_STRING; var SpaceBoundingBoxInfo = new List <SpaceInfo>(); issue.RowName2 = COBieHelpers.GetComponentRelatedSpace(ifcRoot as IfcElement, Model, SpaceBoundingBoxInfo, Context); issue.SheetName2 = "Space"; //End TODO propValues = GetPropertyValue(HSpropertyList, "RiskDescription"); issue.Description = (propValues.Value == DEFAULT_STRING) ? propSet.Name.ToString() : propValues.Value.ToString(); propValues = GetPropertyValue(HSpropertyList, "OwnerDiscipline"); issue.Owner = propValues.Value; propValues = GetPropertyValue(HSpropertyList, "AgreedMitigation"); issue.Mitigation = propValues.Value; issue.ExtSystem = (propSet != null) ? GetExternalSystem(propSet) : DEFAULT_STRING; issue.ExtObject = "HS_Risk_UK"; issue.ExtIdentifier = propSet.GlobalId.ToString();//ifcApproval.Identifier.ToString(); // issues.AddRow(issue); } issues.OrderBy(s => s.Name); ProgressIndicator.Finalise(); #endregion #region PSet_Risk // get all PSet_Risk issues ifcProperties = Model.FederatedInstances.OfType <IfcPropertySet>().Where(ps => ps.Name.ToString() == "PSet_Risk"); ProgressIndicator.Initialise("Creating Issues (from PSet_Risk)", ifcProperties.Count()); foreach (IfcPropertySet propSet in ifcProperties) { ProgressIndicator.IncrementAndUpdate(); COBieIssueRow issue = new COBieIssueRow(issues); List <IfcSimpleProperty> RiskpropertyList = propSet.HasProperties.OfType <IfcSimpleProperty>().ToList(); Interval propValues = GetPropertyValue(RiskpropertyList, "RiskName"); issue.Name = (propValues.Value == DEFAULT_STRING) ? propSet.Name.ToString() : propValues.Value.ToString(); //TODO: Fill in the rest of these properties issues.AddRow(issue); } ProgressIndicator.Finalise(); #endregion issues.OrderBy(s => s.Name); return(issues); }
public MaterialHash(IfcRoot root, IfcMaterialSelect material) { _root = root; _material = material; _hash = _material.CreateHashCode(); }
public string GetClassification(IfcRoot classifiedObject) { IfcClassificationReference classification; if (_classifiedObjects.TryGetValue(classifiedObject, out classification)) { if (classification.ItemReference == classification.Name) { return(classification.ItemReference); } return(classification.ItemReference + ": " + classification.Name); } //if the object is an IfcObject we might be able to get a classification from its aggregating type var ifcObject = classifiedObject as IfcObject; if (ifcObject != null) { var definingTypeObject = GetDefiningTypeObject(ifcObject); //do we have a defining type if (definingTypeObject != null) { if (_classifiedObjects.TryGetValue(definingTypeObject, out classification)) { if (classification.ItemReference == classification.Name) { return(classification.ItemReference); } return(classification.ItemReference + ": " + classification.Name); } } } if (classifiedObject.EntityLabel == 11640) { } if (classifiedObject is IfcSpace) { var val = _attributedObjects[(IfcSpace)classifiedObject]; string classificationName = ""; val.GetSimplePropertyValue("PSet_Revit_Identity Data.OmniClass Table 13 Category", out classificationName); if (classificationName != null) { return(classificationName); } } else if (classifiedObject is IfcTypeObject) { if (_definingTypeObjectMap.ContainsKey((IfcTypeObject)classifiedObject)) { var obj = _definingTypeObjectMap[(IfcTypeObject)classifiedObject].FirstOrDefault(); if (obj != null) { // PSet_Revit_Type_Other.Classification Code var cfg = new string[] { "SimpleProp(PSet_Revit_Type_Other.Classification Code): SimpleProp(PSet_Revit_Type_Other.Classification Description)", "SimpleProp(PSet_Revit_Type_Identity Data.OmniClass Number): SimpleProp(PSet_Revit_Type_Identity Data.OmniClass Title)" }; var val = _attributedObjects[obj]; string pattern = @"SimpleProp\(([^\)]*)\)"; Regex regex = new Regex(pattern); foreach (var ClassificationRule in cfg) { bool ok = true; string result = ClassificationRule; var mts = regex.Matches(ClassificationRule); foreach (Match mt in mts) { string PropName = mt.Groups[1].Value; string PropVal = ""; val.GetSimplePropertyValue(PropName, out PropVal); if (PropVal == null) { ok = false; break; } result = result.Replace("SimpleProp(" + PropName + ")", PropVal); } if (ok) { return(result); } } } } } return(null); }
public Dictionary <IfcRoot, ChangeType> Compare(IEnumerable <IfcRoot> baseline, IEnumerable <IfcRoot> delta) { //Create our dictionary for return Dictionary <IfcRoot, ChangeType> changes = new Dictionary <IfcRoot, ChangeType>(); //Work from copies so we can alter collections List <IfcRoot> Baseline = new List <IfcRoot>(baseline); List <IfcRoot> Delta = new List <IfcRoot>(delta); foreach (var i in baseline) { //Try to get the item in baseline and revisions IfcRoot r = null; try { var c = Delta.Where(x => x.GlobalId == i.GlobalId); //Check if we have a single matching result if (c.Count() == 1) { r = c.First(); } else if (c.Count() > 1) //If we have multiple results, we can't resolve this item by guid, so mark as unknown, and break { if (!changes.ContainsKey(i)) { changes.Add(i, ChangeType.Unknown); } break; } } catch (Exception) { } //If we have a match, then remove from our diff list list if (i != null && r != null) { Baseline.Remove(i); Delta.Remove(r); if (!changes.ContainsKey(i)) { changes.Add(i, ChangeType.Matched); } map.Add(i.EntityLabel, r.EntityLabel); } } //Anything left in baseline is only in the original (ie it's been deleted) foreach (var i in Baseline) { if (!changes.ContainsKey(i)) { changes.Add(i, ChangeType.Deleted); } } //Anything left in revprods is an addition foreach (var i in Delta) { if (!changes.ContainsKey(i)) { changes.Add(i, ChangeType.Added); } } return(changes); }