Esempio n. 1
0
 protected BbSite(BbProject project, IfcSite site, IfcRelAggregates ifcRelAggregates)
 {
     BbProject = project;
     IfcSpatialStructureElement = site;
     IfcRelAggregates           = ifcRelAggregates;
     Guid = IfcGloballyUniqueId.ConvertToGuid(site.GlobalId);
 }
Esempio n. 2
0
        /// <summary>
        /// Create and setup IfcSite object
        /// </summary>
        /// <param name="row">COBieFacilityRow object to read data from</param>
        /// <returns>IfcSite object</returns>
        private void CreateSite(COBieFacilityRow row)
        {
            IfcSite ifcSite = Model.Instances.New <IfcSite>();

            //set owner history
            SetNewOwnerHistory(ifcSite, row.ExternalSystem, Model.DefaultOwningUser, row.CreatedOn);
            //using statement will set the Model.OwnerHistoryAddObject to ifcSite.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, ifcSite.OwnerHistory))
            {
                AddGlobalId(row.ExternalSiteIdentifier, ifcSite);
                if (ValidateString(row.SiteName))
                {
                    ifcSite.Name = row.SiteName;
                }
                ifcSite.CompositionType = IfcElementCompositionEnum.ELEMENT;
                IfcLocalPlacement lp = Model.Instances.New <IfcLocalPlacement>();
                lp.RelativePlacement    = WCS;
                ifcSite.ObjectPlacement = lp;

                if (ValidateString(row.SiteDescription))
                {
                    ifcSite.Description = row.SiteDescription;
                }
            }
        }
Esempio n. 3
0
 protected BbSite(BbProject project, IfcSite site, IfcRelAggregates ifcRelAggregates)
 {
     BbProject = project;
     IfcSpatialStructureElement = site;
     IfcRelAggregates = ifcRelAggregates;
     Guid = IfcGloballyUniqueId.ConvertToGuid(site.GlobalId);
 }
Esempio n. 4
0
        public void CreateProductIfc(ProductIfcRequest request,
                                     Stream outputStream)
        {
            IfcPerson person = IfcInit.CreatePerson(request.owner.person.givenName,
                                                    request.owner.person.familyName,
                                                    request.owner.person.identifier);
            IfcOrganization organization =
                IfcInit.CreateOrganization(request.owner.organization.name,
                                           request.owner.organization.description,
                                           request.owner.organization.identifier);
            IfcOrganization applicationOrganization =
                IfcInit.CreateOrganization(request.owner.application.organization.name,
                                           request.owner.application.organization.description,
                                           request.owner.application.organization.identifier);
            IfcApplication application =
                IfcInit.CreateApplication(applicationOrganization,
                                          request.owner.application.version,
                                          request.owner.application.name,
                                          request.owner.application.identifier);
            IfcOwnerHistory ownerHistory =
                IfcInit.CreateOwnerHistory(person, organization, application);

            IfcProject project = IfcInit.CreateProject(request.project.name,
                                                       request.project.description,
                                                       ownerHistory);
            IfcSite site = IfcInit.CreateSite(null, null, ownerHistory);

            project.Aggregate(site, ownerHistory);
            IfcBuilding building =
                IfcInit.CreateBuilding(null, null, ownerHistory, site.ObjectPlacement);

            site.Aggregate(building, ownerHistory);
            IfcBuildingStorey storey =
                IfcInit.CreateBuildingStorey(null, null, ownerHistory, building.ObjectPlacement);

            building.Aggregate(storey, ownerHistory);
            IfcProduct product;

            switch (request.product.type)
            {
            default:
                product = IfcInit.CreateProxy(request.product.name,
                                              request.product.description,
                                              ownerHistory,
                                              storey.ObjectPlacement,
                                              null);
                break;
            }
            List <IfcRepresentationContext> contextList =
                new List <IfcRepresentationContext> (project.RepresentationContexts);

            product.Representation =
                CreateProductRepresentation(contextList, request.product.representations);
            storey.Contains(product, ownerHistory);
            project.SerializeToStep(outputStream, request.schema.ToString(), null);
            return;
        }
Esempio n. 5
0
 public SiteType(IfcSite ifcSite, CoBieLiteHelper helper)
     : this()
 {
     //  _ifcSite = ifcSite;
     externalEntityName = helper.ExternalEntityName(ifcSite);
     externalID         = helper.ExternalEntityIdentity(ifcSite);
     externalSystemName = helper.ExternalSystemName(ifcSite);
     SiteName           = ifcSite.LongName;
     SiteDescription    = ifcSite.Description;
 }
Esempio n. 6
0
 public static IfcShapeRepresentation GetFootPrintRepresentation(this IfcSite site)
 {
     if (site.Representation != null)
     {
         return
             (site.Representation.Representations.OfType <IfcShapeRepresentation>().FirstOrDefault(
                  r => string.Compare(r.RepresentationIdentifier.GetValueOrDefault(), "FootPrint", true) == 0));
     }
     return(null);
 }
Esempio n. 7
0
        protected override Site Mapping(IfcSite ifcSite, Site site)
        {
            var helper = ((IfcToCOBieLiteUkExchanger)Exchanger).Helper;

            site.ExternalEntity = helper.ExternalEntityName(ifcSite);
            site.ExternalId     = helper.ExternalEntityIdentity(ifcSite);
            site.Name           = ifcSite.LongName;
            site.Description    = ifcSite.Description;
            return(site);
        }
Esempio n. 8
0
        public IfcBuilding AddBuilding(IfcSite site, string name = "", string description = "")
        {
            var b = new IfcBuilding(IfcGuid.IfcGuid.ToIfcGuid(Guid.NewGuid()));

            b.Name        = name;
            b.Description = description;
            storage.AddInstance(b);
            CreateAggregationRelationship(site, b);
            return(b);
        }
Esempio n. 9
0
        public IfcSite AddSite(IfcProject project, string name = "", string description = "")
        {
            var s = new IfcSite(IfcGuid.IfcGuid.ToIfcGuid(Guid.NewGuid()));

            s.Name        = name;
            s.Description = description;
            storage.AddInstance(s);
            CreateAggregationRelationship(project, s);
            return(s);
        }
