Example #1
0
        private bool IsContinuedAssemblyRow(COBieAssemblyRow row)
        {
            if (ValidateString(row.Name))
            {
                if (row.Name.Contains(" : continued "))         //our flag for a continued assembly child list
                {
                    return(true);
                }

                if (ValidateString(row.ChildNames))
                {
                    string name     = row.Name.ToLower().Trim();
                    string lastname = LastRow.Name.ToLower().Trim();
                    lastname = RemPostFixNumber(lastname);

                    if (name.Contains(lastname))
                    {
                        //this is a bit messy but gets over the placement of : on single entries
                        IEnumerable <IfcObjectDefinition> childObjs = GetSheetObjectList(row.SheetName);
                        //check that the name is not a single element, also gets over single entries with : in them
                        string test = row.ChildNames.ToLower().Trim();
                        IfcObjectDefinition RelatedObject = childObjs.Where(obj => obj.Name.ToString().ToLower().Trim() == test).FirstOrDefault();
                        if (RelatedObject != null)
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
Example #2
0
        private bool IsContinuedMaterialRow(COBieAssemblyRow row)
        {
            if (ValidateString(row.Name))
            {
                if (row.Name.Contains(" : continued "))//our flag for a continued assembly child list
                {
                    return(true);
                }

                if (ValidateString(row.ChildNames))
                {
                    string name     = row.Name.ToLower().Trim();
                    string lastname = LastRow.Name.ToLower().Trim();
                    lastname = RemPostFixNumber(lastname);

                    if (name.Contains(lastname))
                    {
                        //test to see if ChildName row as a whole text finds a material, if so then a sing material on the row, so assume the material layer set is listed per row, and not in the ChildName field as a delimited string
                        string           test             = row.ChildNames.ToLower().Trim();
                        IfcMaterialLayer ifcMaterialLayer = IfcMaterialLayers.Where(ml => (ml.Material.Name != null) && (ml.Material.Name.ToString().ToLower().Trim() == test)).FirstOrDefault();
                        if (ifcMaterialLayer != null)
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
Example #3
0
        /// <summary>
        /// Add the data to the IfcMaterialLayerSet object
        /// </summary>
        /// <param name="row">COBieAssemblyRow holding the data</param>
        private void AddMaterial(COBieAssemblyRow row)
        {
            //check we have a chance of creating the IfcMaterialLayerSet object
            if (ValidateString(row.ParentName)) // && (ValidateString(row.ChildNames))
            {
                IfcMaterialLayerSet      ifcMaterialLayerSet      = null;
                IfcMaterialLayerSetUsage ifcMaterialLayerSetUsage = null;
                IfcRelAssociatesMaterial ifcRelAssociatesMaterial = null;
                IfcBuildingElementProxy  ifcBuildingElementProxy  = null;

                if ((LastIfcMaterialLayerSet != null) && IsContinuedMaterialRow(row)) //this row line is a continuation of objects from the line above
                {
                    ifcMaterialLayerSet = LastIfcMaterialLayerSet;
                }
                else
                {
                    ifcMaterialLayerSet = Model.FederatedInstances.Where <IfcMaterialLayerSet>(mls => mls.LayerSetName == row.ParentName).FirstOrDefault();
                    if (ifcMaterialLayerSet == null)
                    {
                        ifcMaterialLayerSet = Model.Instances.New <IfcMaterialLayerSet>(mls => { mls.LayerSetName = row.ParentName; });
                    }

                    ifcMaterialLayerSetUsage = Model.FederatedInstances.Where <IfcMaterialLayerSetUsage>(mlsu => mlsu.ForLayerSet == ifcMaterialLayerSet).FirstOrDefault();
                    if (ifcMaterialLayerSetUsage == null)
                    {
                        ifcMaterialLayerSetUsage = Model.Instances.New <IfcMaterialLayerSetUsage>(mlsu => { mlsu.ForLayerSet = ifcMaterialLayerSet; });
                    }

                    string placeholderText = "Place holder for material layer Set " + row.ParentName;
                    ifcBuildingElementProxy = Model.FederatedInstances.Where <IfcBuildingElementProxy>(bep => bep.Name == placeholderText).FirstOrDefault();
                    if (ifcBuildingElementProxy == null)
                    {
                        ifcBuildingElementProxy = Model.Instances.New <IfcBuildingElementProxy>(bep => { bep.Name = placeholderText; });
                    }
                    ifcRelAssociatesMaterial = Model.FederatedInstances.Where <IfcRelAssociatesMaterial>(ras => ((ras.RelatingMaterial as IfcMaterialLayerSetUsage) == ifcMaterialLayerSetUsage)).FirstOrDefault();
                    if (ifcRelAssociatesMaterial == null)
                    {
                        ifcRelAssociatesMaterial = Model.Instances.New <IfcRelAssociatesMaterial>(ras =>
                        {
                            ras.RelatingMaterial = ifcMaterialLayerSetUsage;
                            ras.RelatedObjects.Add(ifcBuildingElementProxy);
                        });

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

                //add the child objects
                AddChildObjects(ifcMaterialLayerSet, row.ChildNames);
                LastIfcMaterialLayerSet = ifcMaterialLayerSet;
            }
        }
Example #4
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;
                }
            }
        }
Example #5
0
        /// <summary>
        /// Add the data to the IfcRelDecomposes object
        /// </summary>
        /// <param name="row">COBieAssemblyRow holding the data</param>
        private void AddAssembly(COBieAssemblyRow row)
        {
            //check we have a chance of creating the IfcRelDecomposes object
            if ((ValidateString(row.ParentName)) && (ValidateString(row.ChildNames)))
            {
                IfcRelDecomposes ifcRelDecomposes = null;

                if ((LastIfcRelDecomposes != null) && IsContinuedAssemblyRow(row)) //this row line is a continuation of objects from the line above
                {
                    ifcRelDecomposes = LastIfcRelDecomposes;
                }
                else
                {
                    IfcObjectDefinition relatingObject = GetParentObject(row.ParentName);
                    //check on merge we have not already created using name and parent object as check
                    if (ValidateString(row.Name))
                    {
                        string testName = row.Name.ToLower().Trim();
                        ifcRelDecomposes = Model.FederatedInstances.Where <IfcRelDecomposes>(rc => (rc.Name.ToString().ToLower().Trim() == testName) && (rc.RelatingObject == relatingObject)).FirstOrDefault();
                    }

                    if ((ifcRelDecomposes == null) && (relatingObject != null))
                    {
                        if (row.ExtObject.ToLower().Trim() == "ifcrelnests")
                        {
                            ifcRelDecomposes = Model.Instances.New <IfcRelNests>();
                        }
                        else
                        {
                            ifcRelDecomposes = Model.Instances.New <IfcRelAggregates>();
                        }


                        //Add Created By, Created On and ExtSystem to Owner History.
                        SetUserHistory(ifcRelDecomposes, row.ExtSystem, row.CreatedBy, row.CreatedOn);
                    }
                    if (relatingObject == null)
                    {
                        Console.WriteLine(string.Format("Failed to find ifcRelDecomposes parent object in AddAssembly() for {0}", row.Name.ToString()));
                        return;
                    }
                }



                //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, ifcRelDecomposes.OwnerHistory))
                {
                    if (ValidateString(row.Name))
                    {
                        ifcRelDecomposes.Name = row.Name;
                    }
                    if (ValidateString(row.Description))
                    {
                        ifcRelDecomposes.Description = row.Description;
                    }

                    //Add GlobalId
                    AddGlobalId(row.ExtIdentifier, ifcRelDecomposes);

                    if (!(AddParentObject(ifcRelDecomposes, row.ParentName) &&
                          AddChildObjects(ifcRelDecomposes, row.SheetName, row.ChildNames)
                          )
                        )
                    {
                        //failed to add parent or child so remove as not a valid IfcRelDecomposes object
                        try
                        {
                            Model.Delete(ifcRelDecomposes);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(string.Format("Failed to delete ifcRelDecomposes in AddAssembly() - {0}", ex.Message));
                        }
                        ifcRelDecomposes = null;
                    }
                }
                //save for next row, might be a continuation line
                LastIfcRelDecomposes = ifcRelDecomposes;
            }
        }