internal static List <CcManufacturerProduct> GetManufacturerProductsForCode(string code)
        {
            List <CcManufacturerProduct> _products = new List <CcManufacturerProduct>();

            foreach (Document doc in Workspace.Current.Documents.Values)
            {
                //get classificationreference for this code
                IfcClassificationReference classref = GetClassificationReferencesForCode(doc, code);
                if (classref != null)
                {
                    //get relation to propertysettemplate
                    IfcRelAssociatesClassification relassocclass = GetRelAssocClassification(doc, classref);
                    if (relassocclass != null)
                    {
                        List <IfcPropertySet> psets = new List <IfcPropertySet>();
                        foreach (var psettempl in relassocclass.RelatedObjects.Items)
                        {
                            //get propertysets which use the referenced psettemplate
                            if (psettempl is IfcPropertySetTemplate)
                            {
                                List <IfcPropertySet> tempset = GetPropertySetsForTemplateReference(doc, psettempl.Ref);
                                if (tempset != null)
                                {
                                    psets.AddRange(tempset);
                                }
                            }
                        }

                        _products.AddRange(GetListOfManufacturerProducts(doc, psets, code));
                    }
                }
            }

            return(_products);
        }
        private void UpdateIfcExternalReferenceRelationship(string propertyName, IfcClassificationReference ifcClassificationReference)
        {
            if (ifcClassificationReference == null)
            {
                // delete
                DeleteIfcExternalReferenceRelationship();
                return;
            }

            var existingIfcExternalReferenceRelationshipCollection = GetIfcExternalReferenceRelationshipCollection(ifcClassificationReference).ToList();

            if (existingIfcExternalReferenceRelationshipCollection.Any())
            {
                // update
                foreach (var ifcExternalReferenceRelationship in existingIfcExternalReferenceRelationshipCollection)
                {
                    ifcExternalReferenceRelationship.RelatedResourceObjects.Items.Add(this.RefInstance <IfcDocumentInformation>());
                }
            }
            else
            {
                // add
                IfcExternalReferenceRelationship ifcExternalReferenceRelationship = new IfcExternalReferenceRelationship();
                ifcExternalReferenceRelationship.RelatedResourceObjects = new IfcExternalReferenceRelationshipRelatedResourceObjects();
                ifcExternalReferenceRelationship.RelatedResourceObjects.Items.Add(this.RefInstance <IfcDocumentInformation>());
                ifcExternalReferenceRelationship.RelatingReference = ifcClassificationReference.RefInstance <IfcClassificationReference>();
                this.Document.IfcXmlDocument.Items.Add(ifcExternalReferenceRelationship);
            }
        }
Пример #3
0
        private IfcClassificationReference GetOrCreateClassificationReference(string code, string name, IfcClassification source)
        {
            if (code == null)
            {
                return(null);
            }

            IfcClassificationReference classification = _model.Instances.Where <IfcClassificationReference>(s => s.ItemReference == code).FirstOrDefault();

            if (classification == null)
            {
                classification = _model.Instances.New <IfcClassificationReference>(s =>
                {
                    s.ItemReference = code;
                });
            }
            if (name != null)
            {
                classification.Name = name;
            }
            if (source != null)
            {
                classification.ReferencedSource = source;
            }

            return(classification);
        }
Пример #4
0
        /// <summary>
        /// Get Category method for property sets
        /// </summary>
        /// <param name="propSet">IfcPropertySet</param>
        /// <returns>Category as string </returns>
        protected string GetCategory(IfcPropertySet propSet)
        {
            IEnumerable <IfcClassificationReference> cats = from IRAC in propSet.HasAssociations
                                                            where IRAC is IfcRelAssociatesClassification &&
                                                            ((IfcRelAssociatesClassification)IRAC).RelatingClassification is IfcClassificationReference
                                                            select((IfcRelAssociatesClassification)IRAC).RelatingClassification as IfcClassificationReference;

            IfcClassificationReference cat = cats.FirstOrDefault();

            if (cat != null)
            {
                return(cat.Name.ToString());
            }
            //Try by PropertySet as fallback
            var query = from props in propSet.HasProperties
                        where props.Name.ToString() == "OmniClass Table 13 Category" || props.Name.ToString() == "Category Code"
                        select props.ToString().TrimEnd();

            string val = query.FirstOrDefault();

            if (!String.IsNullOrEmpty(val))
            {
                return(val);
            }
            return(Constants.DEFAULT_STRING);
        }