Esempio n. 10
0
        public void ExtrudeAndRevolveTest()
        {
            //Set up project hierarchy
            IfcProject project = IfcInit.CreateProject(null, null, null);
            IfcSite    site    = IfcInit.CreateSite(null, null, null);

            project.Aggregate(site, null);
            IfcBuilding building = IfcInit.CreateBuilding(null, null, null, null);

            site.Aggregate(building, null);
            IfcBuildingStorey storey = IfcInit.CreateBuildingStorey(null, null, null, null);

            building.Aggregate(storey, null);

            //Create shape representation
            // -- extruded profile shape
            IfcPolyline outerCurve = IfcGeom.CreatePolyLine(new List <double[]>()
            {
                new double[] { -0.5, -0.5 },
                new double[] { -0.5, 0.5 },
                new double[] { 0.5, 0.5 },
                new double[] { 0.5, -0.5 },
                new double[] { -0.5, -0.5 }
            });
            IfcProfileDef profileDef = new IfcArbitraryClosedProfileDef(IfcProfileTypeEnum.AREA,
                                                                        null,
                                                                        outerCurve);
            IfcRepresentationItem extrudedRepresentation = profileDef.Extrude(1).Rotate(new double[] { 45, 0, 45 }).Translate(new double[] { -2, 0, 0 });

            // -- revolved profile shape
            IfcRepresentationItem revolvedRepresentation = profileDef.Revolve(-45,
                                                                              new IfcAxis1Placement(new IfcCartesianPoint(1, 0, 0),
                                                                                                    new IfcDirection(0, 1, 0)),
                                                                              null);

            //Create product with representation and place in storey
            var contextEnum = project.RepresentationContexts.GetEnumerator();

            contextEnum.MoveNext();
            IfcShapeRepresentation shapeRepresentation =
                new IfcShapeRepresentation(contextEnum.Current,
                                           new IfcLabel("extruded square"),
                                           new IfcLabel("SweptSolid"),
                                           new IfcRepresentationItem[] { extrudedRepresentation, revolvedRepresentation });
            IfcProxy product = IfcInit.CreateProxy(null, null, null, storey.ObjectPlacement, null);

            product.Representation = new IfcProductDefinitionShape(null, null, new IfcRepresentation[] { shapeRepresentation });;
            storey.Contains(product, null);

            //Write to IFC file
            using (FileStream fs = File.Create("./swept_geom_test.ifc"))
            {
                project.SerializeToStep(fs, "IFC2X3", null);
            }
        }
        private void ExtractBuilding(IfcSite site, int siteId)
        {
            foreach (IfcBuilding building in site.Buildings)
            {
                var dbbuilding = _mapper.Map <Building>(building);
                dbbuilding.SiteId = siteId;

                var buildingId = _buildingRepository.Create(dbbuilding);
                ExtractFloor(building, buildingId);
            }
        }
Esempio n. 12
0
        /// <summary>
        /// Returns all buildings at the highest level of spatial structural decomposition (i.e. root buildings for this site)
        /// </summary>
        public static IEnumerable <IfcBuilding> GetBuildings(this IfcSite site)
        {
            IEnumerable <IfcRelAggregates> aggregate = site.IsDecomposedBy.OfType <IfcRelAggregates>();

            foreach (IfcRelAggregates rel in aggregate)
            {
                foreach (IfcBuilding building in rel.RelatedObjects.OfType <IfcBuilding>())
                {
                    yield return(building);
                }
            }
        }
Esempio n. 13
0
        static void Main(string[] args)
        {
            var dbInitial = new DatabaseIfc(ModelView.Ifc4NotAssigned);

            dbInitial.Factory.Options.GenerateOwnerHistory = false;

            var site = new IfcSite(dbInitial, "site")
            {
                Guid = new Guid("aa4019f8-2584-44a1-a132-c17dfff69c41")
            };
            var project = new IfcProject(dbInitial, "GeomRep")
            {
                Guid = new Guid("94d4ddac-9120-4fb9-bea0-7a414ee725d4")
            };

            new IfcRelAggregates(project, new List <IfcObjectDefinition>()
            {
                site
            })
            {
                Guid = new Guid("5e1fd0e5-b005-fe11-501e-5caff01dc1ad")
            };

            IfcAxis2Placement3D placement1       = new IfcAxis2Placement3D(new IfcCartesianPoint(dbInitial, 2, 5, 1));
            IfcLocalPlacement   objectPlacement1 = new IfcLocalPlacement(site.ObjectPlacement, placement1);

            IfcAxis2Placement3D placement2       = new IfcAxis2Placement3D(new IfcCartesianPoint(dbInitial, 14, 5, 1));
            IfcLocalPlacement   objectPlacement2 = new IfcLocalPlacement(site.ObjectPlacement, placement2);


            var profile1 = new IfcRectangleProfileDef(dbInitial, "rectangleProfileDef", 4, 6);
            IfcExtrudedAreaSolid      extrudedAreaSolid1 = new IfcExtrudedAreaSolid(profile1, 1.35);
            IfcProductDefinitionShape shape1             = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid1));

            var profile2 = new IfcRectangleProfileDef(dbInitial, "rectangleProfileDef", 5, 8);
            IfcExtrudedAreaSolid      extrudedAreaSolid2 = new IfcExtrudedAreaSolid(profile2, 4.1);
            IfcProductDefinitionShape shape2             = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid2));


            var proxy1 = new IfcBuildingElementProxy(site, objectPlacement1, shape1)
            {
                Name = "Cuboid1",
                Guid = new Guid("fbc7f4b2-177d-4875-88bb-d3b44115bbaa")
            };
            var proxy2 = new IfcBuildingElementProxy(site, objectPlacement2, shape2)
            {
                Name = "Cuboid2",
                Guid = new Guid("f8e196cb-c7d9-4d53-9885-0f687706727a")
            };


            dbInitial.WriteFile("cube_double.ifc");
        }
Esempio n. 14
0
        public static void InitializeManufacturerFile(string key, string manufacurerName, string manufacturerDescription)
        {
            IfcProject ifcProject = Workspace.Current.Documents[key].Project;

            ifcProject.Name     = manufacurerName;
            ifcProject.LongName = manufacturerDescription;

            IfcSite site = ifcProject.Sites.AddNewSite();

            site.Name     = manufacurerName;
            site.LongName = manufacturerDescription;
        }
Esempio n. 15
0
 public static IEnumerable <IfcSpace> GetSpaces(this IfcSite site)
 {
     if (site != null)
     {
         if (site.IsDecomposedBy != null)
         {
             var decomp = site.IsDecomposedBy;
             var objs   = decomp.SelectMany(s => s.RelatedObjects);
             return(objs.OfType <IfcSpace>());
         }
     }
     return(Enumerable.Empty <IfcSpace>());
 }
Esempio n. 16
0
        static void Main(string[] args)
        {
            // create database
            var database = new DatabaseIfc(ModelView.Ifc4NotAssigned);

            // create IfcSite instance
            var site = new IfcSite(database, "Site entity");

            // create top-most spatial structure element IfcProject, set units and assign facility to project
            var project = new IfcProject(site, "Project entity");

            database.WriteFile("spatial.ifc");
        }
Esempio n. 17
0
        protected BbSite(
            Guid guid, string name, string description, string longname, string compositionType, BbProject project)

        {
            Guid = guid;

            ObjectBbLocalPlacement = BbLocalPlacement3D.Create(BbHeaderSetting.Setting3D.DefaultBbPosition3D);

            IfcSpatialStructureElement = new IfcSite
            {
                GlobalId        = IfcGloballyUniqueId.ConvertToIfcGuid(guid),
                OwnerHistory    = BbHeaderSetting.Setting3D.IfcOwnerHistory,
                Name            = name,
                Description     = description,
                LongName        = longname,
                ObjectPlacement = ObjectBbLocalPlacement.IfcLocalPlacement,
                //                CompositionType = IfcElementCompositionEnum.ELEMENT,
            };

            if (compositionType.ToLower() == @"complex")
            {
                IfcSpatialStructureElement.CompositionType = IfcElementCompositionEnum.COMPLEX;
            }
            else if (compositionType.ToLower() == @"partial")
            {
                IfcSpatialStructureElement.CompositionType = IfcElementCompositionEnum.PARTIAL;
            }
            else
            {
                IfcSpatialStructureElement.CompositionType = IfcElementCompositionEnum.ELEMENT;
            }

            BbProject = project;


            if (true)
            {
                IfcRelAggregates = new IfcRelAggregates()
                {
                    GlobalId       = IfcGloballyUniqueId.NewGuid(),
                    OwnerHistory   = BbHeaderSetting.Setting3D.IfcOwnerHistory,
                    RelatingObject = BbProject.IfcObject,
                    RelatedObjects = new List <IfcObjectDefinition>()
                    {
                        IfcSpatialStructureElement
                    },
                };
            }
        }
