Beispiel #1
0
        internal bool isClassified(string classificationId, string classificationName, IfcObjectDefinition obj)
        {
            List <IfcRelAssociatesClassification> references = obj.HasAssociations.OfType <IfcRelAssociatesClassification>().ToList();

            if (obj is IfcObject ifcObject)
            {
                IfcTypeObject typeObject = ifcObject.RelatingType();
                if (typeObject != null)
                {
                    references.AddRange(typeObject.HasAssociations.OfType <IfcRelAssociatesClassification>());
                }
            }

            foreach (IfcClassificationReference classificationReference in references.Select(x => x.RelatingClassification).OfType <IfcClassificationReference>())
            {
                if (string.Compare(classificationId, classificationReference.Identification, true) == 0)
                {
                    if (string.IsNullOrEmpty(classificationName))
                    {
                        return(true);
                    }
                    IfcClassification classification = classificationReference.ReferencedClassification();
                    if (classification != null && string.Compare(classification.Name, classificationName, true) == 0)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
        public ExchangeRequirements_TfNSW_Drainage(List <IfcPropertySetTemplate> propertyTemplates) : base()
        {
            PropertyTemplates.AddRange(propertyTemplates);

            IfcClassification classification = new IfcClassification(new DatabaseIfc(ModelView.Ifc4NotAssigned), "Uniclass2015");

            //Indicitive/candidate sender, receiver, activity, process...
            ApplicableProcess.Add(new IfcClassificationReference(classification)
            {
                Identification = "PM_40_30", Name = "Design information"
            });
            Senders.Add(new IfcClassificationReference(classification)
            {
                Identification = "Ro_50_20_28", Name = "Drainage engineer (D)"
            });
            Receivers.Add(new IfcClassificationReference(classification)
            {
                Identification = "Ro_10_30", Name = "Asset management roles"
            });
            Activities.Add(new IfcClassificationReference(classification)
            {
                Identification = "Ac_05_40", Name = "Design stage activities"
            });
            Activities.Add(new IfcClassificationReference(classification)
            {
                Identification = "Ac_05_60", Name = "Handover and close-out stage activities"
            });

            //Exchange Requirements
            Concepts.Add(new Concept_TfNSW_AllDistributionElements());             // No building element proxies, all elements distribution element
            Concepts.Add(new Concept_TfNSW_StormWaterPipeSingleSweep());           // Future might force pipe axis definition with attributes
            // Validate all Systems are drainage
            // Validate Distribution System is assigned to all elements
            // To be advanced further
        }
Beispiel #3
0
        private void GetClassificationDictionary(string classificationSystemName = null)
        {
            if (string.IsNullOrWhiteSpace(classificationSystemName))
            {
                _classificationSystem = null;
            }
            else
            {
                _classificationSystem =
                    Model.Instances.OfType <IfcClassification>(true).FirstOrDefault(rel => rel.Name == classificationSystemName);
            }

            //get the relationships
            var associations =
                Model.Instances.OfType <IfcRelAssociatesClassification>()
                .Where <IfcRelAssociatesClassification>(rel => rel.RelatingClassification is IfcClassificationReference);

            //filter them for our chosen classification system
            associations =
                associations.Where(
                    assoc =>
                    ((IfcClassificationReference)assoc.RelatingClassification).ReferencedSource ==
                    _classificationSystem);
            _classifiedObjects = new Dictionary <IfcRoot, IfcClassificationReference>();
            //create a dictionary of classified objects
            foreach (var ifcRelAssociatesClassification in associations)
            {
                foreach (var relatedObject in ifcRelAssociatesClassification.RelatedObjects)
                {
                    _classifiedObjects.Add(relatedObject,
                                           ((IfcClassificationReference)ifcRelAssociatesClassification.RelatingClassification));
                }
            }
        }
        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"));
        }
Beispiel #5
0
        private void ParseCSV(string data, CsvLineParser parser, IfcClassification source)
        {
            TextReader csvReader = new StringReader(data);

            //header line
            string        line       = csvReader.ReadLine();
            CsvLineParser lineParser = parser;

            lineParser.ParseHeader(line);

            //get first line of data
            line = csvReader.ReadLine();

            while (line != null)
            {
                //parse line
                Line parsedLine = lineParser.ParseLine(line);

                //create IFC object
                IfcSystem system         = GetOrCreateSystem(parsedLine.Code, parsedLine.Description);
                var       classification = GetOrCreateClassificationReference(parsedLine.Code, parsedLine.Description, source);

                //set up hierarchy
                if (system == null)
                {
                    continue;
                }
                IfcSystem parentSystem = GetOrCreateSystem(parsedLine.ParentCode);
                if (parentSystem != null)
                {
                    parentSystem.AddObjectToGroup(system);
                }

                //read new line to be processed in the next step
                line = csvReader.ReadLine();
            }
        }
Beispiel #6
0
        public static IEnumerable <IfcClassificationItemRelationship> GetHierarchy(this IfcClassification cls)
        {
            IModel model = cls.Model;
            IEnumerable <IfcClassificationItemRelationship> itemRels =
                model.Instances.Where <IfcClassificationItemRelationship>(r => r.RelatingItem.ItemOf == cls);
            Dictionary <IfcClassificationItem, IfcClassificationItemRelationship> roots =
                new Dictionary <IfcClassificationItem, IfcClassificationItemRelationship>(); //top level items

            foreach (IfcClassificationItemRelationship itemRel in itemRels)
            {
                roots.Add(itemRel.RelatingItem, itemRel); // so add it as a potential parent
            }
            foreach (IfcClassificationItemRelationship itemRel in itemRels)
            {
                foreach (IfcClassificationItem child in itemRel.RelatedItems)
                {
                    if (roots.ContainsKey(child))
                    {
                        roots.Remove(child); //cannot be a child and a root
                    }
                }
            }
            return(roots.Values);
        }
        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);
            }
        }
        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);
            }
        }
Beispiel #9
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);
        }