Пример #5
0
        static void Main(string[] args)
        {
            DatabaseIfc db = new DatabaseIfc(ModelView.Ifc4X3NotAssigned);

            db.Factory.Options.GenerateOwnerHistory = false;

            IfcProject        project        = new IfcProject(db, "DemoProject");
            IfcProjectLibrary projectLibrary = new IfcProjectLibrary(db, "ClassificationLibrary");

            project.AddDeclared(projectLibrary);

            IfcClassification classification = new IfcClassification(db, "MyClassification");

            new IfcRelAssociatesClassification(classification, projectLibrary);

            IfcClassificationReference buildingElements = new IfcClassificationReference(classification)
            {
                Identification = "100", Name = "BuildingElements"
            };
            IfcClassificationReference walls = new IfcClassificationReference(buildingElements)
            {
                Identification = "100.100", Name = "Walls"
            };
            IfcClassificationReference partionWalls = new IfcClassificationReference(walls)
            {
                Identification = "100.100.002", Name = "PartiionWalls"
            };

            IfcSimplePropertyTemplate simplePropertyTemplate = new IfcSimplePropertyTemplate(db, "IsExternal")
            {
                GlobalId = "3Yss80qXKHuO00025QrE$V", PrimaryMeasureType = "IfcBoolean"
            };
            IfcPropertySetTemplate psetTemplate = new IfcPropertySetTemplate("Pset_WallCommon", simplePropertyTemplate)
            {
                GlobalId = "2VWFE0qXKHuO00025QrE$V"
            };

            IfcPropertySingleValue psv  = new IfcPropertySingleValue(db, "IsExternal", new IfcBoolean(false));
            IfcPropertySet         pset = new IfcPropertySet("Pset_WallCommon", psv);

            new IfcRelDefinesByTemplate(pset, psetTemplate);

            new IfcRelAssociatesClassification(partionWalls, pset);

            DirectoryInfo di = Directory.GetParent(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location));

            di = Directory.GetParent(di.FullName);
            db.WriteFile(Path.Combine(di.FullName, "TestClassification.ifc"));
        }
Пример #6
0
        /// <summary>
        /// do not use obsolete
        /// </summary>
        /// <param name="location"></param>
        /// <param name="itemReference"></param>
        /// <param name="name"></param>
        BbMaterial(string location, string itemReference, string name)
        {
            IfcMaterial = new IfcMaterial
                            {
                                Name = name
                            };

            IfcMaterialClassificationRelationship
                = new IfcMaterialClassificationRelationship
                      {
                          MaterialClassifications = new List<IfcClassificationNotationSelect>(),
                          ClassifiedMaterial = IfcMaterial,
                      };

            IfcClassificationReference
                = new IfcClassificationReference
                      {
                          Location = location,
                          ItemReference = itemReference,
                          Name = name,
                      };

            var ns
                = new IfcClassificationNotationSelect
                         {
                             Value = IfcClassificationReference,
                         };

            IfcMaterialClassificationRelationship.MaterialClassifications.Add(ns);
            //var ifcMaterialLayer = new IfcMaterialLayer
            //    {
            //        Material = IfcMaterial,
            //        LayerThickness = new IfcPositiveLengthMeasure { Value = 0.0 },

            //    };

            //var ifcMaterialLayerSet = new IfcMaterialLayerSet
            //    {
            //        MaterialLayers = new List<IfcMaterialLayer>(),

            //    };
            //ifcMaterialLayerSet.MaterialLayers.Add(ifcMaterialLayer);
            //var ifcMaterialLayerSetUsage = new IfcMaterialLayerSetUsage
            //    {
            //        ForLayerSet = ifcMaterialLayerSet,
            //        LayerSetDirection = IfcLayerSetDirectionEnum.
            //    };
        }