Esempio n. 18
0
        /// <summary>
        ///   Adds Site to the IsDecomposedBy Collection.
        /// </summary>
        public void AddSite(IfcSite site)
        {
            var decomposition = IsDecomposedBy.FirstOrDefault();

            if (decomposition == null) //none defined create the relationship
            {
                var relSub = Model.Instances.New <IfcRelAggregates>();
                relSub.RelatingObject = this;
                relSub.RelatedObjects.Add(site);
            }
            else
            {
                decomposition.RelatedObjects.Add(site);
            }
        }
Esempio n. 19
0
        public static void AddSite(this IfcSite site, IfcSite subSite)
        {
            IEnumerable <IfcRelDecomposes> decomposition = site.IsDecomposedBy;

            if (decomposition.Count() == 0) //none defined create the relationship
            {
                IfcRelAggregates relSub = site.ModelOf.Instances.New <IfcRelAggregates>();
                relSub.RelatingObject = site;
                relSub.RelatedObjects.Add(subSite);
            }
            else
            {
                decomposition.First().RelatedObjects.Add(subSite);
            }
        }
Esempio n. 20
0
        public static void AddElement(this IfcSite site, IfcProduct element)
        {
            IEnumerable <IfcRelContainedInSpatialStructure> relatedElements = site.ContainsElements;

            if (relatedElements.Count() == 0) //none defined create the relationship
            {
                IfcRelContainedInSpatialStructure relSe =
                    site.ModelOf.Instances.New <IfcRelContainedInSpatialStructure>();
                relSe.RelatingStructure = site;
                relSe.RelatedElements.Add(element);
            }
            else
            {
                relatedElements.First().RelatedElements.Add(element);
            }
        }
Esempio n. 21
0
        public Site(IfcStore model, string name, LocalPlacement localPlacement, IfcElementCompositionEnum compositionType, double relativeElevation)
        {
            ifcSite = model.Instances.New <IfcSite>(p =>
            {
                p.Name            = name;
                p.ObjectPlacement = localPlacement.IfcLocalPlacement;
                p.CompositionType = compositionType;
                p.RefElevation    = relativeElevation;
            });

            //this.ownerHistory = ownerHistory;
            this.name              = name;
            this.localPlacement    = localPlacement;
            this.compositionType   = compositionType;
            this.relativeElevation = relativeElevation;
        }
Esempio n. 22
0
        public JsonSiteIfcElement(IfcSite site, JsonProjectIfcElement parent, JsonConversionContext context) : base(site)
        {
            userData.projectId = parent?.id;

            if (site.RefLatitude != null && !userData.pset.ContainsKey("RefLatitude"))
            {
                userData.pset.Add("RefLatitude", site.RefLatitude.ToSTEP().ToString());
            }

            if (site.RefLongitude != null && !userData.pset.ContainsKey("RefLongitude"))
            {
                userData.pset.Add("RefLongitude", site.RefLongitude.ToSTEP().ToString());
            }

            if (site.RefElevation != 0 && !userData.pset.ContainsKey("RefElevation"))
            {
                userData.pset.Add("RefElevation", Convert.ToString(site.RefElevation));
            }

            // Extract Pset
            try
            {
                site.ExtractPset(this);
            }
            catch (Exception ex)
            {
                Console.WriteLine("4. Site pset error : " + ex.Message);
            }

            // Add Matrix
            var sObjectPlacements = site.ObjectPlacement.Extract <IfcObjectPlacement>();
            var sLocalPlacements  = sObjectPlacements[0].Extract <IfcLocalPlacement>();
            var sPos = sLocalPlacements[0].RelativePlacement as IfcAxis2Placement3D;

            if (sPos.Location != null)
            {
                userData.location = sPos.Location.Coordinates[0] / context.SCALE + "," + sPos.Location.Coordinates[1] / context.SCALE + "," + sPos.Location.Coordinates[2] / context.SCALE;
            }
            if (sPos.RefDirection != null)
            {
                userData.refDirection = sPos.RefDirection.DirectionRatios[0] + "," + sPos.RefDirection.DirectionRatios[1] + "," + sPos.RefDirection.DirectionRatios[2];
            }
            if (sPos.Axis != null)
            {
                userData.axis = sPos.Axis.DirectionRatios[0] + "," + sPos.Axis.DirectionRatios[1] + "," + sPos.Axis.DirectionRatios[2];
            }
        }
Esempio n. 23
0
 private string GetFacilitySiteDescription(IfcSite ifcSite)
 {
     if (ifcSite != null)
     {
         if (!string.IsNullOrEmpty(ifcSite.LongName))
         {
             return(ifcSite.LongName);
         }
         else if (!string.IsNullOrEmpty(ifcSite.Description))
         {
             return(ifcSite.Description);
         }
         else if (!string.IsNullOrEmpty(ifcSite.Name))
         {
             return(ifcSite.Name);
         }
     }
     return("Site Description");
 }
Esempio n. 24
0
        protected BbSite(
            Guid guid, string name, string description, string longname, string compositionType, BbProject project)
        {
            Guid = guid;

            ObjectBbLocalPlacement = BbLocalPlacement3D.Create(BbHeaderSetting.Setting3D.DefaultBbPosition3D);

            IfcSpatialStructureElement = new IfcSite
            {
                GlobalId = IfcGloballyUniqueId.ConvertToIfcGuid(guid),
                OwnerHistory = BbHeaderSetting.Setting3D.IfcOwnerHistory,
                Name = name,
                Description = description,
                LongName = longname,
                ObjectPlacement = ObjectBbLocalPlacement.IfcLocalPlacement,
                //                CompositionType = IfcElementCompositionEnum.ELEMENT,
            };

            if (compositionType.ToLower() == @"complex")
            {
                IfcSpatialStructureElement.CompositionType = IfcElementCompositionEnum.COMPLEX;
            }
            else if (compositionType.ToLower() == @"partial")
            {
                IfcSpatialStructureElement.CompositionType = IfcElementCompositionEnum.PARTIAL;
            }
            else
            {
                IfcSpatialStructureElement.CompositionType = IfcElementCompositionEnum.ELEMENT;
            }

            BbProject = project;

            if (true)
            {
                IfcRelAggregates = new IfcRelAggregates() {
                    GlobalId = IfcGloballyUniqueId.NewGuid(),
                    OwnerHistory = BbHeaderSetting.Setting3D.IfcOwnerHistory,
                    RelatingObject = BbProject.IfcObject,
                    RelatedObjects = new List<IfcObjectDefinition>() { IfcSpatialStructureElement },
                };
            }
        }
Esempio n. 25
0
 private string GetFacilitySiteName(IfcSite ifcSite)
 {
     if (ifcSite != null)
     {
         if (!string.IsNullOrEmpty(ifcSite.Name))
         {
             return(ifcSite.Name);
         }
         else if (!string.IsNullOrEmpty(ifcSite.LongName))
         {
             return(ifcSite.LongName);
         }
         else if (!string.IsNullOrEmpty(ifcSite.GlobalId))
         {
             return(ifcSite.GlobalId);
         }
     }
     return("Site Name");
 }
