Пример #1
1
        /// <summary>
        /// Create and setup objects held in the Component COBieSheet
        /// </summary>
        /// <param name="cOBieSheet">COBieSheet of COBieComponentRow to read data from</param>
        public void SerialiseComponent(COBieSheet<COBieComponentRow> cOBieSheet)
        {
            using (XbimReadWriteTransaction trans = Model.BeginTransaction("Add Component"))
            {

                try
                {
                    int count = 1;
                    IfcTypeObjects = Model.Instances.OfType<IfcTypeObject>();
                    IfcSpaces = Model.Instances.OfType<IfcSpace>();
                    IfcBuildingStoreys = Model.Instances.OfType<IfcBuildingStorey>();
                    ProgressIndicator.ReportMessage("Starting Components...");
                    ProgressIndicator.Initialise("Creating Components", cOBieSheet.RowCount);
                    for (int i = 0; i < cOBieSheet.RowCount; i++)
                    {
                        BumpTransaction(trans, count);
                        count++;
                        ProgressIndicator.IncrementAndUpdate();
                        COBieComponentRow row = cOBieSheet[i]; 
                        AddComponent(row);
                    }

                    ProgressIndicator.Finalise();
                    trans.Commit();

                }
                catch (Exception)
                {
                    //TODO: Catch with logger?
                    throw;
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Create and setup objects held in the Zone COBieSheet
        /// </summary>
        /// <param name="cOBieSheet">COBieSheet of COBieZoneRow to read data from</param>
        public void SerialiseZone(COBieSheet<COBieZoneRow> cOBieSheet)
        {
            using (XbimReadWriteTransaction trans = Model.BeginTransaction("Add Zone"))
            {
                try
                {

                    int count = 1;
                    ProgressIndicator.ReportMessage("Starting Zones...");
                    ProgressIndicator.Initialise("Creating Zones", cOBieSheet.RowCount);
                    for (int i = 0; i < cOBieSheet.RowCount; i++)
                    {
                        BumpTransaction(trans, count);
                        count++;
                        ProgressIndicator.IncrementAndUpdate();
                        COBieZoneRow row = cOBieSheet[i];
                        AddZone(row);
                    }

                    ProgressIndicator.Finalise();
                    trans.Commit();

                }
                catch (Exception)
                {
                    //TODO: Catch with logger?
                    throw;
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Add the child row and overflow rows
        /// </summary>
        /// <param name="assemblies">COBieSheet to add rows too</param>
        /// <param name="assembly">COBieAssemblyRow object to copy data from</param>
        /// <param name="childNames">ChildNamesList object holing the names to add to the rows</param>
        private void AddChildRows(COBieSheet <COBieAssemblyRow> assemblies, COBieAssemblyRow assembly, ChildNamesList childNames)
        {
            COBieAssemblyRow assemblyCont = null;
            int index = 0;

            foreach (string childStr in childNames)
            {
                if (index == 0)
                {
                    assembly.ChildNames = childStr;
                    assemblies.AddRow(assembly);
                }
                else
                {
                    assemblyCont               = new COBieAssemblyRow(assemblies);
                    assemblyCont.Name          = assembly.Name + " : continued " + index.ToString();
                    assemblyCont.CreatedBy     = assembly.CreatedBy;
                    assemblyCont.CreatedOn     = assembly.CreatedOn;
                    assemblyCont.SheetName     = assembly.SheetName;
                    assemblyCont.ParentName    = assembly.ParentName;
                    assemblyCont.AssemblyType  = assembly.AssemblyType;
                    assemblyCont.ExtSystem     = assembly.ExtSystem;
                    assemblyCont.ExtObject     = assembly.ExtObject;
                    assemblyCont.ExtIdentifier = assembly.ExtIdentifier;
                    assemblyCont.Description   = assembly.Description;
                    assemblyCont.ChildNames    = childStr;
                    assemblies.AddRow(assemblyCont);
                }
                index = ++index;
            }
        }
Пример #4
0
        /// <summary>
        /// Create and setup objects held in the Type COBieSheet
        /// </summary>
        /// <param name="cOBieSheet">COBieSheet of COBieTypeRow to read data from</param>
        public void SerialiseType(COBieSheet<COBieTypeRow> cOBieSheet)
        {
            using (XbimReadWriteTransaction trans = Model.BeginTransaction("Add Type"))
            {
                try
                {
                    int count = 1;
                    ProgressIndicator.ReportMessage("Starting Types...");
                    ProgressIndicator.Initialise("Creating Types", cOBieSheet.RowCount);
                    for (int i = 0; i < cOBieSheet.RowCount; i++)
                    {
                        BumpTransaction(trans, count);
                        count++;
                        ProgressIndicator.IncrementAndUpdate();
                        COBieTypeRow row = cOBieSheet[i];
                        if ((ValidateString(row.ExtObject)) &&
                            (row.ExtObject.ToLower().Contains("ifcmaterial"))
                            )
                            AddMaterial(row);
                        else
                            AddType(row);
                    }

                    ProgressIndicator.Finalise();
                    trans.Commit();
                }
                catch (Exception)
                {
                    //TODO: Catch with logger?
                    throw;
                }
            }
        }
Пример #5
0
 /// <summary>
 /// Add Properties back to component and type objects
 /// </summary>
 /// <param name="cOBieSheet">COBieSheet of COBieAttributeRow to read data from</param>
 public void SerialiseAttribute(COBieSheet <COBieAttributeRow> cOBieSheet)
 {
     using (XbimReadWriteTransaction trans = Model.BeginTransaction("Add Attribute"))
     {
         try
         {
             int count      = 1;
             var sortedRows = cOBieSheet.Rows.OrderBy(r => r.SheetName).ThenBy(r => r.RowName);
             ProgressIndicator.ReportMessage("Starting Attributes...");
             ProgressIndicator.Initialise("Creating Attributes", cOBieSheet.RowCount);
             foreach (COBieAttributeRow row in sortedRows)
             {
                 BumpTransaction(trans, count);
                 count++;
                 ProgressIndicator.IncrementAndUpdate();
                 AddAttribute(row);
             }
             ProgressIndicator.Finalise();
             trans.Commit();
         }
         catch (Exception)
         {
             //TODO: Catch with logger?
             throw;
         }
     }
 }
Пример #6
0
        /// <summary>
        /// Add the IfcConstructionProductResource to the Model object
        /// </summary>
        /// <param name="cOBieSheet">COBieSheet of COBieSpareRow to read data from</param>
        public void SerialiseSpare(COBieSheet <COBieSpareRow> cOBieSheet)
        {
            using (XbimReadWriteTransaction trans = Model.BeginTransaction("Add Spare"))
            {
                try
                {
                    int count = 1;
                    IfcTypeObjects = Model.FederatedInstances.OfType <IfcTypeObject>();

                    ProgressIndicator.ReportMessage("Starting Spares...");
                    ProgressIndicator.Initialise("Creating Spares", cOBieSheet.RowCount);
                    for (int i = 0; i < cOBieSheet.RowCount; i++)
                    {
                        BumpTransaction(trans, count);
                        count++;
                        ProgressIndicator.IncrementAndUpdate();
                        COBieSpareRow row = cOBieSheet[i];
                        AddSpare(row);
                    }
                    ProgressIndicator.Finalise();
                    trans.Commit();
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
Пример #7
0
        /// <summary>
        /// Add the IfcConstructionProductResource to the Model object
        /// </summary>
        /// <param name="cOBieSheet">COBieSheet of COBieSpareRow to read data from</param>
        public void SerialiseSpare(COBieSheet<COBieSpareRow> cOBieSheet)
        {

            using (XbimReadWriteTransaction trans = Model.BeginTransaction("Add Spare"))
            {
                try
                {
                    int count = 1;
                    IfcTypeObjects = Model.Instances.OfType<IfcTypeObject>();

                    ProgressIndicator.ReportMessage("Starting Spares...");
                    ProgressIndicator.Initialise("Creating Spares", cOBieSheet.RowCount);
                    for (int i = 0; i < cOBieSheet.RowCount; i++)
                    {
                        BumpTransaction(trans, count);
                        count++;
                        ProgressIndicator.IncrementAndUpdate();
                        COBieSpareRow row = cOBieSheet[i];
                        AddSpare(row);
                    }
                    ProgressIndicator.Finalise();
                    trans.Commit();
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
        /// <summary>
        /// Create and setup objects held in the Component COBieSheet
        /// </summary>
        /// <param name="cOBieSheet">COBieSheet of COBieComponentRow to read data from</param>
        public void SerialiseComponent(COBieSheet <COBieComponentRow> cOBieSheet)
        {
            using (var trans = Model.BeginTransaction("Add Component"))
            {
                try
                {
                    var count = 1;
                    IfcTypeObjects     = Model.FederatedInstances.OfType <IfcTypeObject>();
                    IfcSpaces          = Model.FederatedInstances.OfType <IfcSpace>();
                    IfcBuildingStoreys = Model.FederatedInstances.OfType <IfcBuildingStorey>();
                    ProgressIndicator.ReportMessage("Starting Components...");
                    ProgressIndicator.Initialise("Creating Components", cOBieSheet.RowCount);
                    for (var i = 0; i < cOBieSheet.RowCount; i++)
                    {
                        BumpTransaction(trans, count);
                        count++;
                        ProgressIndicator.IncrementAndUpdate();
                        var row = cOBieSheet[i];
                        AddComponent(row);
                    }

                    ProgressIndicator.Finalise();
                    trans.Commit();
                }
                catch (Exception)
                {
                    //TODO: Catch with logger?
                    throw;
                }
            }
        }
Пример #9
0
 /// <summary>
 /// Add Properties back to component and type objects
 /// </summary>
 /// <param name="cOBieSheet">COBieSheet of COBieAttributeRow to read data from</param>
 public void SerialiseAttribute(COBieSheet<COBieAttributeRow> cOBieSheet)
 {
     using (XbimReadWriteTransaction trans = Model.BeginTransaction("Add Attribute"))
     {
         try
         {
             int count = 1;
             var sortedRows = cOBieSheet.Rows.OrderBy(r => r.SheetName).ThenBy(r => r.RowName);
             ProgressIndicator.ReportMessage("Starting Attributes...");
             ProgressIndicator.Initialise("Creating Attributes", cOBieSheet.RowCount);
             foreach (COBieAttributeRow row in sortedRows)
             {
                 BumpTransaction(trans, count);
                 count++;
                 ProgressIndicator.IncrementAndUpdate();
                 AddAttribute(row);
                 
             }
             ProgressIndicator.Finalise();
             trans.Commit();
         }
         catch (Exception)
         {
             //TODO: Catch with logger?
             throw;
         }
     }
 }
Пример #10
0
 /// <summary>
 /// Add the IfcDocumentInformation to the Model object
 /// </summary>
 /// <param name="cOBieSheet">COBieSheet of COBieDocumentRow to read data from</param>
 public void SerialiseDocument(COBieSheet <COBieDocumentRow> cOBieSheet)
 {
     using (ITransaction trans = Model.BeginTransaction("Add Document"))
     {
         try
         {
             int count = 1;
             ProgressIndicator.ReportMessage("Starting Documents...");
             ProgressIndicator.Initialise("Creating Documents", cOBieSheet.RowCount);
             for (int i = 0; i < cOBieSheet.RowCount; i++)
             {
                 BumpTransaction(trans, count);
                 count++;
                 ProgressIndicator.IncrementAndUpdate();
                 COBieDocumentRow row = cOBieSheet[i];
                 AddDocument(row);
             }
             ProgressIndicator.Finalise();
             trans.Commit();
         }
         catch (Exception)
         {
             throw;
         }
     }
 }
Пример #11
0
        /// <summary>
        /// Create and setup objects held in the Issue COBieSheet
        /// </summary>
        /// <param name="cOBieSheet">COBieSheet of COBieIssueRow to read data from</param>
        public void SerialiseIssue(COBieSheet <COBieIssueRow> cOBieSheet)
        {
            using (XbimReadWriteTransaction trans = Model.BeginTransaction("Add Issue"))
            {
                try
                {
                    int count = 1;
                    ProgressIndicator.ReportMessage("Starting Issues...");
                    ProgressIndicator.Initialise("Creating Issues", cOBieSheet.RowCount);
                    for (int i = 0; i < cOBieSheet.RowCount; i++)
                    {
                        BumpTransaction(trans, count);
                        count++;
                        ProgressIndicator.IncrementAndUpdate();
                        COBieIssueRow row = cOBieSheet[i];
                        AddIssue(row);
                    }

                    ProgressIndicator.Finalise();
                    trans.Commit();
                }
                catch (Exception)
                {
                    //TODO: Catch with logger?
                    throw;
                }
            }
        }
Пример #12
0
        /// <summary>
        /// Create and setup objects held in the Connection COBieSheet
        /// </summary>
        /// <param name="cOBieSheet">COBieSheet of COBieConnectionRow to read data from</param>
        public void SerialiseConnection(COBieSheet <COBieConnectionRow> cOBieSheet)
        {
            using (ITransaction trans = Model.BeginTransaction("Add Connection"))
            {
                try
                {
                    int count = 1;
                    IfcElements = Model.FederatedInstances.OfType <IfcElement>();

                    ProgressIndicator.ReportMessage("Starting Connections...");
                    ProgressIndicator.Initialise("Creating Connections", cOBieSheet.RowCount);
                    for (int i = 0; i < cOBieSheet.RowCount; i++)
                    {
                        BumpTransaction(trans, count);
                        count++;
                        ProgressIndicator.IncrementAndUpdate();
                        COBieConnectionRow row = cOBieSheet[i];
                        AddConnection(row);
                    }

                    ProgressIndicator.Finalise();
                    trans.Commit();
                }
                catch (Exception)
                {
                    //TODO: Catch with logger?
                    throw;
                }
            }
        }
Пример #13
0
        // <summary>
        /// Create and setup objects held in the System COBieSheet
        /// </summary>
        /// <param name="cOBieSheet">COBieSheet of COBieSystemRow to read data from</param>
        public void SerialiseSystem(COBieSheet<COBieSystemRow> cOBieSheet)
        {
            using (XbimReadWriteTransaction trans = Model.BeginTransaction("Add System"))
            {

                try
                {

                    int count = 1;
                    ProgressIndicator.ReportMessage("Starting Systems...");
                    ProgressIndicator.Initialise("Creating Systems", cOBieSheet.RowCount);
                    for (int i = 0; i < cOBieSheet.RowCount; i++)
                    {
                        BumpTransaction(trans, count);
                        count++;
                        ProgressIndicator.IncrementAndUpdate();
                        COBieSystemRow row = cOBieSheet[i];
                        if (ValidateString(row.Name))
                        {
                            if ((IfcSystemObj == null) ||
                                (row.Name.ToLower() != IfcSystemObj.Name.ToString().ToLower())
                                )
                            {
                                AddSystem(row);
                                AddProducts(row);
                                SystemProdutIndex = 1;
                            }
                            else
                            {
                                AddProducts(row);
                            }
                        }
                    }

                    ProgressIndicator.Finalise();                    
                    trans.Commit();

                }
                catch (Exception)
                {
                    //TODO: Catch with logger?
                    throw;
                }
            }
        }
Пример #14
0
        /// <summary>
        /// Add the IfcTask to the Model object
        /// </summary>
        /// <param name="cOBieSheet">COBieSheet of COBieResourceRow to read data from</param>
        public void SerialiseJob(COBieSheet<COBieJobRow> cOBieSheet)
        {

            using (XbimReadWriteTransaction trans = Model.BeginTransaction("Add Job"))
            {
                try
                {
                    int count = 1;
                    IfcTypeObjects = Model.Instances.OfType<IfcTypeObject>();
                    IfcConstructionEquipmentResources = Model.Instances.OfType<IfcConstructionEquipmentResource>();

                    ProgressIndicator.ReportMessage("Starting Jobs...");
                    ProgressIndicator.Initialise("Creating Jobs", (cOBieSheet.RowCount * 2));
                    for (int i = 0; i < cOBieSheet.RowCount; i++)
                    {
                        BumpTransaction(trans, count);
                        count++;
                        ProgressIndicator.IncrementAndUpdate();
                        COBieJobRow row = cOBieSheet[i];
                        AddJob(row);
                        
                    }
                    //we need to assign IfcRelSequence relationships, but we need all tasks implemented, so loop rows again
                    IfcTasks = Model.Instances.OfType<IfcTask>(); //get new tasks
                    for (int i = 0; i < cOBieSheet.RowCount; i++)
                    {
                        BumpTransaction(trans, count);
                        ProgressIndicator.IncrementAndUpdate();
                        COBieJobRow row = cOBieSheet[i];
                        SetPriors(row);
                        count++;
                    }
                    ProgressIndicator.Finalise();
                    
                    trans.Commit();
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
Пример #15
0
        /// <summary>
        /// Create and setup objects held in the System COBieSheet
        /// </summary>
        /// <param name="cOBieSheet">COBieSheet of COBieSystemRow to read data from</param>
        public void SerialiseSystem(COBieSheet <COBieSystemRow> cOBieSheet)
        {
            using (ITransaction trans = Model.BeginTransaction("Add System"))
            {
                try
                {
                    int count = 1;
                    ProgressIndicator.ReportMessage("Starting Systems...");
                    ProgressIndicator.Initialise("Creating Systems", cOBieSheet.RowCount);
                    for (int i = 0; i < cOBieSheet.RowCount; i++)
                    {
                        BumpTransaction(trans, count);
                        count++;
                        ProgressIndicator.IncrementAndUpdate();
                        COBieSystemRow row = cOBieSheet[i];
                        if (ValidateString(row.Name))
                        {
                            if ((IfcSystemObj == null) ||
                                (row.Name.ToLower() != IfcSystemObj.Name.ToString().ToLower())
                                )
                            {
                                AddSystem(row);
                                AddProducts(row);
                                SystemProdutIndex = 1;
                            }
                            else
                            {
                                AddProducts(row);
                            }
                        }
                    }

                    ProgressIndicator.Finalise();
                    trans.Commit();
                }
                catch (Exception)
                {
                    //TODO: Catch with logger?
                    throw;
                }
            }
        }
Пример #16
0
        /// <summary>
        /// Add the IfcPersonAndOrganizations to the Model object
        /// </summary>
        /// <param name="cOBieSheet"></param>
        public void SerialiseContacts(COBieSheet<COBieContactRow> cOBieSheet)
        {

            
                    
            using (XbimReadWriteTransaction trans = Model.BeginTransaction("Add Contacts"))
            {
                try
                {
                    int count = 1;
                    SetEmailUser(Constants.DEFAULT_EMAIL); //add [email protected] PersonAndOrganization to use for nulls
                    SetDefaultUser();
                    ProgressIndicator.ReportMessage("Starting Contacts...");
                    ProgressIndicator.Initialise("Creating Contacts", cOBieSheet.RowCount);
                    for (int i = 0; i < cOBieSheet.RowCount; i++)
                    {
                        BumpTransaction(trans, count);
                        count++;
                        ProgressIndicator.IncrementAndUpdate();
                        COBieContactRow row = cOBieSheet[i];
                        CreatePersonAndOrganization(row);

                    }
                    ProgressIndicator.Finalise();
                    trans.Commit();
                }
                catch (Exception)
                {
                    throw;
                }
            }

            //IfcPersonAndOrganization thisContact = new IfcPersonAndOrganization();
            //XbimMemoryModel model = _model as XbimMemoryModel;
            //if (model != null)
            //{
            //    model.Instances.Add(thisContact);
            //}
            //IEnumerable<IfcPersonAndOrganization> ifcPersonAndOrganizations = Model.Instances.OfType<IfcPersonAndOrganization>();
            //string xxx = ifcPersonAndOrganizations.First().ThePerson.GivenName;
        }
Пример #17
0
        /// <summary>
        /// Add the IfcTask to the Model object
        /// </summary>
        /// <param name="cOBieSheet">COBieSheet of COBieResourceRow to read data from</param>
        public void SerialiseJob(COBieSheet <COBieJobRow> cOBieSheet)
        {
            using (XbimReadWriteTransaction trans = Model.BeginTransaction("Add Job"))
            {
                try
                {
                    int count = 1;
                    IfcTypeObjects = Model.Instances.OfType <IfcTypeObject>();
                    IfcConstructionEquipmentResources = Model.Instances.OfType <IfcConstructionEquipmentResource>();

                    ProgressIndicator.ReportMessage("Starting Jobs...");
                    ProgressIndicator.Initialise("Creating Jobs", (cOBieSheet.RowCount * 2));
                    for (int i = 0; i < cOBieSheet.RowCount; i++)
                    {
                        BumpTransaction(trans, count);
                        count++;
                        ProgressIndicator.IncrementAndUpdate();
                        COBieJobRow row = cOBieSheet[i];
                        AddJob(row);
                    }
                    //we need to assign IfcRelSequence relationships, but we need all tasks implemented, so loop rows again
                    IfcTasks = Model.Instances.OfType <IfcTask>(); //get new tasks
                    for (int i = 0; i < cOBieSheet.RowCount; i++)
                    {
                        BumpTransaction(trans, count);
                        ProgressIndicator.IncrementAndUpdate();
                        COBieJobRow row = cOBieSheet[i];
                        SetPriors(row);
                        count++;
                    }
                    ProgressIndicator.Finalise();

                    trans.Commit();
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
Пример #18
0
        /// <summary>
        /// Add the IfcPersonAndOrganizations to the Model object
        /// </summary>
        /// <param name="cOBieSheet"></param>
        public void SerialiseAssembly(COBieSheet <COBieAssemblyRow> cOBieSheet)
        {
            using (XbimReadWriteTransaction trans = Model.BeginTransaction("Add Assembly"))
            {
                try
                {
                    int count = 1;
                    IfcElements       = Model.FederatedInstances.OfType <IfcElement>();
                    IfcTypeObjects    = Model.FederatedInstances.OfType <IfcTypeObject>();
                    IfcMaterialLayers = Model.FederatedInstances.OfType <IfcMaterialLayer>();

                    ProgressIndicator.ReportMessage("Starting Assemblies...");
                    ProgressIndicator.Initialise("Creating Assemblies", cOBieSheet.RowCount);
                    for (int i = 0; i < cOBieSheet.RowCount; i++)
                    {
                        BumpTransaction(trans, count);
                        count++;
                        ProgressIndicator.IncrementAndUpdate();
                        COBieAssemblyRow row     = cOBieSheet[i];
                        string           objType = row.ExtObject.ToLower().Trim();
                        if (objType.Contains("ifcmaterial"))
                        {
                            AddMaterial(row);
                        }
                        else
                        {
                            AddAssembly(row);
                        }

                        LastRow = row;
                    }
                    ProgressIndicator.Finalise();
                    trans.Commit();
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
Пример #19
0
        /// <summary>
        /// Add the IfcPersonAndOrganizations to the Model object
        /// </summary>
        /// <param name="cOBieSheet"></param>
        public void SerialiseAssembly(COBieSheet<COBieAssemblyRow> cOBieSheet)
        {

            using (XbimReadWriteTransaction trans = Model.BeginTransaction("Add Assembly"))
            {
                try
                {
                    int count = 1;
                    IfcElements = Model.Instances.OfType<IfcElement>();
                    IfcTypeObjects = Model.Instances.OfType<IfcTypeObject>();
                    IfcMaterialLayers = Model.Instances.OfType<IfcMaterialLayer>();

                    ProgressIndicator.ReportMessage("Starting Assemblies...");
                    ProgressIndicator.Initialise("Creating Assemblies", cOBieSheet.RowCount);
                    for (int i = 0; i < cOBieSheet.RowCount; i++)
                    {
                        BumpTransaction(trans, count);
                        count++;
                        ProgressIndicator.IncrementAndUpdate();
                        COBieAssemblyRow row = cOBieSheet[i];
                        string objType = row.ExtObject.ToLower().Trim();
                        if (objType.Contains("ifcmaterial"))
                            AddMaterial(row);
                        else
                            AddAssembly(row);
                        
                        LastRow = row;
                        

                    }
                    ProgressIndicator.Finalise();
                    trans.Commit();
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
Пример #20
0
        /// <summary>
        /// Create and setup objects held in the Facility COBieSheet
        /// </summary>
        /// <param name="cOBieSheet">COBieSheet of COBieFacilityRows to read data from</param>
        public void SerialiseFacility(COBieSheet<COBieFacilityRow> cOBieSheet)
        {
            using (XbimReadWriteTransaction trans = Model.BeginTransaction("Add Facility"))
            {
                try
                {
                    ProgressIndicator.ReportMessage("Starting Facility...");
                    ProgressIndicator.Initialise("Creating Facility", 3);
                    
                    //Assume we have only one site and one building to a project
                    COBieFacilityRow row = cOBieSheet[0];
                    ProgressIndicator.IncrementAndUpdate();
                    SetUpProject(row);

                    ProgressIndicator.IncrementAndUpdate();
                    CreateSite(row);

                    ProgressIndicator.IncrementAndUpdate();
                    CreateBuilding(row);

                    //set up relationships
                    GetSite().AddBuilding(GetBuilding());
                    Model.IfcProject.AddSite(GetSite());

                    ProgressIndicator.Finalise();
                   

                    trans.Commit();
                }
                catch (Exception)
                {
                    //TODO: Catch with logger?
                    throw;
                }

                
            }
        }
Пример #21
0
        /// <summary>
        /// Add the IfcPersonAndOrganizations to the Model object
        /// </summary>
        /// <param name="cOBieSheet"></param>
        public void SerialiseContacts(COBieSheet <COBieContactRow> cOBieSheet)
        {
            using (XbimReadWriteTransaction trans = Model.BeginTransaction("Add Contacts"))
            {
                try
                {
                    int count = 1;
                    SetEmailUser(Constants.DEFAULT_EMAIL); //add [email protected] PersonAndOrganization to use for nulls
                    SetDefaultUser();
                    ProgressIndicator.ReportMessage("Starting Contacts...");
                    ProgressIndicator.Initialise("Creating Contacts", cOBieSheet.RowCount);
                    for (int i = 0; i < cOBieSheet.RowCount; i++)
                    {
                        BumpTransaction(trans, count);
                        count++;
                        ProgressIndicator.IncrementAndUpdate();
                        COBieContactRow row = cOBieSheet[i];
                        CreatePersonAndOrganization(row);
                    }
                    ProgressIndicator.Finalise();
                    trans.Commit();
                }
                catch (Exception)
                {
                    throw;
                }
            }

            //IfcPersonAndOrganization thisContact = new IfcPersonAndOrganization();
            //XbimMemoryModel model = _model as XbimMemoryModel;
            //if (model != null)
            //{
            //    model.Instances.Add(thisContact);
            //}
            //IEnumerable<IfcPersonAndOrganization> ifcPersonAndOrganizations = Model.Instances.OfType<IfcPersonAndOrganization>();
            //string xxx = ifcPersonAndOrganizations.First().ThePerson.GivenName;
        }
Пример #22
0
        /// <summary>
        /// Create and setup objects held in the Type COBieSheet
        /// </summary>
        /// <param name="cOBieSheet">COBieSheet of COBieTypeRow to read data from</param>
        public void SerialiseType(COBieSheet <COBieTypeRow> cOBieSheet)
        {
            using (XbimReadWriteTransaction trans = Model.BeginTransaction("Add Type"))
            {
                try
                {
                    int count = 1;
                    ProgressIndicator.ReportMessage("Starting Types...");
                    ProgressIndicator.Initialise("Creating Types", cOBieSheet.RowCount);
                    for (int i = 0; i < cOBieSheet.RowCount; i++)
                    {
                        BumpTransaction(trans, count);
                        count++;
                        ProgressIndicator.IncrementAndUpdate();
                        COBieTypeRow row = cOBieSheet[i];
                        if ((ValidateString(row.ExtObject)) &&
                            (row.ExtObject.ToLower().Contains("ifcmaterial"))
                            )
                        {
                            AddMaterial(row);
                        }
                        else
                        {
                            AddType(row);
                        }
                    }

                    ProgressIndicator.Finalise();
                    trans.Commit();
                }
                catch (Exception)
                {
                    //TODO: Catch with logger?
                    throw;
                }
            }
        }
Пример #23
0
        /// <summary>
        /// set the default IfcPersonAndOrganization in the Model
        /// </summary>
        public void SetDefaultUser()
        {
            COBieSheet <COBieFacilityRow> facilityRow = (COBieSheet <COBieFacilityRow>)WorkBook[Constants.WORKSHEET_FACILITY];

            if (facilityRow.RowCount > 0)
            {
                COBieFacilityRow row = facilityRow[0]; //use first row supported on facility sheet

                string defaultUser = "";
                if ((!string.IsNullOrEmpty(row.CreatedBy)) || (row.CreatedBy != Constants.DEFAULT_STRING))
                {
                    defaultUser = row.CreatedBy;
                }
                COBieSheet <COBieContactRow> contacts = (COBieSheet <COBieContactRow>)WorkBook[Constants.WORKSHEET_CONTACT];
                for (int i = 0; i < contacts.RowCount; i++)
                {
                    if (contacts[i].Email == defaultUser)
                    {
                        CreatePersonAndOrganization(contacts[i], Model.DefaultOwningUser);
                        break;
                    }
                }
            }
        }
Пример #24
0
        /// <summary>
        /// Create and setup objects held in the Facility COBieSheet
        /// </summary>
        /// <param name="cOBieSheet">COBieSheet of COBieFacilityRows to read data from</param>
        public void SerialiseFacility(COBieSheet <COBieFacilityRow> cOBieSheet)
        {
            using (XbimReadWriteTransaction trans = Model.BeginTransaction("Add Facility"))
            {
                try
                {
                    ProgressIndicator.ReportMessage("Starting Facility...");
                    ProgressIndicator.Initialise("Creating Facility", 3);

                    //Assume we have only one site and one building to a project
                    COBieFacilityRow row = cOBieSheet[0];
                    ProgressIndicator.IncrementAndUpdate();
                    SetUpProject(row);

                    ProgressIndicator.IncrementAndUpdate();
                    CreateSite(row);

                    ProgressIndicator.IncrementAndUpdate();
                    CreateBuilding(row);

                    //set up relationships
                    GetSite().AddBuilding(GetBuilding());
                    Model.IfcProject.AddSite(GetSite());

                    ProgressIndicator.Finalise();


                    trans.Commit();
                }
                catch (Exception)
                {
                    //TODO: Catch with logger?
                    throw;
                }
            }
        }
Пример #25
0
        /// <summary>
        /// Fill sheet rows for Resource sheet
        /// </summary>
        /// <returns>COBieSheet</returns>
        public override COBieSheet <COBieResourceRow> Fill()
        {
            ProgressIndicator.ReportMessage("Starting Resources...");

            //create new sheet
            COBieSheet <COBieResourceRow> resources = new COBieSheet <COBieResourceRow>(Constants.WORKSHEET_RESOURCE);

            // get all IfcConstructionEquipmentResource objects from IFC file
            IEnumerable <IfcConstructionEquipmentResource> ifcCer = Model.FederatedInstances.OfType <IfcConstructionEquipmentResource>();

            ProgressIndicator.Initialise("Creating Resources", ifcCer.Count());

            foreach (IfcConstructionEquipmentResource ifcConstructionEquipmentResource in ifcCer)
            {
                ProgressIndicator.IncrementAndUpdate();
                //if (ifcConstructionEquipmentResource == null) continue;

                COBieResourceRow resource = new COBieResourceRow(resources);

                resource.Name          = (string.IsNullOrEmpty(ifcConstructionEquipmentResource.Name.ToString())) ? DEFAULT_STRING : ifcConstructionEquipmentResource.Name.ToString();
                resource.CreatedBy     = GetTelecomEmailAddress(ifcConstructionEquipmentResource.OwnerHistory);
                resource.CreatedOn     = GetCreatedOnDateAsFmtString(ifcConstructionEquipmentResource.OwnerHistory);
                resource.Category      = (string.IsNullOrEmpty(ifcConstructionEquipmentResource.ObjectType.ToString())) ? DEFAULT_STRING : ifcConstructionEquipmentResource.ObjectType.ToString();
                resource.ExtSystem     = GetExternalSystem(ifcConstructionEquipmentResource);
                resource.ExtObject     = (ifcConstructionEquipmentResource == null) ? DEFAULT_STRING : ifcConstructionEquipmentResource.GetType().Name;
                resource.ExtIdentifier = ifcConstructionEquipmentResource.GlobalId;
                resource.Description   = (string.IsNullOrEmpty(ifcConstructionEquipmentResource.Description)) ? DEFAULT_STRING : ifcConstructionEquipmentResource.Description.ToString();

                resources.AddRow(resource);
            }

            resources.OrderBy(s => s.Name);

            ProgressIndicator.Finalise();
            return(resources);
        }
Пример #26
0
        /// <summary>
        /// Fill sheet rows for Component sheet
        /// </summary>
        /// <returns>COBieSheet</returns>
        public override COBieSheet <COBieComponentRow> Fill()
        {
#if DEBUG
            Stopwatch timer = new Stopwatch();
            timer.Start();
#endif
            ProgressIndicator.ReportMessage("Starting Components...");
            //Create new sheet
            COBieSheet <COBieComponentRow> components = new COBieSheet <COBieComponentRow>(Constants.WORKSHEET_COMPONENT);



            IEnumerable <IfcRelAggregates> relAggregates = Model.FederatedInstances.OfType <IfcRelAggregates>();
            IEnumerable <IfcRelContainedInSpatialStructure> relSpatial = Model.FederatedInstances.OfType <IfcRelContainedInSpatialStructure>();

            IEnumerable <IfcObject> ifcElements = ((from x in relAggregates
                                                    from y in x.RelatedObjects
                                                    where !Context.Exclude.ObjectType.Component.Contains(y.GetType())
                                                    select y).Union(from x in relSpatial
                                                                    from y in x.RelatedElements
                                                                    where !Context.Exclude.ObjectType.Component.Contains(y.GetType())
                                                                    select y)).OfType <IfcObject>(); //.GroupBy(el => el.Name).Select(g => g.First())//.Distinct().ToList();

            COBieDataPropertySetValues allPropertyValues = new COBieDataPropertySetValues();         //properties helper class
            COBieDataAttributeBuilder  attributeBuilder  = new COBieDataAttributeBuilder(Context, allPropertyValues);
            attributeBuilder.InitialiseAttributes(ref _attributes);
            //set up filters on COBieDataPropertySetValues for the SetAttributes only
            attributeBuilder.ExcludeAttributePropertyNames.AddRange(Context.Exclude.Component.AttributesEqualTo);         //we do not want listed properties for the attribute sheet so filter them out
            attributeBuilder.ExcludeAttributePropertyNamesWildcard.AddRange(Context.Exclude.Component.AttributesContain); //we do not want listed properties for the attribute sheet so filter them out
            attributeBuilder.RowParameters["Sheet"] = "Component";


            ProgressIndicator.Initialise("Creating Components", ifcElements.Count());

            foreach (var obj in ifcElements)
            {
                ProgressIndicator.IncrementAndUpdate();

                COBieComponentRow component = new COBieComponentRow(components);

                IfcElement el = obj as IfcElement;
                if (el == null)
                {
                    continue;
                }
                string name = el.Name.ToString();
                if (string.IsNullOrEmpty(name))
                {
                    name = "Name Unknown " + UnknownCount.ToString();
                    UnknownCount++;
                }
                //set allPropertyValues to this element
                allPropertyValues.SetAllPropertyValues(el); //set the internal filtered IfcPropertySingleValues List in allPropertyValues
                component.Name = name;

                string createBy = allPropertyValues.GetPropertySingleValueValue("COBieCreatedBy", false);  //support for COBie Toolkit for Autodesk Revit
                component.CreatedBy = ValidateString(createBy) ? createBy : GetTelecomEmailAddress(el.OwnerHistory);
                string createdOn = allPropertyValues.GetPropertySingleValueValue("COBieCreatedOn", false); //support for COBie Toolkit for Autodesk Revit
                component.CreatedOn = ValidateString(createdOn) ?  createdOn : GetCreatedOnDateAsFmtString(el.OwnerHistory);

                component.TypeName = GetTypeName(el);
                component.Space    = COBieHelpers.GetComponentRelatedSpace(el, Model, SpaceBoundingBoxInfo, Context);
                string description = allPropertyValues.GetPropertySingleValueValue("COBieDescription", false); //support for COBie Toolkit for Autodesk Revit
                component.Description = ValidateString(description) ? description : GetComponentDescription(el);
                string extSystem = allPropertyValues.GetPropertySingleValueValue("COBieExtSystem", false);     //support for COBie Toolkit for Autodesk Revit
                component.ExtSystem     = ValidateString(extSystem) ? extSystem : GetExternalSystem(el);
                component.ExtObject     = el.GetType().Name;
                component.ExtIdentifier = el.GlobalId;

                //set from PropertySingleValues filtered via candidateProperties
                //set the internal filtered IfcPropertySingleValues List in allPropertyValues to this element set above
                component.SerialNumber      = allPropertyValues.GetPropertySingleValueValue("SerialNumber", false);
                component.InstallationDate  = GetDateFromProperty(allPropertyValues, "InstallationDate");
                component.WarrantyStartDate = GetDateFromProperty(allPropertyValues, "WarrantyStartDate");
                component.TagNumber         = allPropertyValues.GetPropertySingleValueValue("TagNumber", false);
                component.BarCode           = allPropertyValues.GetPropertySingleValueValue("BarCode", false);
                component.AssetIdentifier   = allPropertyValues.GetPropertySingleValueValue("AssetIdentifier", false);

                components.AddRow(component);

                //fill in the attribute information
                attributeBuilder.RowParameters["Name"]      = component.Name;
                attributeBuilder.RowParameters["CreatedBy"] = component.CreatedBy;
                attributeBuilder.RowParameters["CreatedOn"] = component.CreatedOn;
                attributeBuilder.RowParameters["ExtSystem"] = component.ExtSystem;
                attributeBuilder.PopulateAttributesRows(el); //fill attribute sheet rows
            }

            components.OrderBy(s => s.Name);

            ProgressIndicator.Finalise();
#if DEBUG
            timer.Stop();
            Console.WriteLine("Time to generate Component data = {0} seconds", timer.Elapsed.TotalSeconds.ToString("F3"));
#endif


            return(components);
        }
Пример #27
0
        /// <summary>
        /// Fill sheet rows for Assembly sheet
        /// </summary>
        /// <returns>COBieSheet</returns>
        public override COBieSheet <COBieAssemblyRow> Fill()
        {
            ProgressIndicator.ReportMessage("Starting Assemblies...");
            //Create new sheet

            var ifcProject = Model.Instances.FirstOrDefault <IIfcProject>();

            Debug.Assert(ifcProject != null);

            COBieSheet <COBieAssemblyRow> assemblies = new COBieSheet <COBieAssemblyRow>(Constants.WORKSHEET_ASSEMBLY);

            // get ifcRelAggregates objects from IFC file what are not in the excludedTypes type list
            IEnumerable <IfcRelAggregates> ifcRelAggregates = Model.FederatedInstances.OfType <IfcRelAggregates>();
            IEnumerable <IfcRelNests>      ifcRelNests      = Model.FederatedInstances.OfType <IfcRelNests>();


            IEnumerable <IfcRelDecomposes> relAll = (from ra in ifcRelAggregates
                                                     where ((ra.RelatingObject is IfcProduct) || (ra.RelatingObject is IfcTypeObject)) && !Context.Exclude.ObjectType.Assembly.Contains(ra.RelatingObject.GetType())
                                                     select ra as IfcRelDecomposes).Union
                                                        (from rn in ifcRelNests
                                                        where ((rn.RelatingObject is IfcProduct) || (rn.RelatingObject is IfcTypeObject)) && !Context.Exclude.ObjectType.Assembly.Contains(rn.RelatingObject.GetType())
                                                        select rn as IfcRelDecomposes);

            ProgressIndicator.Initialise("Creating Assemblies", relAll.Count());

            int childColumnLength = 255; //default vale, reassigned below

            foreach (IfcRelDecomposes ra in relAll)
            {
                ProgressIndicator.IncrementAndUpdate();
                COBieAssemblyRow assembly = new COBieAssemblyRow(assemblies);
                if (string.IsNullOrEmpty(ra.Name))
                {
                    if (!string.IsNullOrEmpty(ra.RelatingObject.Name))
                    {
                        assembly.Name = (string.IsNullOrEmpty(ra.RelatingObject.Name)) ? DEFAULT_STRING : ra.RelatingObject.Name.ToString();
                    }
                    else
                    {
                        assembly.Name = DEFAULT_STRING;
                    }
                }
                else
                {
                    assembly.Name = ra.Name.ToString();
                }

                assembly.CreatedBy  = GetTelecomEmailAddress(ra.OwnerHistory);
                assembly.CreatedOn  = GetCreatedOnDateAsFmtString(ra.OwnerHistory);
                assembly.SheetName  = GetSheetByObjectType(ra.RelatingObject.GetType());
                assembly.ParentName = ra.RelatingObject.Name;

                assembly.AssemblyType = "Fixed"; //as Responsibility matrix instruction
                assembly.ExtSystem    = GetExternalSystem(ra);
                assembly.ExtObject    = ra.GetType().Name;
                if (!string.IsNullOrEmpty(ra.GlobalId))
                {
                    assembly.ExtIdentifier = ra.GlobalId.ToString();
                }

                assembly.Description = GetAssemblyDescription(ra);

                //get the assembly child names of objects that make up assembly
                ChildNamesList childNamesUnique = ExtractChildNames(ra);
                if (childColumnLength == 0)
                {
                    childColumnLength = assembly["ChildNames"].COBieColumn.ColumnLength;
                }
                ChildNamesList childNames = ConCatChildNamesList(childNamesUnique, childColumnLength);
                if (childNames.Count > 0)
                {
                    AddChildRows(assemblies, assembly, childNames);
                }
            }

            //--------------Loop all IfcMaterialLayerSet-----------------------------
            IEnumerable <IfcMaterialLayerSet> ifcMaterialLayerSets = Model.FederatedInstances.OfType <IfcMaterialLayerSet>();
            char setNamePostFix = 'A';

            foreach (IfcMaterialLayerSet ifcMaterialLayerSet in ifcMaterialLayerSets)
            {
                COBieAssemblyRow assembly = new COBieAssemblyRow(assemblies);
                if (string.IsNullOrEmpty(ifcMaterialLayerSet.LayerSetName))
                {
                    assembly.Name = "Material Layer Set " + setNamePostFix;
                    setNamePostFix++;
                }
                else
                {
                    assembly.Name = ifcMaterialLayerSet.LayerSetName.ToString();
                }

                //Material layer has no owner history, so lets take the owner history from IfcRelAssociatesMaterial.RelatingMaterial -> (IfcMaterialLayerSetUsage.ForLayerSet -> IfcMaterialLayerSet) || IfcMaterialLayerSet || IfcMaterialLayer as it is a IfcMaterialSelect
                IfcOwnerHistory ifcOwnerHistory = GetMaterialOwnerHistory(ifcMaterialLayerSet);

                if (ifcOwnerHistory != null)
                {
                    assembly.CreatedBy = GetTelecomEmailAddress(ifcOwnerHistory);
                    assembly.CreatedOn = GetCreatedOnDateAsFmtString(ifcOwnerHistory);
                    assembly.ExtSystem = GetExternalSystem(ifcOwnerHistory);
                }
                else //default to the project as we failed to find a IfcRoot object to extract it from
                {
                    assembly.CreatedBy = GetTelecomEmailAddress(ifcProject.OwnerHistory);
                    assembly.CreatedOn = GetCreatedOnDateAsFmtString(ifcProject.OwnerHistory);
                    assembly.ExtSystem = GetExternalSystem(ifcProject.OwnerHistory);
                }

                assembly.SheetName    = Constants.WORKSHEET_TYPE; //any material objects should be in the TYPE sheet
                assembly.Description  = GetMaterialSetDescription(ifcMaterialLayerSet.MaterialLayers.ToList());
                assembly.ParentName   = (!string.IsNullOrEmpty(ifcMaterialLayerSet.LayerSetName)) ? ifcMaterialLayerSet.LayerSetName : new IfcLabel(DEFAULT_STRING);
                assembly.AssemblyType = "Layer";
                assembly.ExtObject    = ifcMaterialLayerSet.GetType().Name;

                //Loop Material names
                ChildNamesList childNamesUnique = ExtractChildNames(ifcMaterialLayerSet.MaterialLayers.ToList());
                ChildNamesList childNames       = ConCatChildNamesList(childNamesUnique, childColumnLength); //childColumnLength is max number of chars for the ChildNames cell
                if (childNames.Count > 0)
                {
                    AddChildRows(assemblies, assembly, childNames);
                }
            }

            assemblies.OrderBy(s => s.Name);

            ProgressIndicator.Finalise();

            return(assemblies);
        }
Пример #28
0
        /// <summary>
        /// Fill sheet rows for Zone sheet
        /// </summary>
        /// <returns>COBieSheet</returns>
        public override COBieSheet <COBieZoneRow> Fill()
        {
            ProgressIndicator.ReportMessage("Starting Zones...");

            //Create new sheet
            COBieSheet <COBieZoneRow> zones = new COBieSheet <COBieZoneRow>(Constants.WORKSHEET_ZONE);


            // get all IfcBuildingStory objects from IFC file
            IEnumerable <IfcZone> ifcZones = Model.FederatedInstances.OfType <IfcZone>();

            COBieDataPropertySetValues allPropertyValues = new COBieDataPropertySetValues(); //properties helper class
            COBieDataAttributeBuilder  attributeBuilder  = new COBieDataAttributeBuilder(Context, allPropertyValues);

            attributeBuilder.InitialiseAttributes(ref _attributes);

            //list of attributes to exclude form attribute sheet
            attributeBuilder.ExcludeAttributePropertyNamesWildcard.AddRange(Context.Exclude.Zone.AttributesContain);
            attributeBuilder.RowParameters["Sheet"] = "Zone";

            //Also check to see if we have any zones within the spaces
            IEnumerable <IfcSpace> ifcSpaces = Model.FederatedInstances.OfType <IfcSpace>();//.OrderBy(ifcSpace => ifcSpace.Name, new CompareIfcLabel());

            ProgressIndicator.Initialise("Creating Zones", ifcZones.Count() + ifcSpaces.Count());

            foreach (IfcZone zn in ifcZones)
            {
                ProgressIndicator.IncrementAndUpdate();
                // create zone for each space found
                Dictionary <String, COBieZoneRow> ExistingZones = new Dictionary <string, COBieZoneRow>();
                IEnumerable <IfcSpace>            spaces        = (zn.IsGroupedBy == null) ? Enumerable.Empty <IfcSpace>() : zn.IsGroupedBy.RelatedObjects.OfType <IfcSpace>();
                foreach (IfcSpace sp in spaces)
                {
                    COBieZoneRow zone;
                    if (ExistingZones.ContainsKey(zn.Name.ToString()))
                    {
                        zone             = ExistingZones[zn.Name.ToString()];
                        zone.SpaceNames += "," + sp.Name.ToString();
                    }
                    else
                    {
                        zone = new COBieZoneRow(zones);
                        ExistingZones[zn.Name.ToString()] = zone;

                        //set allPropertyValues to this element
                        allPropertyValues.SetAllPropertyValues(zn); //set the internal filtered IfcPropertySingleValues List in allPropertyValues

                        zone.Name = zn.Name.ToString();

                        string createBy = allPropertyValues.GetPropertySingleValueValue("COBieCreatedBy", false);  //support for COBie Toolkit for Autodesk Revit
                        zone.CreatedBy = ValidateString(createBy) ? createBy : GetTelecomEmailAddress(zn.OwnerHistory);
                        string createdOn = allPropertyValues.GetPropertySingleValueValue("COBieCreatedOn", false); //support for COBie Toolkit for Autodesk Revit
                        zone.CreatedOn = ValidateString(createdOn) ? createdOn : GetCreatedOnDateAsFmtString(zn.OwnerHistory);

                        zone.Category = GetCategory(zn);

                        zone.SpaceNames = sp.Name;

                        string extSystem = allPropertyValues.GetPropertySingleValueValue("COBieExtSystem", false);//support for COBie Toolkit for Autodesk Revit
                        zone.ExtSystem     = ValidateString(extSystem) ? extSystem : GetExternalSystem(zn);
                        zone.ExtObject     = zn.GetType().Name;
                        zone.ExtIdentifier = zn.GlobalId;
                        string description = allPropertyValues.GetPropertySingleValueValue("COBieDescription", false);//support for COBie Toolkit for Autodesk Revit
                        if (ValidateString(extSystem))
                        {
                            zone.Description = extSystem;
                        }
                        else
                        {
                            zone.Description = (string.IsNullOrEmpty(zn.Description)) ? zn.Name.ToString() : zn.Description.ToString(); //if IsNullOrEmpty on Description then output Name
                        }
                        zones.AddRow(zone);

                        //fill in the attribute information
                        attributeBuilder.RowParameters["Name"]      = zone.Name;
                        attributeBuilder.RowParameters["CreatedBy"] = zone.CreatedBy;
                        attributeBuilder.RowParameters["CreatedOn"] = zone.CreatedOn;
                        attributeBuilder.RowParameters["ExtSystem"] = zone.ExtSystem;
                        attributeBuilder.PopulateAttributesRows(zn); //fill attribute sheet rows//pass data from this sheet info as Dictionary
                    }
                }
            }

            COBieDataPropertySetValues allSpacePropertyValues = new COBieDataPropertySetValues(); //get all property sets and associated properties in one go

            Dictionary <String, COBieZoneRow> myExistingZones = new Dictionary <string, COBieZoneRow>();

            foreach (IfcSpace sp in ifcSpaces)
            {
                ProgressIndicator.IncrementAndUpdate();
                allSpacePropertyValues.SetAllPropertyValues(sp); //set the space as the current object for the properties get glass

                IEnumerable <IfcPropertySingleValue> spProperties = Enumerable.Empty <IfcPropertySingleValue>();
                foreach (KeyValuePair <IfcPropertySet, IEnumerable <IfcSimpleProperty> > item in allSpacePropertyValues.MapPsetToProps)
                {
                    IfcPropertySet pset = item.Key;
                    spProperties = item.Value.Where(p => p.Name.ToString().Contains("ZoneName")).OfType <IfcPropertySingleValue>();


                    //if we have no ifcZones or "ZoneName" properties, and the DepartmentsUsedAsZones flag is true then list departments as zones
                    if ((!spProperties.Any()) && (!ifcZones.Any()) && (Context.DepartmentsUsedAsZones == true))
                    {
                        spProperties = item.Value.Where(p => p.Name == "Department").OfType <IfcPropertySingleValue>();
                    }

                    foreach (IfcPropertySingleValue spProp in spProperties)
                    {
                        COBieZoneRow zone;
                        if (myExistingZones.ContainsKey(spProp.NominalValue.ToString()))
                        {
                            zone             = myExistingZones[spProp.NominalValue.ToString()];
                            zone.SpaceNames += "," + sp.Name;
                        }
                        else
                        {
                            zone      = new COBieZoneRow(zones);
                            zone.Name = spProp.NominalValue.ToString();
                            myExistingZones[spProp.NominalValue.ToString()] = zone;

                            zone.CreatedBy = GetTelecomEmailAddress(sp.OwnerHistory);
                            zone.CreatedOn = GetCreatedOnDateAsFmtString(sp.OwnerHistory);

                            zone.Category   = spProp.Name;
                            zone.SpaceNames = sp.Name;

                            zone.ExtSystem     = GetExternalSystem(pset);
                            zone.ExtObject     = spProp.GetType().Name;
                            zone.ExtIdentifier = pset.GlobalId.ToString(); //IfcPropertySingleValue has no GlobalId so set to the holding IfcPropertySet

                            zone.Description = (string.IsNullOrEmpty(spProp.NominalValue.ToString())) ? DEFAULT_STRING : spProp.NominalValue.ToString();;

                            zones.AddRow(zone);
                        }
                    }
                }
                //spProperties = spProperties.OrderBy(p => p.Name.ToString(), new CompareString()); //consolidate test, Concat as looping spaces then sort then dump to COBieZoneRow foreach
            }

            zones.OrderBy(s => s.Name);

            ProgressIndicator.Finalise();

            return(zones);
        }
        /// <summary>
        /// Create and setup Bounding Box's
        /// </summary>
        /// <param name="cOBieSheet">COBieSheet of COBieCoordinateRow to read data from</param>
        public void SerialiseCoordinate(COBieSheet <COBieCoordinateRow> cOBieSheet)
        {
            using (XbimReadWriteTransaction trans = Model.BeginTransaction("Add Coordinate"))
            {
                try
                {
                    int count = 1;
                    ProgressIndicator.ReportMessage("Starting Coordinates...");
                    ProgressIndicator.Initialise("Creating Coordinates", cOBieSheet.RowCount);
                    var rows = cOBieSheet.Rows.OrderBy(a => a.SheetName == "Component").ThenBy(a => a.SheetName == "Space").ThenBy(a => a.SheetName == "Floor"); //order into Floor,Space,Component, needed to build object placements

                    for (int i = 0; i < cOBieSheet.RowCount; i++)
                    {
                        COBieCoordinateRow row     = rows.ElementAt(i);// cOBieSheet[i];
                        COBieCoordinateRow rowNext = null;
                        BumpTransaction(trans, count);
                        count++;

                        //do floor placement point
                        if ((ValidateString(row.Category)) &&
                            (row.Category.ToLower() == "point")
                            )
                        {
                            ProgressIndicator.IncrementAndUpdate();

                            AddFloorPlacement(row);
                            continue; //work done, next loop please
                        }
                        //do bounding box items
                        if ((ValidateString(row.Category)) &&
                            (row.Category.Contains("box-"))
                            )
                        {
                            i++;                             //set to get next row

                            if (i < cOBieSheet.RowCount)     //get next row if still in range
                            {
                                rowNext = rows.ElementAt(i); //cOBieSheet[i];
                            }
                            if ((rowNext != null) &&
                                (ValidateString(rowNext.Category)) &&
                                (rowNext.Category.Contains("box-")) &&
                                (ValidateString(row.SheetName)) &&
                                //(ValidateString(row.RowName)) &&
                                (ValidateString(rowNext.SheetName)) &&
                                //(ValidateString(rowNext.RowName)) &&
                                (row.SheetName == rowNext.SheetName) &&
                                (row.RowName == rowNext.RowName)
                                )
                            {
                                ProgressIndicator.IncrementAndUpdate();

                                AddBoundingBoxAsExtrudedAreaSolid(row, rowNext);

                                ProgressIndicator.IncrementAndUpdate(); //two row processed here

//#if DEBUG
//                                Console.WriteLine("{0} : {1} == {2} : {3} ", row.SheetName, row.RowName, rowNext.SheetName, rowNext.RowName);
//#endif
                            }
                            else
                            {
#if DEBUG
                                if (rowNext == null)
                                {
                                    Console.WriteLine("Failed to find pair {0} : {1} != {2} : {3} ", row.SheetName, row.RowName, "Null", "Null");
                                }
                                else
                                {
                                    Console.WriteLine("Failed to find pair {0} : {1} != {2} : {3} ", row.SheetName, row.RowName, rowNext.SheetName, rowNext.RowName);
                                }
#endif
                                i--; //set back in case next is point, as two box points failed
                            }
                        }
                    }
                    ProgressIndicator.Finalise();

                    trans.Commit();
                }
                catch (Exception)
                {
                    //TODO: Catch with logger?
                    throw;
                }
            }
        }
Пример #30
0
        /// <summary>
        /// Create and setup Bounding Box's
        /// </summary>
        /// <param name="cOBieSheet">COBieSheet of COBieCoordinateRow to read data from</param>
        public void SerialiseCoordinate(COBieSheet<COBieCoordinateRow> cOBieSheet)
        {
            using (XbimReadWriteTransaction trans = Model.BeginTransaction("Add Coordinate"))
            {

                try
                {
                    int count = 1;
                    ProgressIndicator.ReportMessage("Starting Coordinates...");
                    ProgressIndicator.Initialise("Creating Coordinates", cOBieSheet.RowCount);
                    var rows = cOBieSheet.Rows.OrderBy(a => a.SheetName == "Component").ThenBy(a => a.SheetName == "Space").ThenBy(a => a.SheetName == "Floor"); //order into Floor,Space,Component, needed to build object placements

                    for (int i = 0; i < cOBieSheet.RowCount; i++)
                    {
                        COBieCoordinateRow row = rows.ElementAt(i);// cOBieSheet[i];
                        COBieCoordinateRow rowNext = null;
                        BumpTransaction(trans, count);
                        count++;
                        
                        //do floor placement point
                        if ((ValidateString(row.Category)) &&  
                            (row.Category.ToLower() == "point")
                            )
                        {
                            ProgressIndicator.IncrementAndUpdate();
                        
                            AddFloorPlacement(row);
                            continue; //work done, next loop please
                        }
                        //do bounding box items
                        if ((ValidateString(row.Category)) && 
                            (row.Category.Contains("box-"))
                            )
                        {    
                            i++; //set to get next row

                            if (i < cOBieSheet.RowCount) //get next row if still in range
                                rowNext = rows.ElementAt(i);//cOBieSheet[i];

                            if ((rowNext != null) &&
                                (ValidateString(rowNext.Category)) && 
                                (rowNext.Category.Contains("box-")) &&
                                (ValidateString(row.SheetName)) && 
                                //(ValidateString(row.RowName)) &&
                                (ValidateString(rowNext.SheetName)) &&
                                //(ValidateString(rowNext.RowName)) &&
                                (row.SheetName == rowNext.SheetName) &&
                                (row.RowName == rowNext.RowName)
                                )
                            {
                                ProgressIndicator.IncrementAndUpdate();
                                
                                AddBoundingBoxAsExtrudedAreaSolid(row, rowNext);
                                
                                ProgressIndicator.IncrementAndUpdate(); //two row processed here
                        
//#if DEBUG
//                                Console.WriteLine("{0} : {1} == {2} : {3} ", row.SheetName, row.RowName, rowNext.SheetName, rowNext.RowName);
//#endif                           
                                continue;
                            }
                            else
                            {
#if DEBUG
                                if (rowNext == null)
                                    Console.WriteLine("Failed to find pair {0} : {1} != {2} : {3} ", row.SheetName, row.RowName, "Null", "Null");
                                else
                                    Console.WriteLine("Failed to find pair {0} : {1} != {2} : {3} ", row.SheetName, row.RowName, rowNext.SheetName, rowNext.RowName);
#endif
                                i--; //set back in case next is point, as two box points failed
                            }
                        }
                       
                    }
                    ProgressIndicator.Finalise();
                    
                    trans.Commit();

                }
                catch (Exception)
                {
                    //TODO: Catch with logger?
                    throw;
                }

            }
        }
Пример #31
0
        /// <summary>
        /// Fill sheet rows for Type sheet
        /// </summary>
        /// <returns>COBieSheet</returns>
        public override COBieSheet <COBieTypeRow> Fill()
        {
#if DEBUG
            Stopwatch timer = new Stopwatch();
            timer.Start();
#endif
            ProgressIndicator.ReportMessage("Starting Types...");

            var ifcProject = Model.Instances.FirstOrDefault <IIfcProject>();
            Debug.Assert(ifcProject != null);

            // Create new Sheet
            COBieSheet <COBieTypeRow> types = new COBieSheet <COBieTypeRow>(Constants.WORKSHEET_TYPE);

            //group the types by name as we need to filter duplicate items in for each loop
            IEnumerable <IfcTypeObject> ifcTypeObjects = Model.FederatedInstances.OfType <IfcTypeObject>()
                                                         .Select(type => type)
                                                         .Where(type => !Context.Exclude.ObjectType.Types.Contains(type.GetType()))
                                                         .GroupBy(type => type.Name).SelectMany(g => g);//.Distinct()



            //set up property set helper class
            COBieDataPropertySetValues allPropertyValues = new COBieDataPropertySetValues(); //properties helper class
            COBieDataAttributeBuilder  attributeBuilder  = new COBieDataAttributeBuilder(Context, allPropertyValues);
            attributeBuilder.InitialiseAttributes(ref _attributes);
            attributeBuilder.ExcludeAttributePropertyNames.AddRange(Context.Exclude.Types.AttributesEqualTo);         //we do not want for the attribute sheet so filter them out
            attributeBuilder.ExcludeAttributePropertyNamesWildcard.AddRange(Context.Exclude.Types.AttributesContain); //we do not want for the attribute sheet so filter them out
            attributeBuilder.ExcludeAttributePropertySetNames.AddRange(Context.Exclude.Types.PropertySetsEqualTo);    //exclude the property set from selection of values
            attributeBuilder.RowParameters["Sheet"] = "Type";

            ProgressIndicator.Initialise("Creating Types", ifcTypeObjects.Count());
            //COBieTypeRow lastRow = null;
            foreach (IfcTypeObject type in ifcTypeObjects)
            {
                ProgressIndicator.IncrementAndUpdate();


                COBieTypeRow typeRow = new COBieTypeRow(types);

                // TODO: Investigate centralising this common code.
                string name = type.Name;
                if (string.IsNullOrEmpty(type.Name))
                {
                    name = "Name Unknown " + UnknownCount.ToString();
                    UnknownCount++;
                }

                //set allPropertyValues to this element
                allPropertyValues.SetAllPropertyValues(type); //set the internal filtered IfcPropertySingleValues List in allPropertyValues

                typeRow.Name = name;
                string create_By = allPropertyValues.GetPropertySingleValueValue("COBieTypeCreatedBy", false);  //support for COBie Toolkit for Autodesk Revit
                typeRow.CreatedBy = ValidateString(create_By) ? create_By : GetTelecomEmailAddress(type.OwnerHistory);
                string created_On = allPropertyValues.GetPropertySingleValueValue("COBieTypeCreatedOn", false); //support for COBie Toolkit for Autodesk Revit
                typeRow.CreatedOn = ValidateString(created_On) ? created_On : GetCreatedOnDateAsFmtString(type.OwnerHistory);
                typeRow.Category  = GetCategory(allPropertyValues);
                string description = allPropertyValues.GetPropertySingleValueValue("COBieDescription", false);//support for COBie Toolkit for Autodesk Revit
                typeRow.Description = ValidateString(description) ? description : GetTypeObjDescription(type);

                string ext_System = allPropertyValues.GetPropertySingleValueValue("COBieTypeExtSystem", false);//support for COBie Toolkit for Autodesk Revit
                typeRow.ExtSystem     = ValidateString(ext_System) ? ext_System : GetExternalSystem(type);
                typeRow.ExtObject     = type.GetType().Name;
                typeRow.ExtIdentifier = type.GlobalId;



                FillPropertySetsValues(allPropertyValues, type, typeRow);
                //not duplicate so add to sheet
                //if (CheckForDuplicateRow(lastRow, typeRow))
                //{
                string rowhash = typeRow.RowHashValue;
                if (RowHashs.ContainsKey(rowhash))
                {
                    continue;
                }
                else
                {
                    types.AddRow(typeRow);
                    RowHashs.Add(rowhash, true);
                }

                //lastRow = typeRow; //save this row to test on next loop
                //}
                // Provide Attribute sheet with our context
                //fill in the attribute information
                attributeBuilder.RowParameters["Name"]      = typeRow.Name;
                attributeBuilder.RowParameters["CreatedBy"] = typeRow.CreatedBy;
                attributeBuilder.RowParameters["CreatedOn"] = typeRow.CreatedOn;
                attributeBuilder.RowParameters["ExtSystem"] = typeRow.ExtSystem;
                attributeBuilder.PopulateAttributesRows(type); //fill attribute sheet rows
            }
            ProgressIndicator.Finalise();
            //--------------Loop all IfcMaterialLayerSet-----------------------------
            ProgressIndicator.ReportMessage("Starting MaterialLayerSets...");
            IEnumerable <IfcMaterialLayerSet> ifcMaterialLayerSets = Model.FederatedInstances.OfType <IfcMaterialLayerSet>();
            ChildNamesList rowHolderChildNames      = new ChildNamesList();
            ChildNamesList rowHolderLayerChildNames = new ChildNamesList();

            string createdBy = DEFAULT_STRING, createdOn = DEFAULT_STRING, extSystem = DEFAULT_STRING;
            ProgressIndicator.Initialise("Creating MaterialLayerSets", ifcMaterialLayerSets.Count());

            foreach (IfcMaterialLayerSet ifcMaterialLayerSet in ifcMaterialLayerSets)
            {
                ProgressIndicator.IncrementAndUpdate();
                //Material layer has no owner history, so lets take the owner history from IfcRelAssociatesMaterial.RelatingMaterial -> (IfcMaterialLayerSetUsage.ForLayerSet -> IfcMaterialLayerSet) || IfcMaterialLayerSet || IfcMaterialLayer as it is a IfcMaterialSelect
                IfcOwnerHistory ifcOwnerHistory = GetMaterialOwnerHistory(ifcMaterialLayerSet);
                if (ifcOwnerHistory != null)
                {
                    createdBy = GetTelecomEmailAddress(ifcOwnerHistory);
                    createdOn = GetCreatedOnDateAsFmtString(ifcOwnerHistory);
                    extSystem = GetExternalSystem(ifcOwnerHistory);
                }
                else //default to the project as we failed to find a IfcRoot object to extract it from
                {
                    createdBy = GetTelecomEmailAddress(ifcProject.OwnerHistory);
                    createdOn = GetCreatedOnDateAsFmtString(ifcProject.OwnerHistory);
                    extSystem = GetExternalSystem(ifcProject.OwnerHistory);
                }
                //add materialLayerSet name to rows
                COBieTypeRow matSetRow = new COBieTypeRow(types);
                matSetRow.Name      = (string.IsNullOrEmpty(ifcMaterialLayerSet.LayerSetName)) ? DEFAULT_STRING : ifcMaterialLayerSet.LayerSetName.ToString();
                matSetRow.CreatedBy = createdBy;
                matSetRow.CreatedOn = createdOn;
                matSetRow.ExtSystem = extSystem;
                matSetRow.ExtObject = ifcMaterialLayerSet.GetType().Name;
                matSetRow.AssetType = "Fixed";
                types.AddRow(matSetRow);

                //loop the materials within the material layer set
                foreach (IfcMaterialLayer ifcMaterialLayer in ifcMaterialLayerSet.MaterialLayers)
                {
                    if ((ifcMaterialLayer.Material != null) &&
                        (!string.IsNullOrEmpty(ifcMaterialLayer.Material.Name))
                        )
                    {
                        string name      = ifcMaterialLayer.Material.Name.ToString().Trim();
                        double thickness = ifcMaterialLayer.LayerThickness;
                        string keyName   = name + " (" + thickness.ToString(CultureInfo.InvariantCulture) + ")";
                        if (!rowHolderLayerChildNames.Contains(keyName.ToLower())) //check we do not already have it
                        {
                            COBieTypeRow matRow = new COBieTypeRow(types);

                            matRow.Name         = keyName;
                            matRow.CreatedBy    = createdBy;
                            matRow.CreatedOn    = createdOn;
                            matRow.ExtSystem    = extSystem;
                            matRow.ExtObject    = ifcMaterialLayer.GetType().Name;
                            matRow.AssetType    = "Fixed";
                            matRow.NominalWidth = thickness.ToString();

                            rowHolderLayerChildNames.Add(keyName.ToLower());

                            //we also don't want to repeat on the IfcMaterial loop below
                            if (!rowHolderChildNames.Contains(name.ToLower()))
                            {
                                rowHolderChildNames.Add(name.ToLower());
                            }

                            types.AddRow(matRow);
                        }
                    }
                }
            }
            ProgressIndicator.Finalise();
            //--------Loop Materials in case they are not in a layer Set-----
            ProgressIndicator.ReportMessage("Starting Materials...");

            IEnumerable <IfcMaterial> ifcMaterials = Model.FederatedInstances.OfType <IfcMaterial>();
            ProgressIndicator.Initialise("Creating Materials", ifcMaterials.Count());
            foreach (IfcMaterial ifcMaterial in ifcMaterials)
            {
                ProgressIndicator.IncrementAndUpdate();
                string name = ifcMaterial.Name.ToString().Trim();
                if (!string.IsNullOrEmpty(ifcMaterial.Name))
                {
                    if (!rowHolderChildNames.Contains(name.ToLower())) //check we do not already have it
                    {
                        COBieTypeRow matRow = new COBieTypeRow(types);

                        matRow.Name      = name;
                        matRow.CreatedBy = createdBy; //no way of extraction on material, if no material layer set, so use last found in Layer Set loop
                        matRow.CreatedOn = createdOn; //ditto
                        matRow.ExtSystem = extSystem; //ditto
                        matRow.ExtObject = ifcMaterial.GetType().Name;
                        matRow.AssetType = "Fixed";

                        types.AddRow(matRow);
                    }

                    rowHolderChildNames.Add(name.ToLower());
                }
            }

            types.OrderBy(s => s.Name);

            ProgressIndicator.Finalise();

#if DEBUG
            timer.Stop();
            Console.WriteLine(String.Format("Time to generate Type data = {0} seconds", timer.Elapsed.TotalSeconds.ToString("F3")));
#endif
            return(types);
        }
Пример #32
0
        /// <summary>
        /// Fill sheet rows for Job sheet
        /// </summary>
        /// <returns>COBieSheet</returns>
        public override COBieSheet <COBieJobRow> Fill()
        {
            ProgressIndicator.ReportMessage("Starting Jobs...");

            //create new sheet
            COBieSheet <COBieJobRow> jobs = new COBieSheet <COBieJobRow>(Constants.WORKSHEET_JOB);

            // get all IfcTask objects from IFC file
            IEnumerable <IfcTask> ifcTasks = Model.Instances.OfType <IfcTask>();

            COBieDataPropertySetValues allPropertyValues = new COBieDataPropertySetValues(); //properties helper class

            //IfcTypeObject typObj = Model.Instances.OfType<IfcTypeObject>().FirstOrDefault();
            IfcConstructionEquipmentResource cer = Model.Instances.OfType <IfcConstructionEquipmentResource>().FirstOrDefault();

            ProgressIndicator.Initialise("Creating Jobs", ifcTasks.Count());

            foreach (IfcTask ifcTask in ifcTasks)
            {
                ProgressIndicator.IncrementAndUpdate();

                if (ifcTask == null)
                {
                    continue;
                }

                COBieJobRow job = new COBieJobRow(jobs);

                job.Name      = (string.IsNullOrEmpty(ifcTask.Name.ToString())) ? DEFAULT_STRING : ifcTask.Name.ToString();
                job.CreatedBy = GetTelecomEmailAddress(ifcTask.OwnerHistory);
                job.CreatedOn = GetCreatedOnDateAsFmtString(ifcTask.OwnerHistory);
                job.Category  = ifcTask.ObjectType.ToString();
                job.Status    = (string.IsNullOrEmpty(ifcTask.Status.ToString())) ? DEFAULT_STRING : ifcTask.Status.ToString();

                job.TypeName    = GetObjectType(ifcTask);
                job.Description = (string.IsNullOrEmpty(ifcTask.Description.ToString())) ? DEFAULT_STRING : ifcTask.Description.ToString();

                allPropertyValues.SetAllPropertyValues(ifcTask); //set properties values to this task
                IfcPropertySingleValue ifcPropertySingleValue = allPropertyValues.GetPropertySingleValue("TaskDuration");
                job.Duration = ((ifcPropertySingleValue != null) && (ifcPropertySingleValue.NominalValue != null)) ? ConvertNumberOrDefault(ifcPropertySingleValue.NominalValue.ToString()) : DEFAULT_NUMERIC;
                string unitName = ((ifcPropertySingleValue != null) && (ifcPropertySingleValue.Unit != null)) ? GetUnitName(ifcPropertySingleValue.Unit) : null;
                job.DurationUnit = (string.IsNullOrEmpty(unitName)) ?  DEFAULT_STRING : unitName;

                ifcPropertySingleValue = allPropertyValues.GetPropertySingleValue("TaskStartDate");
                job.Start         = GetStartTime(ifcPropertySingleValue);
                unitName          = ((ifcPropertySingleValue != null) && (ifcPropertySingleValue.Unit != null)) ? GetUnitName(ifcPropertySingleValue.Unit) : null;
                job.TaskStartUnit = (string.IsNullOrEmpty(unitName)) ? DEFAULT_STRING : unitName;

                ifcPropertySingleValue = allPropertyValues.GetPropertySingleValue("TaskInterval");
                job.Frequency          = ((ifcPropertySingleValue != null) && (ifcPropertySingleValue.NominalValue != null)) ? ConvertNumberOrDefault(ifcPropertySingleValue.NominalValue.ToString()) : DEFAULT_NUMERIC;
                unitName          = ((ifcPropertySingleValue != null) && (ifcPropertySingleValue.Unit != null)) ? GetUnitName(ifcPropertySingleValue.Unit) : null;
                job.FrequencyUnit = (string.IsNullOrEmpty(unitName)) ? DEFAULT_STRING : unitName;

                job.ExtSystem     = GetExternalSystem(ifcTask);
                job.ExtObject     = ifcTask.GetType().Name;
                job.ExtIdentifier = ifcTask.GlobalId;

                job.TaskNumber    = (string.IsNullOrEmpty(ifcTask.TaskId.ToString())) ? DEFAULT_STRING : ifcTask.TaskId.ToString();
                job.Priors        = GetPriors(ifcTask);
                job.ResourceNames = GetResources(ifcTask);

                jobs.AddRow(job);
            }

            jobs.OrderBy(s => s.Name);

            ProgressIndicator.Finalise();
            return(jobs);
        }
Пример #33
0
        /// <summary>
        /// Fill sheet rows for Connection sheet
        /// </summary>
        /// <returns>COBieSheet</returns>
        public override COBieSheet <COBieConnectionRow> Fill()
        {
            ProgressIndicator.ReportMessage("Starting Connections...");
            //Create new sheet
            COBieSheet <COBieConnectionRow> connections = new COBieSheet <COBieConnectionRow>(Constants.WORKSHEET_CONNECTION);

            // get all IfcRelConnectsElements objects from IFC file
            IEnumerable <IfcRelConnectsElements> ifcRelConnectsElements = Model.Instances.OfType <IfcRelConnectsElements>()
                                                                          .Where(rce => rce.RelatedElement != null &&
                                                                                 !Context.Exclude.ObjectType.Component.Contains(rce.RelatedElement.GetType()) &&
                                                                                 rce.RelatingElement != null &&
                                                                                 !Context.Exclude.ObjectType.Component.Contains(rce.RelatingElement.GetType())
                                                                                 );
            //get ifcRelConnectsPorts only if we have ifcRelConnectsElements
            IEnumerable <IfcRelConnectsPorts> ifcRelConnectsPorts = Enumerable.Empty <IfcRelConnectsPorts>();

            if (ifcRelConnectsElements.Count() > 0)
            {
                ifcRelConnectsPorts = Model.Instances.OfType <IfcRelConnectsPorts>();
            }

            ProgressIndicator.Initialise("Creating Connections", ifcRelConnectsElements.Count());

            int ids = 0;

            foreach (IfcRelConnectsElements ifcRelConnectsElement in ifcRelConnectsElements)
            {
                ProgressIndicator.IncrementAndUpdate();

                IfcElement relatingElement = ifcRelConnectsElement.RelatingElement;
                IfcElement relatedElement  = ifcRelConnectsElement.RelatedElement;

                COBieConnectionRow conn = new COBieConnectionRow(connections);

                //try and get the IfcRelConnectsPorts first for relatingElement then for relatedElement
                IEnumerable <IfcRelConnectsPorts> ifcRelConnectsPortsElement = ifcRelConnectsPorts.Where(rcp => (rcp.RealizingElement != null) && ((rcp.RealizingElement == relatingElement) || (rcp.RealizingElement == relatedElement)));
                string connectionName = "";
                connectionName = (string.IsNullOrEmpty(ifcRelConnectsElement.Name)) ? "" : ifcRelConnectsElement.Name.ToString();


                conn.CreatedBy      = GetTelecomEmailAddress(ifcRelConnectsElement.OwnerHistory);
                conn.CreatedOn      = GetCreatedOnDateAsFmtString(ifcRelConnectsElement.OwnerHistory);
                conn.ConnectionType = GetComponentDescription(ifcRelConnectsElement);
                conn.SheetName      = GetSheetByObjectType(relatingElement.GetType());

                conn.RowName1 = ((relatingElement != null) && (!string.IsNullOrEmpty(relatingElement.Name.ToString()))) ? relatingElement.Name.ToString() : DEFAULT_STRING;
                conn.RowName2 = ((relatedElement != null) && (!string.IsNullOrEmpty(relatedElement.Name.ToString()))) ? relatedElement.Name.ToString() : DEFAULT_STRING;
                //second attempt to get a name, if no IfcElement name then see if the associated type has a name
                //if (conn.RowName1 == DEFAULT_STRING) conn.RowName1 =  GetTypeName(relatingElement);
                //if (conn.RowName2 == DEFAULT_STRING) conn.RowName2 = GetTypeName(relatedElement);

                //try and get IfcRelConnectsPorts by using relatingElement then relatedElement is the RelizingElement, but this is optional property, but the IfcRelConnectsPorts object document states
                //"Each of the port is being attached to the IfcElement by using the IfcRelConnectsPortToElement relationship" and the IfcRelConnectsPortToElement is a inverse reference to HasPorts
                //on the IfcElement, so if no IfcRelConnectsPorts found for either Element, then check the HasPosts property of each element.
                List <string> realizingElement = new List <string>();
                List <string> relatedPort      = new List <string>();
                List <string> relatingPort     = new List <string>();
                foreach (IfcRelConnectsPorts port  in ifcRelConnectsPortsElement)
                {
                    if ((string.IsNullOrEmpty(connectionName)) && (string.IsNullOrEmpty(port.Name)))
                    {
                        connectionName = port.Name;
                    }

                    if ((port.RealizingElement != null) && (!string.IsNullOrEmpty(port.RealizingElement.ToString())))  //removed to allow export to xbim to keep sequence && (!realizingElement.Contains(port.RealizingElement.ToString()))
                    {
                        realizingElement.Add(port.RealizingElement.ToString());
                    }

                    if ((port.RelatedPort != null) && (!string.IsNullOrEmpty(port.RelatedPort.Name.ToString()))) //removed to allow export to xbim to keep sequence && (!relatedPort.Contains(port.RelatedPort.Name.ToString()))
                    {
                        relatedPort.Add(port.RelatedPort.Name.ToString());
                    }

                    if ((port.RelatingPort != null) && (!string.IsNullOrEmpty(port.RelatingPort.Name.ToString()))) //removed to allow export to xbim to keep sequence && (!relatingPort.Contains(port.RelatingPort.Name.ToString()))
                    {
                        relatingPort.Add(port.RelatingPort.Name.ToString());
                    }
                }

                conn.RealizingElement = (realizingElement.Count > 0) ? COBieXBim.JoinStrings(':', realizingElement) : DEFAULT_STRING;

                //no related port found so lets try and get from IfcElement.HasPorts
                if (relatedPort.Count == 0)
                {
                    IEnumerable <IfcRelConnectsPortToElement> relatedPorts = relatedElement.HasPorts.Where(rcpe => rcpe.RelatingPort != null);
                    foreach (IfcRelConnectsPortToElement port in relatedPorts)
                    {
                        if ((string.IsNullOrEmpty(connectionName)) && (string.IsNullOrEmpty(port.Name)))
                        {
                            connectionName = port.Name;
                        }
                        if ((port.RelatingPort != null) && (!string.IsNullOrEmpty(port.RelatingPort.Name.ToString())) && (!relatedPort.Contains(port.RelatingPort.Name.ToString())))
                        {
                            relatedPort.Add(port.RelatingPort.Name.ToString());
                        }
                    }
                }
                //no relating port found so lets try and get from IfcElement.HasPorts
                if (relatingPort.Count == 0)
                {
                    IEnumerable <IfcRelConnectsPortToElement> relatingPorts = relatingElement.HasPorts.Where(rcpe => rcpe.RelatingPort != null);
                    foreach (IfcRelConnectsPortToElement port in relatingPorts)
                    {
                        if ((string.IsNullOrEmpty(connectionName)) && (string.IsNullOrEmpty(port.Name)))
                        {
                            connectionName = port.Name;
                        }
                        if ((port.RelatingPort != null) && (!string.IsNullOrEmpty(port.RelatingPort.Name.ToString())) && (!relatedPort.Contains(port.RelatingPort.Name.ToString())))
                        {
                            relatingPort.Add(port.RelatingPort.Name.ToString());
                        }
                    }
                }

                conn.PortName1 = (relatingPort.Count > 0) ? COBieXBim.JoinStrings(':', relatingPort) : DEFAULT_STRING;
                conn.PortName2 = (relatedPort.Count > 0) ? COBieXBim.JoinStrings(':', relatedPort) : DEFAULT_STRING;

                conn.ExtSystem     = GetExternalSystem(ifcRelConnectsElement);
                conn.ExtObject     = ifcRelConnectsElement.GetType().Name;
                conn.ExtIdentifier = ifcRelConnectsElement.GlobalId;

                //if no ifcRelConnectsElement Name or Port names then revert to the index number
                conn.Name        = (string.IsNullOrEmpty(connectionName)) ? ids.ToString() : connectionName;
                conn.Description = (string.IsNullOrEmpty(ifcRelConnectsElement.Description)) ? DEFAULT_STRING : ifcRelConnectsElement.Description.ToString();

                connections.AddRow(conn);

                ids++;
            }

            connections.OrderBy(s => s.Name);

            ProgressIndicator.Finalise();

            return(connections);
        }
Пример #34
0
 /// <summary>
 /// Set the exclude list using the pick list sheet as the source of allowed Object Types
 /// </summary>
 /// <param name="CobiePickLists">COBieSheet of COBiePickListsRow</param>
 private void SetExcludeObjTypeTypes(COBieSheet<COBiePickListsRow> CobiePickLists)
 {
     List<Type> objTypes = GetExcludedTypes(CobiePickLists, typeof(IfcTypeObject), 37);
     Context.Exclude.ObjectType.Types.Clear();
     Context.Exclude.ObjectType.Types.AddRange(objTypes);
 }
Пример #35
0
 /// <summary>
 /// Set the exclude list using the pick list sheet as the source of allowed Element types
 /// </summary>
 /// <param name="CobiePickLists">COBieSheet of COBiePickListsRow</param>
 private void SetExcludeComponentTypes(COBieSheet<COBiePickListsRow> CobiePickLists)
 {
     List<Type> eleTypes = GetExcludedTypes(CobiePickLists, typeof(IfcElement), 22);
     Context.Exclude.ObjectType.Component.Clear();
     Context.Exclude.ObjectType.Component.AddRange(eleTypes);
 }
Пример #36
0
        /// <summary>
        /// Validate XLS file for COBie errors, also will swap templates if required
        /// </summary>
        /// <param name="parameters">Params</param>
        /// <returns>Created file name</returns>
        private void ValidateXLSfile(Params parameters, ICOBieValidationTemplate ValidationTemplate = null)
        {
            //read xls file
            LogBackground(String.Format("Reading {0}....", parameters.ModelFile));
            COBieXLSDeserialiser deSerialiser = new COBieXLSDeserialiser(parameters.ModelFile);
            COBieWorkbook        Workbook     = deSerialiser.Deserialise();

            //extract pick list from the template sheet and swap into workbook (US / UK)
            LogBackground("Swapping PickList from template...");
            COBieSheet <COBiePickListsRow> CobiePickLists = null;

            if ((!string.IsNullOrEmpty(parameters.TemplateFile)) &&
                File.Exists(parameters.TemplateFile)
                )
            {
                //extract the pick list sheet from template
                COBieXLSDeserialiser deSerialiserPickList = new COBieXLSDeserialiser(parameters.TemplateFile, Constants.WORKSHEET_PICKLISTS);
                COBieWorkbook        wbookPickList        = deSerialiserPickList.Deserialise();
                if (wbookPickList.Count > 0)
                {
                    CobiePickLists = (COBieSheet <COBiePickListsRow>)wbookPickList.FirstOrDefault();
                }
                //check the workbook last sheet is a pick list
                if (Workbook.LastOrDefault() is COBieSheet <COBiePickListsRow> )
                {
                    //remove original pick list and replace with templates
                    Workbook.RemoveAt(Workbook.Count - 1);
                    Workbook.Add(CobiePickLists);
                }
                else
                {
                    LogBackground("Failed to Swap PickList from template...");
                }
            }

            COBieContext  context  = new COBieContext(_worker.ReportProgress);
            COBieProgress progress = new COBieProgress(context);

            context.Exclude = UserFilters;

            //Validate
            progress.Initialise("Validating Workbooks", Workbook.Count, 0);
            progress.ReportMessage("Building Indices...");
            foreach (ICOBieSheet <COBieRow> item in Workbook)
            {
                item.BuildIndices();
            }
            progress.ReportMessage("Building Indices...Finished");

            // Validate the workbook
            progress.ReportMessage("Starting Validation...");

            Workbook.Validate(ErrorRowIndexBase.RowTwo, null, (lastProcessedSheetIndex) =>
            {
                // When each sheet has been processed, increment the progress bar
                progress.IncrementAndUpdate();
            });
            progress.ReportMessage("Finished Validation");
            progress.Finalise();

            // Export
            LogBackground(String.Format("Formatting as XLS using {0} template...", Path.GetFileName(parameters.TemplateFile)));
            COBieXLSSerialiser serialiser = new COBieXLSSerialiser(parameters.ModelFile, parameters.TemplateFile);

            serialiser.Excludes = UserFilters;
            serialiser.Serialise(Workbook, ValidationTemplate);

            LogBackground(String.Format("Export Complete: {0}", parameters.ModelFile));

            Process.Start(parameters.ModelFile);

            LogBackground("Finished COBie Validation");
        }
Пример #37
0
        /// <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;
        }
Пример #38
0
 /// <summary>
 /// Returns a list of class types to use as exclusions
 /// </summary>
 /// <param name="CobiePickLists">COBieSheet of COBiePickListsRow</param>
 /// <param name="reqType">Type object to filter selection on</param>
 /// <param name="colIndex">column index to get required classes from</param>
 /// <returns></returns>
 private List<Type> GetExcludedTypes(COBieSheet<COBiePickListsRow> CobiePickLists, Type reqType, int colIndex)
 {
     List<Type> classTypes = AppDomain.CurrentDomain.GetAssemblies().SelectMany(a => a.GetTypes()).Where(t => t.IsSubclassOf(reqType)).ToList();
     
     if ((CobiePickLists.RowCount > 0) && 
         (classTypes.Count > 0)
         )
     {
         for (int i = 0; i < CobiePickLists.RowCount; i++)
         {
             COBiePickListsRow row = CobiePickLists[i];
             var colvalue = row[colIndex];
             if ((colvalue != null) && 
                 (!string.IsNullOrEmpty(colvalue.CellValue))
                 )
             {
                 IfcType ifcType;
                 if (IfcMetaData.TryGetIfcType(colvalue.CellValue.Trim().ToUpper(), out ifcType))
                     classTypes.Remove(ifcType.Type);
             }
         }
     }
     return classTypes;
 }
Пример #39
0
        // Populate PickLists by column
        public COBieSheet<COBiePickListsRow> GetCOBiePickListsSheet(string pickListsXMLFilePath)
        {
            // read xml document for picklists
            if (string.IsNullOrEmpty(pickListsXMLFilePath)) pickListsXMLFilePath = "PickLists.xml";
            XmlDocument xdoc = new XmlDocument();
            xdoc.Load(pickListsXMLFilePath);
            XmlNodeList items = xdoc.SelectNodes("//PickLists//Item");

            COBieSheet<COBiePickListsRow> pickLists = new COBieSheet<COBiePickListsRow>(Constants.WORKSHEET_PICKLISTS);

            foreach (XmlNode node in items)
            {
                COBiePickListsRow pickList = new COBiePickListsRow(pickLists);
                XmlElement itemEle = (XmlElement)node;

                pickList.ApprovalBy = itemEle.GetElementsByTagName("ApprovalBy")[0].InnerText;
                pickList.AreaUnit = itemEle.GetElementsByTagName("AreaUnit")[0].InnerText;
                pickList.AssetType = itemEle.GetElementsByTagName("AssetType")[0].InnerText;
                pickList.CategoryFacility = itemEle.GetElementsByTagName("Category-Facility")[0].InnerText;
                pickList.CategorySpace = itemEle.GetElementsByTagName("Category-Space")[0].InnerText;
                pickList.CategoryElement = itemEle.GetElementsByTagName("Category-Element")[0].InnerText;
                pickList.CategoryProduct = itemEle.GetElementsByTagName("Category-Product")[0].InnerText;
                pickList.CategoryRole = itemEle.GetElementsByTagName("Category-Role")[0].InnerText;
                pickList.CoordinateSheet = itemEle.GetElementsByTagName("CoordinateSheet")[0].InnerText;
                pickList.ConnectionType = itemEle.GetElementsByTagName("ConnectionType")[0].InnerText;
                pickList.CoordinateType = itemEle.GetElementsByTagName("CoordinateType")[0].InnerText;
                pickList.DocumentType = itemEle.GetElementsByTagName("DocumentType")[0].InnerText;
                pickList.DurationUnit = itemEle.GetElementsByTagName("DurationUnit")[0].InnerText;
                pickList.FloorType = itemEle.GetElementsByTagName("FloorType")[0].InnerText;
                pickList.IssueCategory = itemEle.GetElementsByTagName("IssueCategory")[0].InnerText;
                pickList.IssueChance = itemEle.GetElementsByTagName("IssueChance")[0].InnerText;
                pickList.IssueImpact = itemEle.GetElementsByTagName("IssueImpact")[0].InnerText;
                pickList.IssueRisk = itemEle.GetElementsByTagName("IssueRisk")[0].InnerText;
                pickList.JobStatusType = itemEle.GetElementsByTagName("JobStatusType")[0].InnerText;
                pickList.JobType = itemEle.GetElementsByTagName("JobType")[0].InnerText;
                pickList.ObjAttribute = itemEle.GetElementsByTagName("objAttribute")[0].InnerText;
                pickList.ObjAttributeType = itemEle.GetElementsByTagName("objAttributeType")[0].InnerText;
                pickList.ObjComponent = itemEle.GetElementsByTagName("objComponent")[0].InnerText;
                pickList.ObjConnection = itemEle.GetElementsByTagName("objConnection")[0].InnerText;
                pickList.ObjContact = itemEle.GetElementsByTagName("objContact")[0].InnerText;
                pickList.ObjCoordinate = itemEle.GetElementsByTagName("objCoordinate")[0].InnerText;
                pickList.ObjDocument = itemEle.GetElementsByTagName("objDocument")[0].InnerText;
                pickList.ObjFacility = itemEle.GetElementsByTagName("objFacility")[0].InnerText;
                pickList.ObjFloor = itemEle.GetElementsByTagName("objFloor")[0].InnerText;
                pickList.ObjIssue = itemEle.GetElementsByTagName("objIssue")[0].InnerText;
                pickList.ObjJob = itemEle.GetElementsByTagName("objJob")[0].InnerText;
                pickList.ObjProject = itemEle.GetElementsByTagName("objProject")[0].InnerText;
                pickList.ObjResource = itemEle.GetElementsByTagName("objResource")[0].InnerText;
                pickList.ObjSite = itemEle.GetElementsByTagName("objSite")[0].InnerText;
                pickList.ObjSpace = itemEle.GetElementsByTagName("objSpace")[0].InnerText;
                pickList.ObjSpare = itemEle.GetElementsByTagName("objSpare")[0].InnerText;
                pickList.ObjSystem = itemEle.GetElementsByTagName("objSystem")[0].InnerText;
                pickList.ObjType = itemEle.GetElementsByTagName("objType")[0].InnerText;
                pickList.ObjWarranty = itemEle.GetElementsByTagName("objWarranty")[0].InnerText;
                pickList.ObjZone = itemEle.GetElementsByTagName("objZone")[0].InnerText;
                pickList.ResourceType = itemEle.GetElementsByTagName("ResourceType")[0].InnerText;
                pickList.SheetType = itemEle.GetElementsByTagName("SheetType")[0].InnerText;
                pickList.SpareType = itemEle.GetElementsByTagName("SpareType")[0].InnerText;
                pickList.StageType = itemEle.GetElementsByTagName("StageType")[0].InnerText;
                pickList.ZoneType = itemEle.GetElementsByTagName("ZoneType")[0].InnerText;
                pickList.LinearUnit = itemEle.GetElementsByTagName("LinearUnit")[0].InnerText;
                pickList.VolumeUnit = itemEle.GetElementsByTagName("VolumeUnit")[0].InnerText;
                pickList.CostUnit = itemEle.GetElementsByTagName("CostUnit")[0].InnerText;
                pickList.AssemblyType = itemEle.GetElementsByTagName("AssemblyType")[0].InnerText;
                pickList.ImpactType = itemEle.GetElementsByTagName("ImpactType")[0].InnerText;
                pickList.ImpactStage = itemEle.GetElementsByTagName("ImpactStage")[0].InnerText;
                pickList.ImpactUnit = itemEle.GetElementsByTagName("ImpactUnit")[0].InnerText;
                pickList.ObjAssembly = itemEle.GetElementsByTagName("objAssembly")[0].InnerText;
                pickList.ObjImpact = itemEle.GetElementsByTagName("objImpact")[0].InnerText;

                pickLists.Rows.Add(pickList);
            }

            return pickLists;
        }
Пример #40
0
        /// <summary>
        /// Fill sheet rows for System sheet
        /// </summary>
        /// <returns>COBieSheet</returns>
        public  COBieSheet<COBieSystemRow> Fill(Dictionary<string, HashSet<string>> compIndices)
        {
            ProgressIndicator.ReportMessage("Starting Systems...");

            //Create new sheet
            COBieSheet<COBieSystemRow> systems = new COBieSheet<COBieSystemRow>(Constants.WORKSHEET_SYSTEM);

            // get all IfcSystem, IfcGroup and IfcElectricalCircuit objects from IFC file
            IEnumerable<IfcGroup> ifcGroups = Model.FederatedInstances.OfType<IfcGroup>().Where(ifcg => ifcg is IfcSystem); //get anything that is IfcSystem or derived from it eg IfcElectricalCircuit
            //IEnumerable<IfcSystem> ifcSystems = Model.FederatedInstances.OfType<IfcSystem>();
            //IEnumerable<IfcElectricalCircuit> ifcElectricalCircuits = Model.FederatedInstances.OfType<IfcElectricalCircuit>();
            //ifcGroups = ifcGroups.Union(ifcSystems);
            //ifcGroups = ifcGroups.Union(ifcElectricalCircuits);

            //Alternative method of extraction
            List<string> PropertyNames = new List<string> { "Circuit Number", "System Name" };

            IEnumerable<IfcPropertySet> ifcPropertySets = from ps in Model.FederatedInstances.OfType<IfcPropertySet>()
                                                          from psv in ps.HasProperties.OfType<IfcPropertySingleValue>()
                                                          where PropertyNames.Contains(psv.Name)
                                                          select ps;

            ProgressIndicator.Initialise("Creating Systems", ifcGroups.Count() + ifcPropertySets.Count());

            foreach (IfcGroup ifcGroup in ifcGroups)
            {
                ProgressIndicator.IncrementAndUpdate();

                IEnumerable<IfcProduct> ifcProducts = (ifcGroup.IsGroupedBy == null) ? Enumerable.Empty<IfcProduct>() : ifcGroup.IsGroupedBy.RelatedObjects.OfType<IfcProduct>();

                foreach (IfcProduct product in ifcProducts)
                {
                    COBieSystemRow sys = new COBieSystemRow(systems);

                    sys.Name = ifcGroup.Name;

                    sys.CreatedBy = GetTelecomEmailAddress(ifcGroup.OwnerHistory);
                    sys.CreatedOn = GetCreatedOnDateAsFmtString(ifcGroup.OwnerHistory);

                    sys.Category = GetCategory(ifcGroup);
                    string name = product.Name;
                    if (string.IsNullOrEmpty(product.Name) || (product.Name == Constants.DEFAULT_STRING))
                    {
                        name = product.GetType().Name + " Name Unknown " + UnknownCount.ToString();
                        UnknownCount++;
                    }
                    else
                    {
                        if (compIndices.Count > 0) //check we have values
                        {
                            //check for name in components , if missing exclude from system, unknown names are listed see above
                            if (!compIndices["Name"].Contains(name, StringComparer.OrdinalIgnoreCase))
                                continue;
                        }
                        
                    }
                    sys.ComponentNames = product.Name;
                    sys.ExtSystem = GetExternalSystem(ifcGroup);
                    sys.ExtObject = ifcGroup.GetType().Name; //need to create product if filtered out in the components sheet
                    if (!string.IsNullOrEmpty(ifcGroup.GlobalId))
                    {
                        sys.ExtIdentifier = ifcGroup.GlobalId;//need to create product if filtered out in the components sheet
                    }
                    sys.Description = GetSystemDescription(ifcGroup);

                    systems.AddRow(sys);
                }
                //check if no products then add group only, new line for each, or should we do as assembly? conCant with :
                if (!ifcProducts.Any())
                {
                    COBieSystemRow sys = new COBieSystemRow(systems);

                    sys.Name = ifcGroup.Name;

                    sys.CreatedBy = GetTelecomEmailAddress(ifcGroup.OwnerHistory);
                    sys.CreatedOn = GetCreatedOnDateAsFmtString(ifcGroup.OwnerHistory);

                    sys.Category = GetCategory(ifcGroup);
                    sys.ComponentNames = DEFAULT_STRING;
                    sys.ExtSystem = GetExternalSystem(ifcGroup);
                    sys.ExtObject = ifcGroup.GetType().Name;
                    if (!string.IsNullOrEmpty(ifcGroup.GlobalId))
                    {
                        sys.ExtIdentifier = ifcGroup.GlobalId;
                    }
                    sys.Description = GetSystemDescription(ifcGroup);

                    systems.AddRow(sys);
                }

            }

            
            foreach (IfcPropertySet ifcPropertySet in ifcPropertySets)
            {
                ProgressIndicator.IncrementAndUpdate();
                string name =  "";
                IfcRelDefinesByProperties ifcRelDefinesByProperties = ifcPropertySet.PropertyDefinitionOf.FirstOrDefault(); //one or zero 
                IfcPropertySingleValue ifcPropertySingleValue = ifcPropertySet.HasProperties.OfType<IfcPropertySingleValue>().Where(psv => PropertyNames.Contains(psv.Name)).FirstOrDefault();
                if ((ifcPropertySingleValue != null) && (ifcPropertySingleValue.NominalValue != null) && (!string.IsNullOrEmpty(ifcPropertySingleValue.NominalValue.ToString())))
                    name = ifcPropertySingleValue.NominalValue.ToString();
                else //try for "System Classification" Not in matrix but looks a good candidate
                {
                    IfcPropertySingleValue ifcPropertySVClassification = ifcPropertySet.HasProperties.OfType<IfcPropertySingleValue>().Where(psv => psv.Name == "System Classification").FirstOrDefault(); 
                    if ((ifcPropertySVClassification != null) && (ifcPropertySVClassification.NominalValue != null) && (!string.IsNullOrEmpty(ifcPropertySVClassification.NominalValue.ToString())))
                        name = ifcPropertySVClassification.NominalValue.ToString();
                }
                
                foreach (IfcObject ifcObject in ifcRelDefinesByProperties.RelatedObjects)
                {
                    if (ifcObject != null)
                    {
                        COBieSystemRow sys = new COBieSystemRow(systems);
                        //OK if we have no name lets just guess at the first value as we need a value
                        if (string.IsNullOrEmpty(name))
                        {
                            //get first text value held in NominalValue
                            var names = ifcPropertySet.HasProperties.OfType<IfcPropertySingleValue>().Where(psv => (psv.NominalValue != null) && (!string.IsNullOrEmpty(psv.NominalValue.ToString()))).Select(psv => psv.NominalValue).FirstOrDefault();
                            if (names != null)
                            {
                                name = names.ToString();
                            }
                            else
                            {
                                //OK last chance, lets take the property name that is not in the filter list of strings, ie. != "Circuit Number", "System Name" or "System Classification" from above 
                                IfcPropertySingleValue propname = ifcPropertySet.HasProperties.OfType<IfcPropertySingleValue>().Where(psv => !PropertyNames.Contains(psv.Name)).FirstOrDefault();
                                if (propname != null)
                                    name = propname.Name.ToString();
                            }
                            
                        }
                        sys.Name = string.IsNullOrEmpty(name) ? DEFAULT_STRING : name;

                        sys.CreatedBy = GetTelecomEmailAddress(ifcObject.OwnerHistory);
                        sys.CreatedOn = GetCreatedOnDateAsFmtString(ifcObject.OwnerHistory);
                        
                        sys.Category = (ifcPropertySingleValue.Name == "Circuit Number") ? "circuit" : GetCategory(ifcObject); //per matrix v9
                        //check that the element is in the component list
                        if (compIndices.Count > 0) //check we have values
                        {
                            //check for name in components , if missing exclude from system, unknown names are listed see above
                            if (!compIndices["Name"].Contains(ifcObject.Name.ToString(), StringComparer.OrdinalIgnoreCase))
                                continue;
                        }
                        sys.ComponentNames = ifcObject.Name;
                        sys.ExtSystem = GetExternalSystem(ifcPropertySet);
                        sys.ExtObject = ifcPropertySingleValue.GetType().Name;
                        sys.Description = string.IsNullOrEmpty(name) ? DEFAULT_STRING : name; ;

                        systems.AddRow(sys);
                    }
                }
            }

            systems.OrderBy(s => s.Name);

            ProgressIndicator.Finalise();
            return systems;
        }
Пример #41
0
        /// <summary>
        /// Fill sheet rows for Contact sheet
        /// </summary>
        /// <returns>COBieSheet</returns>
        public override COBieSheet <COBieContactRow> Fill()
        {
            ProgressIndicator.ReportMessage("Starting Contacts...");

            ClearEMails(); //clear the email dictionary for a new file conversion

            //create new sheet
            COBieSheet <COBieContactRow>           contacts                  = new COBieSheet <COBieContactRow>(Constants.WORKSHEET_CONTACT);
            IEnumerable <string>                   cobieContacts             = Model.Instances.OfType <IfcPropertySingleValue>().Where(psv => psv.Name == "COBieCreatedBy" || psv.Name == "COBieTypeCreatedBy").GroupBy(psv => psv.NominalValue).Select(g => g.First().NominalValue.ToString());
            IEnumerable <IfcPersonAndOrganization> ifcPersonAndOrganizations = Model.Instances.OfType <IfcPersonAndOrganization>();

            ProgressIndicator.Initialise("Creating Contacts", ifcPersonAndOrganizations.Count() + cobieContacts.Count());

            List <IfcOrganizationRelationship> ifcOrganizationRelationships = null;

            foreach (IfcPersonAndOrganization ifcPersonAndOrganization in ifcPersonAndOrganizations)
            {
                ProgressIndicator.IncrementAndUpdate();

                //check we do not have a default email address, if skip it as we want the validation warning
                string email = GetTelecomEmailAddress(ifcPersonAndOrganization);
                if (email == Constants.DEFAULT_EMAIL)
                {
                    continue;
                }

                COBieContactRow contact = new COBieContactRow(contacts);
                // get person and organization
                IfcOrganization ifcOrganization = ifcPersonAndOrganization.TheOrganization;
                IfcPerson       ifcPerson       = ifcPersonAndOrganization.ThePerson;
                contact.Email = email;

                //lets default the creator to that user who created the project for now, no direct link to OwnerHistory on IfcPersonAndOrganization, IfcPerson or IfcOrganization
                contact.CreatedBy = GetTelecomEmailAddress(Model.IfcProject.OwnerHistory);
                contact.CreatedOn = GetCreatedOnDateAsFmtString(Model.IfcProject.OwnerHistory);

                IfcActorRole ifcActorRole = null;
                if (ifcPerson.Roles != null)
                {
                    ifcActorRole = ifcPerson.Roles.FirstOrDefault();
                }
                if (ifcOrganization.Roles != null)
                {
                    ifcActorRole = ifcOrganization.Roles.FirstOrDefault();
                }
                if ((ifcActorRole != null) && (!string.IsNullOrEmpty(ifcActorRole.UserDefinedRole)))
                {
                    contact.Category = ifcActorRole.UserDefinedRole.ToString();
                }
                else
                {
                    contact.Category = DEFAULT_STRING;
                }

                contact.Company   = (string.IsNullOrEmpty(ifcOrganization.Name)) ? DEFAULT_STRING : ifcOrganization.Name.ToString();
                contact.Phone     = GetTelecomTelephoneNumber(ifcPersonAndOrganization);
                contact.ExtSystem = DEFAULT_STRING;   // TODO: Person is not a Root object so has no Owner. What should this be?

                contact.ExtObject = "IfcPersonAndOrganization";
                if (!string.IsNullOrEmpty(ifcPerson.Id))
                {
                    contact.ExtIdentifier = ifcPerson.Id;
                }
                //get department
                string department = "";
                if (ifcPerson.Addresses != null)
                {
                    department = ifcPerson.Addresses.PostalAddresses.Select(dept => dept.InternalLocation).Where(dept => !string.IsNullOrEmpty(dept)).FirstOrDefault();
                }
                if (string.IsNullOrEmpty(department))
                {
                    if (ifcOrganizationRelationships == null)
                    {
                        ifcOrganizationRelationships = Model.Instances.OfType <IfcOrganizationRelationship>().ToList();
                    }
                    IfcOrganization ifcRelOrganization = ifcOrganizationRelationships
                                                         .Where(Or => Or.RelatingOrganization.EntityLabel == ifcOrganization.EntityLabel && Or.RelatedOrganizations.Last() != null)
                                                         .Select(Or => Or.RelatedOrganizations.Last())
                                                         .LastOrDefault();
                    if (ifcRelOrganization != null)
                    {
                        department = ifcRelOrganization.Name.ToString();
                    }
                }
                if (string.IsNullOrEmpty(department))
                {
                    department = ifcOrganization.Description.ToString(); //only place to match example files
                }
                contact.Department = (string.IsNullOrEmpty(department)) ? contact.Company : department;

                contact.OrganizationCode = (string.IsNullOrEmpty(ifcOrganization.Id)) ? DEFAULT_STRING : ifcOrganization.Id.ToString();
                contact.GivenName        = (string.IsNullOrEmpty(ifcPerson.GivenName)) ? DEFAULT_STRING : ifcPerson.GivenName.ToString();
                contact.FamilyName       = (string.IsNullOrEmpty(ifcPerson.FamilyName)) ? DEFAULT_STRING : ifcPerson.FamilyName.ToString();
                if (ifcPerson.Addresses != null)
                {
                    GetContactAddress(contact, ifcPerson.Addresses);
                }
                else
                {
                    GetContactAddress(contact, ifcOrganization.Addresses);
                }

                contacts.AddRow(contact);
            }

            foreach (string email in cobieContacts)
            {
                ProgressIndicator.IncrementAndUpdate();
                COBieContactRow contact = new COBieContactRow(contacts);
                contact.Email = email;

                //lets default the creator to that user who created the project for now, no direct link to OwnerHistory on IfcPersonAndOrganization, IfcPerson or IfcOrganization
                contact.CreatedBy = GetTelecomEmailAddress(Model.IfcProject.OwnerHistory);
                contact.CreatedOn = GetCreatedOnDateAsFmtString(Model.IfcProject.OwnerHistory);
                contact.Category  = DEFAULT_STRING;
                contact.Company   = DEFAULT_STRING;
                contact.Phone     = DEFAULT_STRING;
                contact.ExtSystem = DEFAULT_STRING;

                contact.ExtObject  = "IfcPropertySingleValue";
                contact.Department = DEFAULT_STRING;

                contact.OrganizationCode = DEFAULT_STRING;
                contact.GivenName        = DEFAULT_STRING;
                contact.FamilyName       = DEFAULT_STRING;
                contact.Street           = DEFAULT_STRING;
                contact.PostalBox        = DEFAULT_STRING;
                contact.Town             = DEFAULT_STRING;
                contact.StateRegion      = DEFAULT_STRING;
                contact.PostalCode       = DEFAULT_STRING;
                contact.Country          = DEFAULT_STRING;

                contacts.AddRow(contact);
            }
            ProgressIndicator.Finalise();

            contacts.OrderBy(s => s.Email);

            return(contacts);
        }
Пример #42
0
        /// <summary>
        /// Constructor 
        /// </summary>
        /// <param name="model">IModel to read data from</param>
        public COBieQueries(COBieContext context)
        {
            _context = context;

            _attributes = new COBieSheet<COBieAttributeRow>(Constants.WORKSHEET_ATTRIBUTE); //create the attribute sheet
        }
Пример #43
0
        /// <summary>
        /// Fill sheet rows for Coordinate sheet
        /// </summary>
        public override COBieSheet <COBieCoordinateRow> Fill()
        {
            //get the conversion to the COBie units (metres or feet)
            double conversionFactor;
            var    cobieUnits = Context.WorkBookUnits.LengthUnit.ToLowerInvariant();

            if (cobieUnits == "meters" || cobieUnits == "metres")
            {
                conversionFactor = Model.ModelFactors.OneMetre;
            }
            else if (cobieUnits == "millimeters" || cobieUnits == "millimetres")
            {
                conversionFactor = Model.ModelFactors.OneMilliMetre;
            }
            else if (cobieUnits == "feet" || cobieUnits == "foot")
            {
                conversionFactor = Model.ModelFactors.OneFoot;
            }
            else if (cobieUnits == "inch" || cobieUnits == "inches")
            {
                conversionFactor = Model.ModelFactors.OneInch;
            }
            else
            {
                throw new Exception(
                          string.Format("The COBie units are incorrectly set, the provided value {0} is invalid.",
                                        cobieUnits));
            }

            XbimMatrix3D globalTransform = XbimMatrix3D.CreateScale(1 / conversionFactor);

            var coordinates = new COBieSheet <COBieCoordinateRow>(Constants.WORKSHEET_COORDINATE);

            ProgressIndicator.ReportMessage("Starting Coordinates...");


            //Create new sheet

            //Get buildings and spaces
            var ifcBuildingStoreys = Model.FederatedInstances.OfType <IfcBuildingStorey>();
            var ifcSpaces          = Model.FederatedInstances.OfType <IfcSpace>()
                                     .OrderBy(ifcSpace => ifcSpace.Name, new CompareIfcLabel());
            var ifcProducts = ifcBuildingStoreys.Union <IfcProduct>(ifcSpaces); //add spaces

            //get component products as shown in Component sheet
            var relAggregates = Model.FederatedInstances.OfType <IfcRelAggregates>();
            var relSpatial    = Model.FederatedInstances.OfType <IfcRelContainedInSpatialStructure>();
            var ifcElements   = ((from x in relAggregates
                                  from y in x.RelatedObjects
                                  where !Context.Exclude.ObjectType.Component.Contains(y.GetType())
                                  select y).Union(from x in relSpatial
                                                  from y in x.RelatedElements
                                                  where !Context.Exclude.ObjectType.Component.Contains(y.GetType())
                                                  select y)).OfType <IfcProduct>(); //.GroupBy(el => el.Name).Select(g => g.First())

            ifcProducts = ifcProducts.Union(ifcElements);

            var productList = ifcProducts as IList <IfcProduct> ?? ifcProducts.ToList();

            ProgressIndicator.Initialise("Creating Coordinates", productList.Count());

            var m3D = new Xbim3DModelContext(Model);

            foreach (var ifcProduct in productList)
            {
                ProgressIndicator.IncrementAndUpdate();
                //if no name to link the row name too skip it, as no way to link back to the parent object
                //if (string.IsNullOrEmpty(ifcProduct.Name))
                //    continue;

                var coordinate = new COBieCoordinateRow(coordinates)
                {
                    Name = (string.IsNullOrEmpty(ifcProduct.Name.ToString()))
                        ? DEFAULT_STRING
                        : ifcProduct.Name.ToString(),
                    CreatedBy = GetTelecomEmailAddress(ifcProduct.OwnerHistory),
                    CreatedOn = GetCreatedOnDateAsFmtString(ifcProduct.OwnerHistory)
                };

                // (ifcBuildingStorey == null || ifcBuildingStorey.Name.ToString() == "") ? "CoordinateName" : ifcBuildingStorey.Name.ToString();

                coordinate.RowName = coordinate.Name;

                XbimPoint3D?ifcCartesianPointLower = null;
                XbimPoint3D?ifcCartesianPointUpper = null;
                var         transBox = new TransformedBoundingBox();
                if (ifcProduct is IfcBuildingStorey)
                {
                    XbimMatrix3D worldMatrix = ifcProduct.ObjectPlacement.ToMatrix3D();
                    ifcCartesianPointLower = new XbimPoint3D(worldMatrix.OffsetX, worldMatrix.OffsetY,
                                                             worldMatrix.OffsetZ);
                    //get the offset from the world coordinates system 0,0,0 point, i.e. origin point of this object in world space
                    coordinate.SheetName   = "Floor";
                    coordinate.Category    = "point";
                    ifcCartesianPointUpper = null;
                }
                else
                {
                    if (ifcProduct is IfcSpace)
                    {
                        coordinate.SheetName = "Space";
                    }
                    else
                    {
                        coordinate.SheetName = "Component";
                    }

                    coordinate.Category = "box-lowerleft"; //and box-upperright, so two values required when we do this

                    var          boundBox  = XbimRect3D.Empty;
                    XbimMatrix3D transform = XbimMatrix3D.Identity;
                    foreach (var shapeInstance in m3D.ShapeInstancesOf(ifcProduct))
                    {
                        if (boundBox.IsEmpty)
                        {
                            boundBox = shapeInstance.BoundingBox;
                        }
                        else
                        {
                            boundBox.Union(shapeInstance.BoundingBox);
                        }
                        transform = shapeInstance.Transformation;
                    }
                    if (!boundBox.IsEmpty)
                    {
                        XbimMatrix3D m = globalTransform * transform;
                        transBox = new TransformedBoundingBox(boundBox, m);
                        //set points
                        ifcCartesianPointLower = transBox.MinPt;
                        ifcCartesianPointUpper = transBox.MaxPt;
                    }
                }

                if (ifcCartesianPointLower.HasValue)
                {
                    coordinate.CoordinateXAxis = string.Format("{0}", (double)ifcCartesianPointLower.Value.X);
                    coordinate.CoordinateYAxis = string.Format("{0}", (double)ifcCartesianPointLower.Value.Y);
                    coordinate.CoordinateZAxis = string.Format("{0}", (double)ifcCartesianPointLower.Value.Z);
                    coordinate.ExtSystem       = GetExternalSystem(ifcProduct);
                    coordinate.ExtObject       = ifcProduct.GetType().Name;
                    if (!string.IsNullOrEmpty(ifcProduct.GlobalId))
                    {
                        coordinate.ExtIdentifier = ifcProduct.GlobalId.ToString();
                    }

                    coordinate.ClockwiseRotation   = transBox.ClockwiseRotation.ToString("F4");
                    coordinate.ElevationalRotation = transBox.ElevationalRotation.ToString("F4");
                    coordinate.YawRotation         = transBox.YawRotation.ToString("F4");

                    coordinates.AddRow(coordinate);
                }

                if (ifcCartesianPointUpper.HasValue) //we need a second row for upper point
                {
                    var coordinateUpper = new COBieCoordinateRow(coordinates);
                    coordinateUpper.Name                = coordinate.Name;
                    coordinateUpper.CreatedBy           = coordinate.CreatedBy;
                    coordinateUpper.CreatedOn           = coordinate.CreatedOn;
                    coordinateUpper.RowName             = coordinate.RowName;
                    coordinateUpper.SheetName           = coordinate.SheetName;
                    coordinateUpper.Category            = "box-upperright";
                    coordinateUpper.CoordinateXAxis     = string.Format("{0}", (double)ifcCartesianPointUpper.Value.X);
                    coordinateUpper.CoordinateYAxis     = string.Format("{0}", (double)ifcCartesianPointUpper.Value.Y);
                    coordinateUpper.CoordinateZAxis     = string.Format("{0}", (double)ifcCartesianPointUpper.Value.Z);
                    coordinateUpper.ExtSystem           = coordinate.ExtSystem;
                    coordinateUpper.ExtObject           = coordinate.ExtObject;
                    coordinateUpper.ExtIdentifier       = coordinate.ExtIdentifier;
                    coordinateUpper.ClockwiseRotation   = coordinate.ClockwiseRotation;
                    coordinateUpper.ElevationalRotation = coordinate.ElevationalRotation;
                    coordinateUpper.YawRotation         = coordinate.YawRotation;

                    coordinates.AddRow(coordinateUpper);
                }
            }

            coordinates.OrderBy(s => s.Name);

            ProgressIndicator.Finalise();


            return(coordinates);
        }
Пример #44
0
 public void InitialiseAttributes(ref COBieSheet <COBieAttributeRow> attributeSheet)
 {
     _attributes = attributeSheet;
 }
Пример #45
0
        /// <summary>
        /// Fill sheet rows for Floor sheet
        /// </summary>
        /// <returns>COBieSheet</returns>
        public override COBieSheet <COBieFloorRow> Fill()
        {
            ProgressIndicator.ReportMessage("Starting Floors...");

            //create new sheet
            COBieSheet <COBieFloorRow> floors = new COBieSheet <COBieFloorRow>(Constants.WORKSHEET_FLOOR);

            // get all IfcBuildingStory objects from IFC file
            IEnumerable <IfcBuildingStorey> buildingStories = Model.Instances.OfType <IfcBuildingStorey>();

            COBieDataPropertySetValues allPropertyValues = new COBieDataPropertySetValues(); //properties helper class
            COBieDataAttributeBuilder  attributeBuilder  = new COBieDataAttributeBuilder(Context, allPropertyValues);

            attributeBuilder.InitialiseAttributes(ref _attributes);


            //IfcClassification ifcClassification = Model.Instances.OfType<IfcClassification>().FirstOrDefault();
            //list of attributes to exclude form attribute sheet

            //set up filters on COBieDataPropertySetValues for the SetAttributes only
            attributeBuilder.ExcludeAttributePropertyNames.AddRange(Context.Exclude.Floor.AttributesEqualTo);
            attributeBuilder.ExcludeAttributePropertyNamesWildcard.AddRange(Context.Exclude.Floor.AttributesContain);
            attributeBuilder.RowParameters["Sheet"] = "Floor";



            ProgressIndicator.Initialise("Creating Floors", buildingStories.Count());

            foreach (IfcBuildingStorey ifcBuildingStorey in buildingStories)
            {
                ProgressIndicator.IncrementAndUpdate();

                COBieFloorRow floor = new COBieFloorRow(floors);
                string        name  = ifcBuildingStorey.Name;
                if (string.IsNullOrEmpty(ifcBuildingStorey.Name))
                {
                    ifcBuildingStorey.Name = "Name Unknown " + UnknownCount.ToString();
                    UnknownCount++;
                }

                //set allPropertyValues to this element
                allPropertyValues.SetAllPropertyValues(ifcBuildingStorey); //set the internal filtered IfcPropertySingleValues List in allPropertyValues


                floor.Name = name;

                string createBy = allPropertyValues.GetPropertySingleValueValue("COBieCreatedBy", false);  //support for COBie Toolkit for Autodesk Revit
                floor.CreatedBy = ValidateString(createBy) ? createBy : GetTelecomEmailAddress(ifcBuildingStorey.OwnerHistory);
                string createdOn = allPropertyValues.GetPropertySingleValueValue("COBieCreatedOn", false); //support for COBie Toolkit for Autodesk Revit
                floor.CreatedOn = ValidateString(createdOn) ? createdOn : GetCreatedOnDateAsFmtString(ifcBuildingStorey.OwnerHistory);

                floor.Category = GetCategory(ifcBuildingStorey);

                string extSystem = allPropertyValues.GetPropertySingleValueValue("COBieExtSystem", false);//support for COBie Toolkit for Autodesk Revit
                floor.ExtSystem     = ValidateString(extSystem) ? extSystem : GetExternalSystem(ifcBuildingStorey);
                floor.ExtObject     = ifcBuildingStorey.GetType().Name;
                floor.ExtIdentifier = ifcBuildingStorey.GlobalId;
                string description = allPropertyValues.GetPropertySingleValueValue("COBieDescription", false);//support for COBie Toolkit for Autodesk Revit
                floor.Description = ValidateString(description) ? description : GetFloorDescription(ifcBuildingStorey);
                floor.Elevation   = (string.IsNullOrEmpty(ifcBuildingStorey.Elevation.ToString())) ? DEFAULT_NUMERIC : string.Format("{0}", (double)ifcBuildingStorey.Elevation);

                floor.Height = GetFloorHeight(ifcBuildingStorey, allPropertyValues);

                floors.AddRow(floor);

                //fill in the attribute information
                attributeBuilder.RowParameters["Name"]      = floor.Name;
                attributeBuilder.RowParameters["CreatedBy"] = floor.CreatedBy;
                attributeBuilder.RowParameters["CreatedOn"] = floor.CreatedOn;
                attributeBuilder.RowParameters["ExtSystem"] = floor.ExtSystem;
                attributeBuilder.PopulateAttributesRows(ifcBuildingStorey); //fill attribute sheet rows//pass data from this sheet info as Dictionary
            }

            floors.OrderBy(s => s.Name);

            ProgressIndicator.Finalise();

            return(floors);
        }
Пример #46
0
        /// <summary>
        /// Fill sheet rows for Document sheet
        /// </summary>
        /// <returns>COBieSheet</returns>
        public override COBieSheet <COBieDocumentRow> Fill()
        {
            ProgressIndicator.ReportMessage("Starting Documents...");
            var ifcProject = Model.Instances.FirstOrDefault <IIfcProject>();

            Debug.Assert(ifcProject != null);

            //create new sheet
            COBieSheet <COBieDocumentRow> documents = new COBieSheet <COBieDocumentRow>(Constants.WORKSHEET_DOCUMENT);

            // get all IfcBuildingStory objects from IFC file
            IEnumerable <IfcDocumentInformation> docInfos = Model.FederatedInstances.OfType <IfcDocumentInformation>();

            ProgressIndicator.Initialise("Creating Documents", docInfos.Count());

            foreach (IfcDocumentInformation di in docInfos)
            {
                ProgressIndicator.IncrementAndUpdate();

                COBieDocumentRow doc = new COBieDocumentRow(documents);


                doc.Name = (di == null) ? "" : di.Name.ToString();
                //get the first associated document to extract the objects the document refers to
                IfcRelAssociatesDocument ifcRelAssociatesDocument = DocumentInformationForObjects(di).FirstOrDefault();


                if ((ifcRelAssociatesDocument != null) && (ifcRelAssociatesDocument.OwnerHistory != null))
                {
                    doc.CreatedBy = GetTelecomEmailAddress(ifcRelAssociatesDocument.OwnerHistory);
                }
                else if (di.DocumentOwner != null)
                {
                    if (di.DocumentOwner is IfcPersonAndOrganization)
                    {
                        doc.CreatedBy = GetTelecomEmailAddress(di.DocumentOwner as IfcPersonAndOrganization);
                    }
                    else if (di.DocumentOwner is IfcPerson)
                    {
                        doc.CreatedBy = GetEmail(null, di.DocumentOwner as IfcPerson);
                    }
                    else if (di.DocumentOwner is IfcOrganization)
                    {
                        doc.CreatedBy = GetEmail(di.DocumentOwner as IfcOrganization, null);
                    }
                }
                else if (ifcProject.OwnerHistory != null)
                {
                    doc.CreatedBy = GetTelecomEmailAddress(ifcProject.OwnerHistory);
                }


                if ((ifcRelAssociatesDocument != null) && (ifcRelAssociatesDocument.OwnerHistory != null))
                {
                    doc.CreatedOn = GetCreatedOnDateAsFmtString(ifcRelAssociatesDocument.OwnerHistory);
                }
                else if (di.CreationTime != null)
                {
                    doc.CreatedOn = di.CreationTime.ToString();
                }
                else if (ifcProject.OwnerHistory != null)
                {
                    doc.CreatedOn = Context.RunDateTime;
                }


                doc.Category = (string.IsNullOrEmpty(di.Purpose.ToString())) ? DEFAULT_STRING :di.Purpose.ToString();

                doc.ApprovalBy = (string.IsNullOrEmpty(di.IntendedUse.ToString())) ? DEFAULT_STRING : di.IntendedUse.ToString();
                doc.Stage      = (string.IsNullOrEmpty(di.Scope.ToString())) ? DEFAULT_STRING : di.Scope.ToString();


                RelatedObjectInformation relatedObjectInfo = GetRelatedObjectInformation(ifcRelAssociatesDocument);
                doc.SheetName     = relatedObjectInfo.SheetName;
                doc.RowName       = relatedObjectInfo.Name;
                doc.ExtObject     = relatedObjectInfo.ExtObject;
                doc.ExtIdentifier = relatedObjectInfo.ExtIdentifier;
                doc.ExtSystem     = relatedObjectInfo.ExtSystem;

                if (ifcRelAssociatesDocument != null)
                {
                    FileInformation fileInfo = GetFileInformation(ifcRelAssociatesDocument);
                    doc.File      = fileInfo.Name;
                    doc.Directory = GetDirectory(!string.IsNullOrWhiteSpace(fileInfo.Location) ? fileInfo.Location : fileInfo.Name);
                }

                doc.Description = (string.IsNullOrEmpty(di.Description)) ? DEFAULT_STRING : di.Description.ToString();
                doc.Reference   = (string.IsNullOrEmpty(di.DocumentId.Value.ToString())) ? DEFAULT_STRING : di.DocumentId.Value.ToString();

                documents.AddRow(doc);
            }

            documents.OrderBy(s => s.Name);

            ProgressIndicator.Finalise();
            return(documents);
        }
 public void InitialiseAttributes(ref COBieSheet<COBieAttributeRow> attributeSheet)
 {
     _attributes = attributeSheet;
 }