Пример #7
0
        /// <summary>
        /// do not use obsolete
        /// </summary>
        /// <param name="location"></param>
        /// <param name="itemReference"></param>
        /// <param name="name"></param>
        BbMaterial(string location, string itemReference, string name)
        {
            IfcMaterial = new IfcMaterial
            {
                Name = name
            };

            IfcMaterialClassificationRelationship
                = new IfcMaterialClassificationRelationship
                {
                MaterialClassifications = new List <IfcClassificationNotationSelect>(),
                ClassifiedMaterial      = IfcMaterial,
                };

            IfcClassificationReference
                = new IfcClassificationReference
                {
                Location      = location,
                ItemReference = itemReference,
                Name          = name,
                };

            var ns
                = new IfcClassificationNotationSelect
                {
                Value = IfcClassificationReference,
                };

            IfcMaterialClassificationRelationship.MaterialClassifications.Add(ns);
            //var ifcMaterialLayer = new IfcMaterialLayer
            //    {
            //        Material = IfcMaterial,
            //        LayerThickness = new IfcPositiveLengthMeasure { Value = 0.0 },

            //    };

            //var ifcMaterialLayerSet = new IfcMaterialLayerSet
            //    {
            //        MaterialLayers = new List<IfcMaterialLayer>(),

            //    };
            //ifcMaterialLayerSet.MaterialLayers.Add(ifcMaterialLayer);
            //var ifcMaterialLayerSetUsage = new IfcMaterialLayerSetUsage
            //    {
            //        ForLayerSet = ifcMaterialLayerSet,
            //        LayerSetDirection = IfcLayerSetDirectionEnum.
            //    };
        }
        private Ifc4.IfcClassificationReference GetIfcClassificationReferenceFromIfcExternalReferenceRelationship()
        {
            Ifc4.Document document = this.Document;
            IfcClassificationReference ifcClassificationReference = (from ifcExternalReferenceRelationship in document.IfcXmlDocument.Items.OfType <Ifc4.IfcExternalReferenceRelationship>()
                                                                     where ifcExternalReferenceRelationship.RelatedResourceObjects != null &&
                                                                     ifcExternalReferenceRelationship.RelatedResourceObjects.Items.Exists(item => item.Ref == this.Id) &&
                                                                     ifcExternalReferenceRelationship.RelatingReference is IfcClassificationReference
                                                                     select ifcExternalReferenceRelationship.RelatingReference).FirstOrDefault() as IfcClassificationReference;

            if (ifcClassificationReference != null && ifcClassificationReference.IsRef)
            {
                ifcClassificationReference = this.Document.IfcXmlDocument.Items.OfType <IfcClassificationReference>().FirstOrDefault(item => item.Id == ifcClassificationReference.Ref);
            }

            return(ifcClassificationReference);
        }
        private static IfcClassificationReference GetClassificationReferencesForCode(Document document, string classification)
        {
            IfcClassificationReference _ref = null;

            var classrefs = document.IfcXmlDocument.Items.OfType <IfcClassificationReference>()
                            .Where(ele => ele.Identification == classification);

            List <IfcClassificationReference> grp = classrefs.ToList();

            if (grp != null && grp.Count > 0)
            {
                _ref = grp[0];
            }

            return(_ref);
        }
Пример #10
0
        private Ifc4.IfcClassificationReference GetIfcClassificationReferenceFromIfcRelAssociatesClassification()
        {
            Ifc4.Document document = this.Document;

            IfcClassificationReference ifcClassificationReference = (from ifcRelAssociatesClassification in document.IfcXmlDocument.Items.OfType <Ifc4.IfcRelAssociatesClassification>()
                                                                     where ifcRelAssociatesClassification.RelatedObjects != null &&
                                                                     ifcRelAssociatesClassification.RelatedObjects.Items.Exists(item => item.Ref == this.Id) &&
                                                                     ifcRelAssociatesClassification.RelatingClassification != null &&
                                                                     ifcRelAssociatesClassification.RelatingClassification.Item is IfcClassificationReference
                                                                     select ifcRelAssociatesClassification.RelatingClassification.Item).FirstOrDefault() as IfcClassificationReference;

            if (ifcClassificationReference != null && ifcClassificationReference.IsRef)
            {
                ifcClassificationReference = this.Document.IfcXmlDocument.Items.OfType <IfcClassificationReference>().FirstOrDefault(item => item.Id == ifcClassificationReference.Ref);
            }
            return(ifcClassificationReference);
        }
Пример #11
0
        /// <summary>
        /// Set Category to the property set
        /// </summary>
        /// <param name="ifcRoot">IfcRoot Object (IfcPropertySet)</param>
        /// <param name="category">string, category Name</param>
        private void SetCategory(IfcRoot ifcRoot, string category)
        {
            IfcRelAssociatesClassification ifcRelAssociatesClassification = Model.Instances.Where <IfcRelAssociatesClassification>(r => (r.RelatingClassification is IfcClassificationReference) && ((IfcClassificationReference)r.RelatingClassification).Name.ToString().ToLower() == category.ToLower()).FirstOrDefault();

            //create if none found
            if (ifcRelAssociatesClassification == null)
            {
                ifcRelAssociatesClassification = Model.Instances.New <IfcRelAssociatesClassification>();
                IfcClassificationReference ifcClassificationReference = Model.Instances.New <IfcClassificationReference>();
                ifcClassificationReference.Name = category;
                ifcRelAssociatesClassification.RelatingClassification = ifcClassificationReference;
            }
            //add this IfcRoot object if not already associated
            if (!ifcRelAssociatesClassification.RelatedObjects.Contains(ifcRoot))
            {
                ifcRelAssociatesClassification.RelatedObjects.Add(ifcRoot);
            }
        }