Esempio n. 26
0
        public void CreateProjectInitTest()
        {
            //==== DEFAULT PROJECT ====
            IfcProject project_default = IfcInit.CreateProject(null, null, null);
            IfcSite    site_default    = IfcInit.CreateSite(null, null, null);

            project_default.Aggregate(site_default, null);
            IfcBuilding building_default = IfcInit.CreateBuilding(null, null, null, null);

            site_default.Aggregate(building_default, null);
            IfcBuildingStorey storey_default = IfcInit.CreateBuildingStorey(null, null, null, null);

            building_default.Aggregate(storey_default, null);
            using (FileStream fs = File.Create("./default_project.ifc"))
            {
                project_default.SerializeToStep(fs, "IFC2X3", null);
            }

            //==== MANUAL CONTENT PROJECT ====
            IfcPerson       person       = IfcInit.CreatePerson("Melange", "Cedric");
            IfcOrganization organization = IfcInit.CreateOrganization("test organization", "a dummy organization for testing", "MyOrg");
            IfcApplication  application  = IfcInit.CreateApplication(organization, "1.0", "test app", "TestApp");
            IfcOwnerHistory ownerHistory = IfcInit.CreateOwnerHistory(person,
                                                                      organization,
                                                                      application);
            IfcProject project_manual = IfcInit.CreateProject("manual",
                                                              "My manual test project",
                                                              ownerHistory);
            IfcSite site_manual = IfcInit.CreateSite("test site", "a dummy site for testing", ownerHistory);

            project_manual.Aggregate(site_manual, ownerHistory);
            IfcBuilding building_manual = IfcInit.CreateBuilding("test building", "a dummy building for testing", ownerHistory, site_manual.ObjectPlacement);

            site_manual.Aggregate(building_manual, ownerHistory);
            IfcBuildingStorey storey_manual = IfcInit.CreateBuildingStorey("first storey", "first storey for testing", ownerHistory, building_manual.ObjectPlacement);

            building_manual.Aggregate(storey_manual, null);
            using (FileStream fs = File.Create("./manual_project.ifc"))
            {
                project_manual.SerializeToStep(fs, "IFC2X3", "my company");
            }
        }
Esempio n. 27
0
        /// <summary>
        /// only for import
        /// </summary>
        /// <param name="ifcSite"></param>
        protected BbSite(IfcSite ifcSite)
        {
            Guid = IfcGloballyUniqueId.ConvertToGuid(ifcSite.GlobalId);

            var a = EarlyBindingInstanceModel.GetReferencedEntities(ifcSite.EIN).Values;

            var b = (from x in a.OfType<IfcRelAggregates>()
                where x.RelatingObject.GetType() == typeof (IfcProject)
                     select x).First() as IfcRelAggregates;

            IfcRelAggregates = b;

            if (b != null)
            {
                var sPrjGuid = BbInstanceDB.GetSemIdListByEin(b.RelatingObject.EIN).First();
                var aa = BbInstanceDB.GetSemById(sPrjGuid) as BbProject;
                BbProject = aa;

            }

            IfcSpatialStructureElement = ifcSite;
        }
Esempio n. 28
0
        /// <summary>
        /// Returns the projected footprint are of the site, this value is derived and makes use of property sets not in the ifc schema
        /// </summary>
        /// <param name="site"></param>
        /// <returns></returns>
        public static IfcAreaMeasure?GetFootprintArea(this IfcSite site)
        {
            IfcQuantityArea qArea = site.GetQuantity <IfcQuantityArea>("BaseQuantities", "GrossArea");

            if (qArea == null)
            {
                qArea = site.GetQuantity <IfcQuantityArea>("GrossArea");              //just look for any area
            }
            if (qArea != null)
            {
                return(qArea.AreaValue);
            }
            //if revit try their value
            IfcAreaMeasure val = site.GetPropertySingleValue <IfcAreaMeasure>("PSet_Revit_Dimensions", "Projected Area");

            if (val != null)
            {
                return(val);
            }

            return(null);
        }
Esempio n. 29
0
        /// <summary>
        /// only for import
        /// </summary>
        /// <param name="ifcSite"></param>
        protected BbSite(IfcSite ifcSite)
        {
            Guid = IfcGloballyUniqueId.ConvertToGuid(ifcSite.GlobalId);

            var a = EarlyBindingInstanceModel.GetReferencedEntities(ifcSite.EIN).Values;

            var b = (from x in a.OfType <IfcRelAggregates>()
                     where x.RelatingObject.GetType() == typeof(IfcProject)
                     select x).First() as IfcRelAggregates;

            IfcRelAggregates = b;


            if (b != null)
            {
                var sPrjGuid = BbInstanceDB.GetSemIdListByEin(b.RelatingObject.EIN).First();
                var aa       = BbInstanceDB.GetSemById(sPrjGuid) as BbProject;
                BbProject = aa;
            }


            IfcSpatialStructureElement = ifcSite;
        }
Esempio n. 30
0
        public static IfcBuilding CreateBuilding(IfcStore model, string name, IfcSite site = null)
        {
            using (var txn = model.BeginTransaction("Create Building"))
            {
                var building = model.Instances.New <IfcBuilding>();
                building.Name = name;
                building.OwnerHistory.OwningUser        = model.DefaultOwningUser as Xbim.Ifc2x3.ActorResource.IfcPersonAndOrganization;
                building.OwnerHistory.OwningApplication = model.DefaultOwningApplication as Xbim.Ifc2x3.UtilityResource.IfcApplication;
                //building.ElevationOfRefHeight = elevHeight;
                building.CompositionType = IfcElementCompositionEnum.ELEMENT;


                if (site == null)
                {
                    IfcProject(model).AddBuilding(building);
                }
                else
                {
                    AddBuildingElement(site, building);
                }
                txn.Commit();
                return(building);
            }
        }
