示例#1
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;
                }
            }
        }
示例#2
0
        /// <summary>
        /// Add the data to the IfcConstructionProductResource object
        /// </summary>
        /// <param name="row">COBieSpareRow holding the data</param>
        private void AddSpare(COBieSpareRow row)
        {
            //we are merging so check for an existing item name, assume the same item as should be the same building
            if (CheckIfExistOnMerge <IfcConstructionProductResource>(row.Name))
            {
                return;//we have it so no need to create
            }

            IfcConstructionProductResource ifcConstructionProductResource = Model.Instances.New <IfcConstructionProductResource>();

            //Add Created By, Created On and ExtSystem to Owner History.
            SetUserHistory(ifcConstructionProductResource, row.ExtSystem, row.CreatedBy, row.CreatedOn);

            //using statement will set the Model.OwnerHistoryAddObject to IfcConstructionProductResource.OwnerHistory as OwnerHistoryAddObject is used upon any property changes,
            //then swaps the original OwnerHistoryAddObject back in the dispose, so set any properties within the using statement
            using (COBieXBimEditScope context = new COBieXBimEditScope(Model, ifcConstructionProductResource.OwnerHistory))
            {
                //Add Name
                if (ValidateString(row.Name))
                {
                    ifcConstructionProductResource.Name = row.Name;
                }

                //Add Category
                AddCategory(row.Category, ifcConstructionProductResource);

                //Add Type Relationship
                if (ValidateString(row.TypeName))
                {
                    List <string> typeNames = SplitString(row.TypeName, ':');
                    IEnumerable <IfcTypeObject> ifcTypeObjects = IfcTypeObjects.Where(to => typeNames.Contains(to.Name.ToString().Trim()));
                    SetRelAssignsToResource(ifcConstructionProductResource, ifcTypeObjects);
                }
                //Add GlobalId
                AddGlobalId(row.ExtIdentifier, ifcConstructionProductResource);

                //add Description
                if (ValidateString(row.Description))
                {
                    ifcConstructionProductResource.Description = row.Description;
                }

                if (ValidateString(row.Suppliers))
                {
                    AddPropertySingleValue(ifcConstructionProductResource, "Pset_Spare_COBie", "Spare Properties From COBie", "Suppliers", "Suppliers Contact Details", new IfcLabel(row.Suppliers));
                }

                if (ValidateString(row.SetNumber))
                {
                    AddPropertySingleValue(ifcConstructionProductResource, "Pset_Spare_COBie", null, "SetNumber", "Set Number", new IfcLabel(row.SetNumber));
                }

                if (ValidateString(row.PartNumber))
                {
                    AddPropertySingleValue(ifcConstructionProductResource, "Pset_Spare_COBie", null, "PartNumber", "Part Number", new IfcLabel(row.PartNumber));
                }
            }
        }