Пример #12
0
        private void UpdateIfcRelAssociatesClassification(string propertyName, IfcClassificationReference ifcClassificationReference)
        {
            if (ifcClassificationReference == null)
            {
                // delete
                DeleteIfcRelAssociatesClassification();
                return;
            }

            var existingIfcRelAssociatesClassificationCollection = GetIfcRelAssociatesClassificationCollection();

            if (existingIfcRelAssociatesClassificationCollection.Count() == 0)
            {
                // add
                IfcRelAssociatesClassification ifcRelAssociatesClassification = new IfcRelAssociatesClassification();
                ifcRelAssociatesClassification.RelatedObjects = new IfcRelAssociatesRelatedObjects();
                ifcRelAssociatesClassification.RelatedObjects.Items.Add(this.RefInstance());

                ifcRelAssociatesClassification.RelatingClassification      = new IfcRelAssociatesClassificationRelatingClassification();
                ifcRelAssociatesClassification.RelatingClassification.Item = new IfcClassificationReference()
                {
                    Ref = ifcClassificationReference.Id
                };
                this.Document.IfcXmlDocument.Items.Add(ifcRelAssociatesClassification);
                return;
            }

            foreach (var ifcRelAssociatesClassification in existingIfcRelAssociatesClassificationCollection)
            {
                // update
                ifcRelAssociatesClassification.RelatingClassification.Item = new IfcClassificationReference()
                {
                    Ref = ifcClassificationReference.Id
                };
            }
        }
Пример #13
0
        static void Main(string[] args)
        {
            DatabaseIfc db = new DatabaseIfc(ReleaseVersion.IFC4X3);

            IfcRailway sydneyLightRail = new IfcRailway(db);

            sydneyLightRail.Name       = "Sydney Light Rail";
            sydneyLightRail.ObjectType = "Light Rail Complexes";

            IfcProject project = new IfcProject(sydneyLightRail, "", IfcUnitAssignment.Length.Metre);

            IfcClassification          uniclass2015       = new IfcClassification(db, "Uniclass2015");
            IfcClassificationReference lightRailComplexes = new IfcClassificationReference(uniclass2015);

            lightRailComplexes.Identification = "Co_80_50_45";
            lightRailComplexes.Name           = "Light Rail Complexes";

            lightRailComplexes.Associate(sydneyLightRail);

            IfcFacilityPartTypeSelect facilityPartTypeSelect = new IfcFacilityPartTypeSelect(IfcRailwayPartTypeEnum.USERDEFINED);
            IfcFacilityPart           cbdCorridor            = new IfcFacilityPart(sydneyLightRail, "CBD and SE Light Rail", facilityPartTypeSelect, IfcFacilityUsageEnum.LONGITUDINAL);

            new IfcClassificationReference(uniclass2015)
            {
                Identification = "En_80_50_71", Name = "Railway Corridors"
            }.Associate(cbdCorridor);

            IfcSpace deStop = new IfcSpace(cbdCorridor, "DE Stop");

            deStop.PredefinedType = IfcSpaceTypeEnum.USERDEFINED;
            deStop.ObjectType     = "Light Rail Stops";

            new IfcClassificationReference(uniclass2015)
            {
                Identification = "SL_80_50_47", Name = "Light Rail Stops"
            }.Associate(deStop);

            IfcSpace platform1_2 = new IfcSpace(deStop, "Platform 1/2");

            IfcClassificationReference classificationTicketSystem = new IfcClassificationReference(uniclass2015)
            {
                Identification = "Ss_75_90_80", Name = "Ticketing Systems"
            };
            IfcSystem opal = new IfcSystem(sydneyLightRail, "Opal system");

            classificationTicketSystem.Associate(opal);

            IfcDistributionSystem platform1_2TicketSystem = new IfcDistributionSystem(platform1_2, "DE Stop Platform 1/2 Ticket System", IfcDistributionSystemEnum.USERDEFINED);

            opal.AddAggregated(platform1_2TicketSystem);
            classificationTicketSystem.Associate(platform1_2TicketSystem);

            IfcCommunicationsApplianceType opalTicketMachineType = new IfcCommunicationsApplianceType(db, "Opal Ticket Machine", IfcCommunicationsApplianceTypeEnum.USERDEFINED);

            new IfcClassificationReference(uniclass2015)
            {
                Identification = "Pr_75_75_27_80", Name = "Smart card readers and writers"
            }.Associate(opalTicketMachineType);
            project.AddDeclared(opalTicketMachineType);

            IfcLocalPlacement          ticketMachineLocalPlacement = null;
            IfcProductDefinitionShape  ticketMachineShape          = null;
            IfcCommunicationsAppliance ticketMachine = new IfcCommunicationsAppliance(platform1_2, ticketMachineLocalPlacement, ticketMachineShape, platform1_2TicketSystem);

            IfcPropertySingleValue dateCommissioned = new IfcPropertySingleValue(db, "Date Commissioned", new IfcDate(DateTime.Now));

            new IfcPropertySet("TfNSW_Asset", dateCommissioned);

            System.Windows.Forms.SaveFileDialog saveFileDialog = new System.Windows.Forms.SaveFileDialog();
            saveFileDialog.Filter = "IFC BIM Data (*.ifc,*.ifcxml,*.ifcjson,*.ifczip)|*.ifc;*.ifcxml;*.ifcjson;*.ifczip";;
            if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                db.WriteFile(saveFileDialog.FileName);
            }
        }
 private IEnumerable <IfcExternalReferenceRelationship> GetIfcExternalReferenceRelationshipCollection(IfcClassificationReference ifcClassificationReference)
 {
     Ifc4.Document document = this.Document;
     return(from ifcExternalReferenceRelationship in document.IfcXmlDocument.Items.OfType <Ifc4.IfcExternalReferenceRelationship>()
            where ifcExternalReferenceRelationship.RelatingReference != null &&
            ifcExternalReferenceRelationship.RelatingReference.Ref == ifcClassificationReference.Id
            select ifcExternalReferenceRelationship);
 }