Esempio n. 31
0
        internal static DatabaseIfc Generate(ModelView mdv, string path)
        {
            DatabaseIfc db = new DatabaseIfc(true, mdv);
            //IfcGeometricRepresentationContext
            //IfcCartesianPoint
            //IfcAxis2Placement3D
            //IfcDirection
            //IfcAxis2Placement2D
            //IfcSIUnit
            //IfcLocalPlacement
            IfcSite site = new IfcSite(db, "TestSite");
            //IfcPerson  NOT RV
            //IfcOrganization  NOT RV
            //IfcPersonAndOrganization  NOT RV
            //IfcOwnerHistory  NOT RV
            //fcApplication NOT RV
            //                     IfcProjectLibrary NOT RV Can't have multiple context
            IfcProject project = new IfcProject(site, "TestProject", IfcUnitAssignment.Length.Millimetre)
            {
            };
            //IfcUnitAssignment
            //IfcRelAggregates
            IfcBuilding building = new IfcBuilding(site, "TestBuilding")
            {
            };
            IfcBuildingStorey buildingStorey = new IfcBuildingStorey(building, "TestBuildingStorey", 3000);
            IfcSpace          space          = new IfcSpace(buildingStorey, null, null)
            {
                Name = "TestSpace"
            };

            space.RelatingType = new IfcSpaceType(db, "TestSpaceType", IfcSpaceTypeEnum.INTERNAL);

            IfcZone zone = new IfcZone(buildingStorey, "TestZone", "TestZoneLongName", new List <IfcSpace>()
            {
                space
            });

            IfcLocalPlacement localPlacement = buildingStorey.Placement as IfcLocalPlacement;

            IfcMaterial material = new IfcMaterial(db, "TestMaterial")
            {
                Description = "TestDescription", Category = "TestCategory"
            };
            IfcMaterialProperties materialProperties = new IfcMaterialProperties("TestMaterialProperties", material);

            materialProperties.AddProperty(new IfcPropertySingleValue(db, "MassDensity", new IfcMassDensityMeasure(1)));
            IfcSurfaceStyleShading surfaceStyleShading = new IfcSurfaceStyleShading(new IfcColourRgb(db, 1, 0, 0)
            {
                Name = "Red"
            });
            IfcSurfaceStyle surfaceStyle = new IfcSurfaceStyle(surfaceStyleShading, null, null, null, null);
            IfcMaterialDefinitionRepresentation materialDefinitionRepresentation = new IfcMaterialDefinitionRepresentation(new IfcStyledRepresentation(new IfcStyledItem(surfaceStyle)
            {
                Name = "TestStyledItem"
            }), material);

            IfcIndexedPolyCurve          indexedPolyCurve          = IPE200Curve(db);
            IfcArbitraryClosedProfileDef arbitraryClosedProfileDef = new IfcArbitraryClosedProfileDef("IPE200", indexedPolyCurve);
            IfcMaterialProfile           materialProfile           = new IfcMaterialProfile("TestMaterialProfile", material, arbitraryClosedProfileDef);
            IfcMaterialProfileSet        materialProfileSet        = new IfcMaterialProfileSet("TestMaterialProfileSet", materialProfile);

            IfcExtrudedAreaSolid extrudedAreaSolid = new IfcExtrudedAreaSolid(arbitraryClosedProfileDef, new IfcAxis2Placement3D(new IfcCartesianPoint(db, 0, 0, 0), new IfcDirection(db, 1, 0, 0), new IfcDirection(db, 0, 1, 0)), new IfcDirection(db, 0, 0, 1), 5000);
            IfcBeamType          beamType          = new IfcBeamType(db, "TestBeamType", IfcBeamTypeEnum.BEAM);

            beamType.MaterialSelect = materialProfileSet;
            IfcBeam beam = new IfcBeam(buildingStorey, new IfcLocalPlacement(localPlacement, new IfcAxis2Placement3D(new IfcCartesianPoint(db, 1000, 2000, 0))
            {
                RefDirection = new IfcDirection(db, 0, 1, 0)
            }), new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid)));

            //IfcGeometricRepresentationSubContext
            beam.RelatingType = beamType;
            //IfcRelDefinesByType

            //	if(mdv != ModelView.Ifc4Reference)
            //			IfcActorRole  NOT RV

            //IfcActuator
            //IfcActuatorType
            //IfcAdvancedBrep  NOT RV
            //IfcAdvancedFace   NOT RV
            //IfcAirTerminal
            //IfcAirTerminalBox
            //IfcAirTerminalBoxType
            //IfcAirTerminalType
            //IfcAirToAirHeatRecovery
            //IfcAirToAirHeatRecoveryType
            //IfcAlarm
            //IfcAlarmType
            //IfcArbitraryOpenProfileDef
            //IfcArbitraryProfileDefWithVoids
            //IfcAsymmetricIShapeProfileDef  NOT RV
            //IfcAudioVisualAppliance
            //IfcAudioVisualApplianceType
            //IfcAxis1Placement
            //IfcBeamStandardCase  NOT RV
            //IfcBlock   NOT RV
            //IfcBoiler
            //IfcBoilerType
            //IfcBooleanClippingResult  NOT RV
            //IfcBooleanResult  NOT RV
            //IfcBSplineCurveWithKnots  NOT RV
            //IfcBSplineSurface  NOT RV
            //IfcBSplineSurfaceWithKnots  NOT RV
            //IfcBuildingElementPart
            //IfcBuildingElementPartType
            //IfcBuildingElementProxy
            //IfcBuildingElementProxyType
            //IfcBuildingSystem
            //IfcBurner
            //IfcBurnerType
            //IfcCableCarrierFitting
            //IfcCableCarrierFittingType
            //IfcCableCarrierSegment
            //IfcCableCarrierSegmentType
            //IfcCableFitting
            //IfcCableFittingType
            //IfcCableSegment
            //IfcCableSegmentType
            //IfcCartesianPointList2D
            //IfcCartesianPointList3D
            //IfcCartesianTransformationOperator2D
            //IfcCartesianTransformationOperator2DnonUniform
            //IfcCartesianTransformationOperator3D
            //IfcCartesianTransformationOperator3DnonUniform
            //IfcCenterLineProfileDef
            //IfcChiller
            //IfcChillerType
            //IfcChimney
            //IfcChimneyType
            //IfcCircle
            //IfcCircleHollowProfileDef  NOT RV
            //IfcCircleProfileDef  NOT RV
            //IfcCivilElement
            //IfcCivilElementType
            //IfcClassification
            //IfcClassificationReference
            //IfcClosedShell
            //IfcCoil
            //IfcCoilType
            //IfcColourRgbList
            //IfcColourSpecification
            //IfcColumn
            //IfcColumnStandardCase  NOT RV
            //IfcColumnType
            //IfcCommunicationsAppliance
            //IfcCommunicationsApplianceType
            //IfcComplexProperty
            //IfcCompositeProfileDef  NOT RV
            //IfcCompressor
            //IfcCompressorType
            //IfcCondenser
            //IfcCondenserType
            //IfcConnectedFaceSet  NOT RV
            //IfcConnectionCurveGeometry  NOT RV
            //IfcConnectionVolumeGeometry  NOT RV
            //IfcController
            //IfcControllerType
            //IfcConversionBasedUnit
            //IfcConversionBasedUnitWithOffset
            //IfcCooledBeam
            //IfcCooledBeamType
            //IfcCoolingTower
            //IfcCoolingTowerType
            //IfcCovering
            //IfcCoveringType
            //IfcCsgSolid  NOT RV
            //IfcCShapeProfileDef  NOT RV
            //IfcCurtainWall
            //IfcCurtainWallType
            //IfcCurveStyle
            //IfcCurveStyleFont
            //IfcCurveStyleFontPattern
            //IfcDamper
            //IfcDamperType
            //IfcDerivedProfileDef  NOT RV
            //IfcDerivedUnit
            //IfcDerivedUnitElement
            //IfcDimensionalExponents
            //IfcDiscreteAccessory
            //IfcDiscreteAccessoryType
            //IfcDistributionChamberElement
            //IfcDistributionChamberElementType
            //IfcDistributionCircuit
            //IfcDistributionControlElement
            //IfcDistributionControlElementType
            //IfcDistributionElement
            //IfcDistributionElementType
            //IfcDistributionFlowElement
            //IfcDistributionFlowElementType
            //IfcDistributionPort
            //IfcDistributionSystem
            //IfcDocumentReference
            //IfcDoor
            //IfcDoorLiningProperties
            //IfcDoorPanelProperties
            //IfcDoorStandardCase  NOT RV
            //IfcDoorType
            //IfcDuctFitting
            //IfcDuctFittingType
            //IfcDuctSegment
            //IfcDuctSegmentType
            //IfcDuctSilencer
            //IfcDuctSilencerType
            //IfcEdge	 NOT RV
            //IfcEdgeCurve  NOT RV
            //IfcEdgeLoop  NOT RV
            //IfcElectricAppliance
            //IfcElectricApplianceType
            //IfcElectricDistributionBoard
            //IfcElectricDistributionBoardType
            //IfcElectricFlowStorageDevice
            //IfcElectricFlowStorageDeviceType
            //IfcElectricGenerator
            //IfcElectricGeneratorType
            //IfcElectricMotor
            //IfcElectricMotorType
            //IfcElectricTimeControl
            //IfcElectricTimeControlType
            //IfcElementAssembly
            //IfcElementAssemblyType
            //IfcElementComponent
            //IfcElementComponentType
            //IfcElementQuantity
            //IfcEllipseProfileDef  NOT RV
            //IfcEnergyConversionDevice
            //IfcEnergyConversionDeviceType
            //IfcEngine
            //IfcEngineType
            //IfcEvaporativeCooler
            //IfcEvaporativeCoolerType
            //IfcEvaporator
            //IfcEvaporatorType
            //IfcExtendedProperties
            //IfcExternalInformation
            //IfcExternalReference
            //IfcExtrudedAreaSolidTapered  NOT RV
            //IfcFace  NOT RV
            //IfcFaceBasedSurfaceModel  NOT RV
            //IfcFaceBound  NOT RV
            //IfcFaceOuterBound  NOT RV
            //IfcFaceSurface  NOT RV
            //IfcFacetedBrep  NOT RV
            //IfcFan
            //IfcFanType
            //IfcFastener
            //IfcFastenerType
            //IfcFeatureElement
            //IfcFeatureElementAddition  NOT RV
            //IfcFeatureElementSubtraction
            //IfcFillAreaStyle
            //IfcFillAreaStyleHatching
            //IfcFilter
            //IfcFilterType
            //IfcFireSuppressionTerminal
            //IfcFireSuppressionTerminalType
            //IfcFixedReferenceSweptAreaSolid  NOT RV
            //IfcFlowController
            //IfcFlowControllerType
            //IfcFlowFitting
            //IfcFlowFittingType
            //IfcFlowInstrument
            //IfcFlowInstrumentType
            //IfcFlowMeter
            //IfcFlowMeterType
            //IfcFlowMovingDevice
            //IfcFlowMovingDeviceType
            //IfcFlowSegment
            //IfcFlowSegmentType
            //IfcFlowStorageDevice
            //IfcFlowStorageDeviceType
            //IfcFlowTerminal
            //IfcFlowTerminalType
            //IfcFlowTreatmentDevice
            //IfcFlowTreatmentDeviceType
            //IfcFooting
            //IfcFootingType
            //IfcFurnishingElement
            //IfcFurnishingElementType
            //IfcFurniture
            //IfcFurnitureType
            //IfcGeographicElement
            //IfcGeographicElementType
            //IfcGeometricCurveSet
            //IfcGeometricSet
            //IfcGrid
            //IfcGridAxis
            //IfcGridPlacement  NOT RV
            //IfcGroup
            //IfcHalfSpaceSolid  NOT RV
            //IfcHeatExchanger
            //IfcHeatExchangerType
            //IfcHumidifier
            //IfcHumidifierType
            //IfcIndexedColourMap
            //IfcIndexedTextureMap
            //IfcIndexedTriangleTextureMap
            //IfcInterceptor
            //IfcInterceptorType
            //IfcIShapeProfileDef
            //IfcJunctionBox
            //IfcJunctionBoxType
            //IfcLamp
            //IfcLampType
            //IfcLibraryInformation  NOT RV
            //IfcLibraryReference  NOT RV
            //IfcLightFixture
            //IfcLightFixtureType
            //IfcLine
            //IfcLoop   NOT RV
            //IfcLShapeProfileDef  NOT RV
            //IfcMapConversion
            //IfcMappedItem
            //IfcMaterialConstituent
            //IfcMaterialConstituentSet
            //IfcMaterialLayer
            //IfcMaterialLayerSet
            //IfcMaterialLayerSetUsage  NOT RV
            //IfcMaterialLayerWithOffsets  NOT RV
            //IfcMaterialProfileSetUsage  NOT RV
            //IfcMaterialProfileSetUsageTapering  NOT RV
            //IfcMaterialProfileWithOffsets  NOT RV
            //IfcMaterialUsageDefinition  NOT RV
            //IfcMeasureWithUnit
            //IfcMechanicalFastener
            //IfcMechanicalFastenerType
            //IfcMedicalDevice
            //IfcMedicalDeviceType
            //IfcMember
            //IfcMemberStandardCase  NOT RV
            //IfcMemberType
            //IfcMonetaryUnit
            //IfcMotorConnection
            //IfcMotorConnectionType
            //IfcNamedUnit
            //IfcOpeningElement
            //IfcOpeningStandardCase  NOT RV
            //IfcOpenShell  NOT RV
            //IfcOrientedEdge  NOT RV
            //IfcOutlet
            //IfcOutletType
            //IfcPcurve  NOT RV
            //IfcPhysicalComplexQuantity
            //IfcPhysicalQuantity
            //IfcPhysicalSimpleQuantity
            //IfcPile
            //IfcPileType
            //IfcPipeFitting
            //IfcPipeFittingType
            //IfcPipeSegment
            //IfcPipeSegmentType
            //IfcPlane  NOT RV
            //IfcPlate
            //IfcPlateStandardCase  NOT RV
            //IfcPlateType
            //IfcPoint
            //IfcPolygonalBoundedHalfSpace  NOT RV
            //IfcPolyline  NOT RV
            //IfcPolyLoop  NOT RV
            //IfcPort
            //IfcPostalAddress
            //IfcPreDefinedPropertySet
            //IfcPresentationItem
            //IfcPresentationLayerAssignment
            //IfcPresentationStyle
            //IfcPresentationStyleAssignment
            //IfcProductDefinitionShape
            //IfcProductRepresentation
            //IfcProfileDef
            //IfcProfileProperties
            //IfcProjectedCRS
            //IfcProjectionElement  NOT RV
            //IfcProperty
            //IfcPropertyAbstraction
            //IfcPropertyBoundedValue
            //IfcPropertyDefinition
            //IfcPropertyEnumeratedValue
            //IfcPropertyEnumeration
            //IfcPropertyListValue
            //IfcPropertySet
            //IfcPropertySetTemplate  NOT RV
            //IfcPropertyTableValue
            //IfcPropertyTemplate  NOT RV
            //IfcPropertyTemplateDefinition  NOT RV
            //IfcProtectiveDevice
            //IfcProtectiveDeviceTrippingUnit
            //IfcProtectiveDeviceTrippingUnitType
            //IfcProtectiveDeviceType
            //IfcPump
            //IfcPumpType
            //IfcQuantityArea
            //IfcQuantityCount
            //IfcQuantityLength
            //IfcQuantitySet
            //IfcQuantityTime
            //IfcQuantityVolume
            //IfcQuantityWeight
            //IfcRailing
            //IfcRailingType
            //IfcRamp
            //IfcRampFlight
            //IfcRampFlightType
            //IfcRampType
            //IfcRectangleHollowProfileDef  NOT RV
            //IfcRectangleProfileDef  NOT RV
            //IfcRectangularPyramid  NOT RV
            //IfcReinforcingBar
            //IfcReinforcingBarType
            //IfcReinforcingElement
            //IfcReinforcingElementType
            //IfcReinforcingMesh
            //IfcReinforcingMeshType
            //IfcRelAssignsToGroup
            //IfcRelAssociatesClassification
            //IfcRelAssociatesDocument
            //IfcRelAssociatesLibrary  NOT RV
            //IfcRelAssociatesMaterial
            //IfcRelConnectsElements  NOT RV
            //IfcRelConnectsPathElements  NOT RV
            //IfcRelConnectsPorts
            //IfcRelConnectsWithRealizingElements  NOT RV
            //IfcRelContainedInSpatialStructure
            //IfcRelCoversBldgElements
            //IfcRelDeclares
            //IfcRelDefinesByProperties
            //IfcRelFillsElement
            //IfcRelFlowControlElements  NOT RV
            //IfcRelInterferesElements  NOT RV
            //IfcRelNests
            //IfcRelProjectsElement  NOT RV
            //IfcRelServicesBuildings
            //IfcRelVoidsElement
            //IfcRepresentation
            //IfcRepresentationContext
            //IfcRepresentationItem
            //IfcRepresentationMap
            //IfcRevolvedAreaSolid
            //IfcRevolvedAreaSolidTapered  NOT RV
            //IfcRightCircularCone  NOT RV
            //IfcRightCircularCylinder  NOT RV
            //IfcRoof
            //IfcRoofType
            //IfcRoundedRectangleProfileDef  NOT RV
            //IfcSanitaryTerminal
            //IfcSanitaryTerminalType
            //IfcSensor
            //IfcSensorType
            //IfcShadingDevice
            //IfcShadingDeviceType
            //IfcShapeRepresentation
            //IfcShellBasedSurfaceModel  NOT RV
            //IfcSimplePropertyTemplate  NOT RV
            //IfcSlab
            //IfcSlabElementedCase  NOT RV
            //IfcSlabStandardCase  NOT RV
            //IfcSlabType
            //IfcSolarDevice
            //IfcSolarDeviceType
            //IfcSpaceHeater
            //IfcSpaceHeaterType
            //IfcSpatialZone
            //IfcSpatialZoneType
            //IfcSphere  NOT RV
            //IfcStackTerminal
            //IfcStackTerminalType
            //IfcStair
            //IfcStairFlight
            //IfcStairFlightType
            //IfcStairType
            //IfcStyleModel
            //IfcSurface  NOT RV
            //IfcSurfaceCurveSweptAreaSolid  NOT RV
            //IfcSurfaceOfLinearExtrusion  NOT RV
            //IfcSurfaceOfRevolution  NOT RV
            //IfcSurfaceStyleRendering
            //IfcSurfaceStyleWithTextures surfaceStyleWithTextures = new IfcSurfaceStyleWithTextures(new IfcImageTexture(db,true,true,""));
            //IfcSweptDiskSolid
            //IfcSwitchingDevice
            //IfcSwitchingDeviceType
            //IfcSystemFurnitureElement
            //IfcSystemFurnitureElementType
            //IfcTank
            //IfcTankType
            //IfcTelecomAddress  NOT RV
            //IfcTendon
            //IfcTendonAnchor
            //IfcTendonAnchorType
            //IfcTendonType
            //IfcTessellatedFaceSet
            //IfcTessellatedItem
            //IfcTextureCoordinate
            //IfcTextureVertexList
            //IfcTransformer
            //IfcTransformerType
            //IfcTransportElement
            //IfcTransportElementType
            //IfcTriangulatedFaceSet
            //IfcTrimmedCurve
            //IfcTShapeProfileDef  NOT RV
            //IfcTubeBundle
            //IfcTubeBundleType
            //IfcUnitaryControlElement
            //IfcUnitaryControlElementType
            //IfcUnitaryEquipment
            //IfcUnitaryEquipmentType
            //IfcUShapeProfileDef  NOT RV
            //IfcValve
            //IfcValveType
            //IfcVector
            //IfcVertex  NOT RV
            //IfcVertexPoint  NOT RV
            //IfcVibrationIsolator
            //IfcVibrationIsolatorType
            //IfcVirtualGridIntersection  NOT RV
            //IfcWall
            //IfcWallElementedCase  NOT RV
            //IfcWallStandardCase  NOT RV
            //IfcWallType
            //IfcWasteTerminal
            //IfcWasteTerminalType
            //IfcWindow
            //IfcWindowLiningProperties
            //IfcWindowPanelProperties
            //IfcWindowStandardCase  NOT RV
            //IfcWindowType
            //IfcZShapeProfileDef  NOT RV
            db.WriteFile(Path.Combine(path, mdv.ToString() + ".ifc"));
            return(db);
        }