Пример #15
0
        public string CreateCcFileFromVDI3805(VDI3805.VDI3805 vdi3805)
        {
            EventHandler handler = eventHandler;

            string   tempModelFilename = InitializeCcFile("CAFM-ConnectFacilitiesViewTemplateVdi3805.ifcxml");
            Document doc = null;

            if (!Current.Documents.ContainsKey(tempModelFilename))
            {
                doc = Ifc4.Workspace.CurrentWorkspace.OpenDocument(tempModelFilename);
                doc.IfcXmlDocument.Header.Author            = vdi3805.ManufacturerName;
                doc.IfcXmlDocument.Header.Organization      = vdi3805.ManufacturerText;
                doc.IfcXmlDocument.Header.OriginatingSystem = vdi3805.Filename;
                doc.IfcXmlDocument.Header.Authorization     = vdi3805.ManufacturerUrl;
                Current.Documents.Add(tempModelFilename, doc);

                string catalogueName = "CAFMConnectCatalogueOfObjectTypes";
                if (m_TempAllIfcClassificationReferenceCollection == null)
                {
                    m_TempAllIfcClassificationReferenceCollection = GetIfcClassificationReferenceCollectionFromCatalogue(tempModelFilename, catalogueName);
                }

                m_filteredIfcClassificationReference = m_TempAllIfcClassificationReferenceCollection.FirstOrDefault(item => item.Identification == vdi3805.GetCclassification());
            }
            string siteGuid = AddNewSite(tempModelFilename, vdi3805.ManufacturerName, vdi3805.ManufacturerName, vdi3805.ManufacturerName2, vdi3805.ManufacturerText, vdi3805.LeadData_010.IssueMonth, vdi3805.CountryCode);
            string code     = vdi3805.GetCclassification();

            foreach (ProductMainGroup1_100 pmg100 in vdi3805.LeadData_010.ProductMainGroup1_100s)
            {
                LastAction = pmg100.ProductDesignation;
                handler?.Invoke(this, EventArgs.Empty);

                foreach (ProductMainGroup2_110 pmg110 in pmg100.ProductMainGroup2_110s)
                {
                    LastAction = pmg110.ProductDesignation;
                    handler?.Invoke(this, EventArgs.Empty);

                    foreach (ProductElementData_700 ped700 in pmg110.ProductElementData_700s)
                    {
                        CafmConnect.Manufacturer.CcManufacturerProduct product = new CcManufacturerProduct(code);

                        switch (vdi3805.VDI3805PartNumber)
                        {
                        case "PART02":
                            break;

                        case "PART03":
                            product.Description = ped700.HeatGenerator.ProductName;
                            product.Name        = ped700.HeatGenerator.ProductRange;
                            product.Attributes.Add(new CcManufacturerProductDetail("Beschreibung", "Beschreibung", pmg100.ProductDesignation));

                            FieldInfo[] fields = ped700.HeatGenerator.GetType().GetFields();
                            foreach (var field in fields)
                            {
                                string value;
                                if (field.GetValue(ped700.HeatGenerator) != null)
                                {
                                    value = field.GetValue(ped700.HeatGenerator).ToString();
                                }
                                else
                                {
                                    value = string.Empty;
                                }
                                product.Attributes.Add(new CcManufacturerProductDetail(field.Name, field.Name, value));
                            }

                            LastAction = ped700.HeatGenerator.ProductName;
                            handler?.Invoke(this, EventArgs.Empty);

                            break;

                        case "PART04":
                            break;

                        case "PART05":
                            break;

                        case "PART06":
                            break;

                        case "PART07":
                            break;

                        case "PART08":
                            break;

                        case "PART09":
                            break;
                        }


                        //product.Attributes.Add(new CcManufacturerProductDetail("Beschreibung", "Beschreibung", pmg.ProductMainGroup2_110s.FirstOrDefault().ProductElementData_700s.FirstOrDefault().HeatGenerators.FirstOrDefault().ProductName.ToString()));
                        //product.Attributes.Add(new CcManufacturerProductDetail("Anzahl Haltestellen", "Anzahl Haltestellen", "10"));
                        //product.Attributes.Add(new CcManufacturerProductDetail("Tragkraft in Personen", "Tragkraft in Personen", "5"));
                        //product.Attributes.Add(new CcManufacturerProductDetail("Tragkraft", "Tragkraft", (i * 2).ToString()));

                        if (siteGuid != null)
                        {
                            AddNewProduct(tempModelFilename, siteGuid, code, product, pmg100.ProductDesignation);
                        }
                    }
                }
            }

            return(tempModelFilename);
        }