Esempio n. 32
0
        public void PostToStore(Xbim.Ifc2x3.ProductExtension.IfcSite rt)
        {

            

            var rdfrt = new IfcSite(this)
            {
                UriId = rt.GlobalId.ToString(),
                GlobalId = rt.GlobalId,
                Name = rt.Name.ToString(),
                Description = rt.Description.ToString(),
                RefLatitude =
                new IfcCompoundPlaneAngleMeasure(this)
                {
                    
                    first = rt.RefLatitude.Value.Degrees,
                    rest = new IfcCompoundPlaneAngleMeasure(this) {
                                first = rt.RefLatitude.Value.Minutes,
                                rest = new IfcCompoundPlaneAngleMeasure(this){
                                         first = rt.RefLatitude.Value.Seconds,
                                        rest = new IfcCompoundPlaneAngleMeasure(this) {
                                            first = (double)(rt.RefLatitude.Value.MillionthsOfaSecond == null ? 0 : rt.RefLatitude.Value.MillionthsOfaSecond),
                                            rest = new IfcCompoundPlaneAngleMeasure(this)
                            }
                        }
                    }
                },
                RefLongitude =
                new IfcCompoundPlaneAngleMeasure(this)
                {
                    first = rt.RefLongitude.Value.Degrees,
                    rest = new IfcCompoundPlaneAngleMeasure(this)
                    {
                        first = rt.RefLongitude.Value.Minutes,
                        rest = new IfcCompoundPlaneAngleMeasure(this)
                        {
                            first = rt.RefLongitude.Value.Seconds,
                            rest = new IfcCompoundPlaneAngleMeasure(this)
                            {
                                first = (double)(rt.RefLatitude.Value.MillionthsOfaSecond == null ? 0 : rt.RefLatitude.Value.MillionthsOfaSecond),
                                rest = new IfcCompoundPlaneAngleMeasure(this)
                            }
                        }
                    }
                }

            };                          
        }