Пример #16
0
        /// <summary>
        /// Get the category from the IfcRelAssociatesClassification / IfcClassificationReference objects
        /// </summary>
        /// <param name="obj">IfcObjectDefinition object</param>
        /// <returns></returns>
        public string GetCategoryClassification(IfcObjectDefinition obj)
        {
            //Try by relationship first
            var ifcRAC = obj.HasAssociations.OfType <IfcRelAssociatesClassification>().FirstOrDefault();
            IfcClassificationReference ifcCR = null;

            if (ifcRAC != null)
            {
                ifcCR = ifcRAC.RelatingClassification as IfcClassificationReference;
            }

            if (ifcCR != null)
            {
                var conCatChar = " : ";
                if ((Context.TemplateFileName != null) && (Context.TemplateFileName.Contains("COBie-US"))) //change for US format
                {
                    conCatChar = ": ";
                }
                //holders for first and last part of category
                string itemReference = ifcCR.ItemReference;
                if (!string.IsNullOrEmpty(itemReference))
                {
                    itemReference = itemReference.Trim();
                }

                string name = ifcCR.Name;
                if (!string.IsNullOrEmpty(name))
                {
                    name = name.Trim();
                }

                //need to use split as sometime the whole category is stored in both ItemReference and Name
                //We split here as sometimes the whole category(13-15 11 34 11: Office) is place in itemReference and Name
                if ((!string.IsNullOrEmpty(name)) &&
                    (!string.IsNullOrEmpty(itemReference))
                    )
                {
                    itemReference = itemReference.Split(':').First().Trim();
                    var nameSplit = name.Split(':');
                    //just in case we have more than one ":"in name
                    if (nameSplit.First().Trim().Equals(itemReference, StringComparison.OrdinalIgnoreCase))
                    {
                        for (var i = 0; i < nameSplit.Count(); i++)
                        {
                            //skip first item
                            if (i == 1)
                            {
                                name = nameSplit[i].Trim();
                            }
                            if (i > 1)
                            {
                                name += conCatChar + nameSplit[i].Trim();        //add back the second, third... ": "
                            }
                        }
                    }
                    else
                    {
                        name = nameSplit.Last().Trim();
                    }
                }

                //Return the Category
                if ((!string.IsNullOrEmpty(itemReference)) &&
                    (!string.IsNullOrEmpty(name)) &&
                    (!itemReference.Equals(name, StringComparison.OrdinalIgnoreCase))
                    )
                {
                    return(itemReference + conCatChar + name);
                }
                else if (!string.IsNullOrEmpty(itemReference))
                {
                    return(itemReference);
                }
                else if (!string.IsNullOrEmpty(name))
                {
                    return(name);
                }
                else if (!string.IsNullOrEmpty(ifcCR.Location))
                {
                    return(ifcCR.Location);
                }
                else if ((ifcCR.ReferencedSource != null) &&
                         (!string.IsNullOrEmpty(ifcCR.ReferencedSource.Name))
                         )
                {
                    return(ifcCR.ReferencedSource.Name);
                }
            }
            return(null);
        }
        private static IfcRelAssociatesClassification GetRelAssocClassification(Document document, IfcClassificationReference classref)
        {
            IfcRelAssociatesClassification _rel = null;
            var relassoc = document.IfcXmlDocument.Items.OfType <IfcRelAssociatesClassification>()
                           .Where(ele => ele.RelatingClassification.Item.Ref == classref.Id);

            List <IfcRelAssociatesClassification> grp = relassoc.ToList();

            if (grp != null && grp.Count > 0)
            {
                _rel = grp[0];
            }
            return(_rel);
        }
Пример #18
0
        static void Main(string[] args)
        {
            //Sample Data https://www.tmr.qld.gov.au/-/media/busind/techstdpubs/Geotechnical/Geotech-Borehole-Logging/Geotechnical-Borehole-Logging.pdf?la=en
            //http://creativecommons.org/licenses/by/3.0/au/
            // © State of Queensland(Department of Transport and Main Roads) 2016

            // Suggested enhancements to test :
            //		Nominate Status and Reference Number
            //		Add Geolocation
            //		Use linear placement for statum layers
            //		Capture Auger, Casing, Wash Boring and Core drilling extents
            //		Add stratum data Impact Strength, Defect Spacing, Additional Data and Test Results, Sample Tests

            DatabaseIfc db = new DatabaseIfc(ReleaseVersion.IFC4X3);

            db.Factory.Options.AngleUnitsInRadians = false;

            IfcSite    site    = new IfcSite(db, "Coombabah Creek Abutment");
            IfcProject project = new IfcProject(site, "FG6280", IfcUnitAssignment.Length.Metre)
            {
                LongName = "Gold Coast Light Rail(GCLR) Stage 2"
            };

            project.Description = "http://creativecommons.org/licenses/by/3.0/au/ © State of Queensland(Department of Transport and Main Roads) 2016";

            IfcAxis2Placement3D placement         = new IfcAxis2Placement3D(new IfcCartesianPoint(db, 0, 0, 0.99));
            IfcLocalPlacement   boreHolePlacement = new IfcLocalPlacement(site.ObjectPlacement, placement);
            IfcBorehole         borehole          = new IfcBorehole(site, boreHolePlacement, null);

            borehole.Name        = "BH-CC-01";
            borehole.Description = "Sample borehole data published at  https://www.tmr.qld.gov.au/-/media/busind/techstdpubs/Geotechnical/Geotech-Borehole-Logging/Geotechnical-Borehole-Logging.pdf?la=en";

            Pset_BoreholeCommon pset_BoreholeCommon = new Pset_BoreholeCommon(borehole);

            pset_BoreholeCommon.GroundwaterDepth = -5;             //Not identified in borehole log
            //new Pset_Uncertainty(borehole) { Basis = PEnum_UncertaintyBasis.MEASUREMENT };
            Pset_GeotechnicalAssemblyCommon psetGeotechnicalAssemblyCommon = new Pset_GeotechnicalAssemblyCommon(borehole);

            psetGeotechnicalAssemblyCommon.Purpose = PEnum_StrataAssemblyPurpose.GEOLOGICAL;

            //Should some of these properties be standard?
            //Should actors such as drilling company be IfcActor etc

            List <IfcProperty> tmrBoreholeProperties = new List <IfcProperty>();

            tmrBoreholeProperties.Add(new IfcPropertySingleValue(db, "Driller", new IfcIdentifier("North Coast Drilling")));
            tmrBoreholeProperties.Add(new IfcPropertySingleValue(db, "LoggedBy", new IfcIdentifier("D.Colborne/J.Armstrong")));
            tmrBoreholeProperties.Add(new IfcPropertySingleValue(db, "ReviewedBy", new IfcIdentifier("S.Foley")));
            tmrBoreholeProperties.Add(new IfcPropertySingleValue(db, "Plunge", new IfcPlaneAngleMeasure(90)));
            tmrBoreholeProperties.Add(new IfcPropertySingleValue(db, "Date Started", new IfcDate(new DateTime(2015, 09, 10))));
            tmrBoreholeProperties.Add(new IfcPropertySingleValue(db, "Date Completed", new IfcDate(new DateTime(2015, 09, 11))));
            tmrBoreholeProperties.Add(new IfcPropertySingleValue(db, "Reference No", new IfcIdentifier("H12327")));
            tmrBoreholeProperties.Add(new IfcPropertySingleValue(db, "Job No", new IfcIdentifier("498/04375")));
            new IfcPropertySet(borehole, "TMR_Borehole", tmrBoreholeProperties);

            IfcCircleProfileDef boreProfile = new IfcCircleProfileDef(db, "BoreHole", 0.05);

            IfcMaterial siltyClayTopsoil = new IfcMaterial(db, "Silty Clay (TopSoil)");

            siltyClayTopsoil.Description = "Dark grey, moist.";

            placement = new IfcAxis2Placement3D(new IfcCartesianPoint(db, 0, 0, -0.1));
            IfcLocalPlacement         localPlacement    = new IfcLocalPlacement(boreHolePlacement, placement);
            IfcExtrudedAreaSolid      extrudedAreaSolid = new IfcExtrudedAreaSolid(boreProfile, 0.1);
            IfcProductDefinitionShape shape             = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid));

            //gg Toolkit uses nesting rather than aggregating for stratums
            IfcSolidStratum solidStratum = new IfcSolidStratum(borehole, localPlacement, shape);

            solidStratum.SetMaterial(siltyClayTopsoil);

            IfcClassification soilClassification = new IfcClassification(db, "Soil Descriptions");

            soilClassification.Description = "Description and Classification of Soils for Geotechnical Purposes: Refer to AS1726 - 1993(Appendix A).";

            IfcMaterial siltyClayEstuarine = new IfcMaterial(db, "Silty CLAY (Estuarine)");

            siltyClayEstuarine.Description = "Dark grey, moist, soft.";
            placement         = new IfcAxis2Placement3D(new IfcCartesianPoint(db, 0, 0, -1.2));
            localPlacement    = new IfcLocalPlacement(boreHolePlacement, placement);
            extrudedAreaSolid = new IfcExtrudedAreaSolid(boreProfile, 1.1);
            shape             = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid));
            solidStratum      = new IfcSolidStratum(borehole, localPlacement, shape);
            solidStratum.SetMaterial(siltyClayEstuarine);
            IfcClassificationReference soilClassificationCI = new IfcClassificationReference(soilClassification)
            {
                Identification = "CI",
                Description    = "Inorganic clays of low to medium plasticity, gravelly clays, sandy clays, silty clays, lean clays"
            };

            soilClassificationCI.Associate(solidStratum);