Esempio n. 33
0
        /// <summary>
        /// Write the model to IFC.
        /// </summary>
        /// <param name="model"></param>
        /// <param name="path">The path to the generated IFC STEP file.</param>
        public static void ToIFC(this Model model, string path)
        {
            var ifc = new Document("Elements", "Elements", Environment.UserName,
                                   null, null, null, "Elements", null, null,
                                   null, null, null, null, null, null
                                   );

            var proj = ifc.AllInstancesOfType <IfcProject>().FirstOrDefault();

            // Add a site
            var site          = new IfcSite(IfcGuid.ToIfcGuid(Guid.NewGuid()), null, IfcElementCompositionEnum.ELEMENT);
            var projAggregate = new IfcRelAggregates(IfcGuid.ToIfcGuid(Guid.NewGuid()), null, proj, new List <IfcObjectDefinition> {
                site
            });

            // Add building and building storey
            var building  = new IfcBuilding(IfcGuid.ToIfcGuid(Guid.NewGuid()), null, IfcElementCompositionEnum.ELEMENT);
            var storey    = new IfcBuildingStorey(IfcGuid.ToIfcGuid(Guid.NewGuid()), null, IfcElementCompositionEnum.ELEMENT);
            var aggregate = new IfcRelAggregates(IfcGuid.ToIfcGuid(Guid.NewGuid()), null, building, new List <IfcObjectDefinition> {
                storey
            });

            // Aggregate the building into the site
            var siteAggregate = new IfcRelAggregates(IfcGuid.ToIfcGuid(Guid.NewGuid()), null, site, new List <IfcObjectDefinition> {
                building
            });

            ifc.AddEntity(site);
            ifc.AddEntity(projAggregate);
            ifc.AddEntity(building);
            ifc.AddEntity(storey);
            ifc.AddEntity(aggregate);
            ifc.AddEntity(siteAggregate);

            var products = new List <IfcProduct>();
            var context  = ifc.AllInstancesOfType <IfcGeometricRepresentationContext>().FirstOrDefault();

            foreach (var e in model.Elements.Values)
            {
                try
                {
                    products.AddRange(e.ToIfcProducts(context, ifc));
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"There was an error writing an element of type {e.GetType()} to IFC: " + ex.Message);
                    Console.WriteLine(ex.StackTrace);
                    continue;
                }
            }

            var spatialRel = new IfcRelContainedInSpatialStructure(IfcGuid.ToIfcGuid(Guid.NewGuid()), null, products, storey);

            ifc.AddEntity(spatialRel);

            if (File.Exists(path))
            {
                File.Delete(path);
            }
            File.WriteAllText(path, ifc.ToSTEP(path));
        }