#warning Should soil classification be assigned to soil or to stratum?

            IfcMaterial clayeySANDEstuarine = new IfcMaterial(db, "Clayey SAND (Estuarine)");
            clayeySANDEstuarine.Description = "Dark grey, wet, very loose.";
            placement         = new IfcAxis2Placement3D(new IfcCartesianPoint(db, 0, 0, -6.4));
            localPlacement    = new IfcLocalPlacement(boreHolePlacement, placement);
            extrudedAreaSolid = new IfcExtrudedAreaSolid(boreProfile, 5.2);
            shape             = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid));
            solidStratum      = new IfcSolidStratum(borehole, localPlacement, shape);
            solidStratum.SetMaterial(clayeySANDEstuarine);
            solidStratum.Description = "Fine to medium grained. Shell fragments throughout.";

            IfcClassificationReference soilClassificationSC = new IfcClassificationReference(soilClassification)
            {
                Identification = "SC",
                Description    = "Clayey sands, sandclay mixtures"
            };
            soilClassificationSC.Associate(solidStratum);

            IfcMaterial METAGREYWACKEdcf = new IfcMaterial(db, "METAGREYWACKE (DCf)");

            placement         = new IfcAxis2Placement3D(new IfcCartesianPoint(db, 0, 0, -6.8));
            localPlacement    = new IfcLocalPlacement(boreHolePlacement, placement);
            extrudedAreaSolid = new IfcExtrudedAreaSolid(boreProfile, 0.4);
            shape             = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid));
            solidStratum      = new IfcSolidStratum(borehole, localPlacement, shape);
            solidStratum.SetMaterial(METAGREYWACKEdcf);
            solidStratum.Description = "XW: Recovered as orange brown to grey, moist, very stiff, Silty CLAY.";

            IfcClassification rockClassification = new IfcClassification(db, "Rock Descriptions");
            rockClassification.Description = "Refer to AS1726-1993 (Appendix A3.3) for the description and classification of rock material composition";


            IfcClassificationReference rockClassificationXW = new IfcClassificationReference(rockClassification)
            {
                Identification = "XW",
                Description    = "Rock is weathered to such an extent that it has 'soil' properties, i.e. it either disintegrates or can be remoulded in water, but substance fabric and rock structure still recognisable."
            };
            rockClassificationXW.Associate(solidStratum);

            placement         = new IfcAxis2Placement3D(new IfcCartesianPoint(db, 0, 0, -12.7));
            localPlacement    = new IfcLocalPlacement(boreHolePlacement, placement);
            extrudedAreaSolid = new IfcExtrudedAreaSolid(boreProfile, 5.9);
            shape             = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid));
            solidStratum      = new IfcSolidStratum(borehole, localPlacement, shape);
            solidStratum.SetMaterial(METAGREYWACKEdcf);
            solidStratum.Description = "SW: Dark grey, fine to medium grained, indistinctly foliated, high to very high strength.";
            IfcClassificationReference rockClassificationSW = new IfcClassificationReference(rockClassification)
            {
                Identification = "SW",
                Description    = "Rock is slightly discoloured but shows little or no change of strength from fresh rock."
            };
            rockClassificationSW.Associate(solidStratum);


            System.Windows.Forms.SaveFileDialog saveFileDialog = new System.Windows.Forms.SaveFileDialog();
            saveFileDialog.Filter = "IFC BIM Data (*.ifc,*.ifcxml,*.ifcjson,*.ifczip)|*.ifc;*.ifcxml;*.ifcjson;*.ifczip";;
            if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                db.WriteFile(saveFileDialog.FileName);
            }
        }