Esempio n. 34
0
        /// <summary>
        /// Write the model to IFC.
        /// </summary>
        /// <param name="model"></param>
        /// <param name="path">The path to the generated IFC STEP file.</param>
        public static void ToIFC(this Model model, string path)
        {
            var ifc = new Document("Elements", "Elements", Environment.UserName,
                                   null, null, null, "Elements", null, null,
                                   null, null, null, null, null, null
                                   );

            var proj = ifc.AllInstancesOfType <IfcProject>().FirstOrDefault();

            // Add a site
            var site = new IfcSite(IfcGuid.ToIfcGuid(Guid.NewGuid()),
                                   null,
                                   "Hypar Site",
                                   "The default site generated by Hypar",
                                   null,
                                   null,
                                   null,
                                   null,
                                   IfcElementCompositionEnum.ELEMENT,
                                   new IfcCompoundPlaneAngleMeasure(new List <int> {
                0, 0, 0
            }),
                                   new IfcCompoundPlaneAngleMeasure(new List <int> {
                0, 0, 0
            }),
                                   0,
                                   null,
                                   null);
            var projAggregate = new IfcRelAggregates(IfcGuid.ToIfcGuid(Guid.NewGuid()), proj, new List <IfcObjectDefinition> {
                site
            });

            // Add building and building storey
            var building = new IfcBuilding(IfcGuid.ToIfcGuid(Guid.NewGuid()),
                                           null,
                                           "Default Building",
                                           "The default building generated by Hypar.",
                                           null,
                                           null,
                                           null,
                                           null,
                                           IfcElementCompositionEnum.ELEMENT,
                                           0,
                                           0,
                                           null);
            var storey = new IfcBuildingStorey(IfcGuid.ToIfcGuid(Guid.NewGuid()),
                                               null,
                                               "Default Storey",
                                               "The default storey generated by Hypar",
                                               null,
                                               null,
                                               null,
                                               null,
                                               IfcElementCompositionEnum.ELEMENT,
                                               0);
            var aggregate = new IfcRelAggregates(IfcGuid.ToIfcGuid(Guid.NewGuid()), building, new List <IfcObjectDefinition> {
                storey
            });

            // Aggregate the building into the site
            var siteAggregate = new IfcRelAggregates(IfcGuid.ToIfcGuid(Guid.NewGuid()), site, new List <IfcObjectDefinition> {
                building
            });

            ifc.AddEntity(site);
            ifc.AddEntity(projAggregate);
            ifc.AddEntity(building);
            ifc.AddEntity(storey);
            ifc.AddEntity(aggregate);
            ifc.AddEntity(siteAggregate);

            var products = new List <IfcProduct>();
            var context  = ifc.AllInstancesOfType <IfcGeometricRepresentationContext>().FirstOrDefault();

            // IfcRelAssociatesMaterial
            // IfcMaterialDefinitionRepresentation
            // https://forums.buildingsmart.org/t/where-and-how-will-my-colors-be-saved-in-ifc/1806/12
            var styleAssignments = new Dictionary <Guid, List <IfcStyleAssignmentSelect> >();

            var white = Colors.White.ToIfcColourRgb();

            ifc.AddEntity(white);

            // TODO: Fix color support in all applications.
            // https://forums.buildingsmart.org/t/why-is-it-so-difficult-to-get-colors-to-show-up/2312/12
            foreach (var m in model.AllElementsOfType <Material>())
            {
                var material = new IfcMaterial(m.Name, null, "Hypar");
                ifc.AddEntity(material);

                var color = m.Color.ToIfcColourRgb();
                ifc.AddEntity(color);

                var transparency = new IfcNormalisedRatioMeasure(1.0 - m.Color.Alpha);

                var shading = new IfcSurfaceStyleShading(color, transparency);
                ifc.AddEntity(shading);

                var styles = new List <IfcSurfaceStyleElementSelect> {
                    new IfcSurfaceStyleElementSelect(shading),
                };
                var surfaceStyle = new IfcSurfaceStyle(material.Name, IfcSurfaceSide.BOTH, styles);
                ifc.AddEntity(surfaceStyle);

                var styleAssign = new IfcStyleAssignmentSelect(surfaceStyle);
                var assignments = new List <IfcStyleAssignmentSelect>()
                {
                    styleAssign
                };
                styleAssignments.Add(m.Id, assignments);
            }


            foreach (var e in model.Elements.Values.Where(e =>
            {
                var t = e.GetType();
                return(((e is GeometricElement &&
                         !((GeometricElement)e).IsElementDefinition) || e is ElementInstance) &&
                       t != typeof(ModelCurve) &&
                       t != typeof(ModelPoints) &&
                       t != typeof(AnalysisMesh));
            }))
            {
                try
                {
                    products.AddRange(e.ToIfcProducts(context, ifc, styleAssignments));
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"There was an error writing an element of type {e.GetType()} to IFC: " + ex.Message);
                    Console.WriteLine(ex.StackTrace);
                    continue;
                }
            }

            var spatialRel = new IfcRelContainedInSpatialStructure(IfcGuid.ToIfcGuid(Guid.NewGuid()), products, storey);

            ifc.AddEntity(spatialRel);

            if (File.Exists(path))
            {
                File.Delete(path);
            }
            File.WriteAllText(path, ifc.ToSTEP(path));
        }