コード例 #1
0
ファイル: BbMainPiece.cs プロジェクト: mind-peace/ifctoolkit
 protected BbMainPiece(BbAssembly assembly, IfcElement element, IfcRelAggregates ifcRelAggregates)
 {
     //BbAssembly = assembly;
     // wrong implementation need modification, donghoon 20131205
     //_ifcElement = element;
     //_ifcRelAggregates = ifcRelAggregates;
 }
コード例 #2
0
ファイル: BbSite.cs プロジェクト: JackTing/ifctoolkit
 protected BbSite(BbProject project, IfcSite site, IfcRelAggregates ifcRelAggregates)
 {
     BbProject = project;
     IfcSpatialStructureElement = site;
     IfcRelAggregates = ifcRelAggregates;
     Guid = IfcGloballyUniqueId.ConvertToGuid(site.GlobalId);
 }
コード例 #3
0
 protected BbSite(BbProject project, IfcSite site, IfcRelAggregates ifcRelAggregates)
 {
     BbProject = project;
     IfcSpatialStructureElement = site;
     IfcRelAggregates           = ifcRelAggregates;
     Guid = IfcGloballyUniqueId.ConvertToGuid(site.GlobalId);
 }
コード例 #4
0
ファイル: BbMainPiece.cs プロジェクト: JackTing/ifctoolkit
 protected BbMainPiece(BbAssembly assembly, IfcElement element, IfcRelAggregates ifcRelAggregates)
 {
     //BbAssembly = assembly;
     // wrong implementation need modification, donghoon 20131205
     //_ifcElement = element;
     //_ifcRelAggregates = ifcRelAggregates;
 }
コード例 #5
0
        public void AddToHostObject(BbProduct hostObject)
        {
            HostObject = hostObject;
            var a = EarlyBindingInstanceModel.GetReferencedEntities(hostObject.IfcObject.EIN).Values;

            var b = (from x in a.OfType <IfcRelAggregates>()
                     where x.RelatingObject.EIN == hostObject.IfcObject.EIN
                     select x).ToList();

            switch (b.Count)
            {
            case 0:
                IfcRelAggregates = new IfcRelAggregates
                {
                    GlobalId       = IfcGloballyUniqueId.NewGuid(),
                    OwnerHistory   = hostObject.IfcObject.OwnerHistory,
                    RelatingObject = hostObject.IfcObject,
                    RelatedObjects = new List <IfcObjectDefinition>()
                    {
                    },
                };
                break;

            case 1:
                IfcRelAggregates = b[0];
                break;

            default:
                throw new NotImplementedException();
            }
            var aa = GetType().GetProperty("IfcObject").GetValue(this, null) as IfcObject;

            IfcRelAggregates.RelatedObjects.Add(aa);
        }
コード例 #6
0
ファイル: Document.cs プロジェクト: JoinCAD/IFC-gen
        /*public IfcPropertySet AddPropertySet(IfcBuildingElementProxy element, List<IfcProperty> properties){
         *      var ps = new IfcPropertySet(IfcGuid.IfcGuid.ToIfcGuid(Guid.NewGuid()),properties);
         *      var def = new IfcPropertySetDefinition(IfcGuid.IfcGuid.ToIfcGuid(Guid.NewGuid()));
         *      var test = new IfcPropertySetDefinitionSelect();
         *      //var r = new IfcRelDefinesByProperties(IfcGuid.IfcGuid.ToIfcGuid(Guid.NewGuid()), new List<IfcObjectDefinition>{element},);
         * }*/

        private void CreateAggregationRelationship(IfcObjectDefinition from, IfcObjectDefinition to)
        {
            var r = new IfcRelAggregates(IfcGuid.IfcGuid.ToIfcGuid(Guid.NewGuid()), from, new List <IfcObjectDefinition> {
                to
            });

            from.Decomposes.Add(r);
            storage.AddInstance(r);
        }
コード例 #7
0
        public static void AddDecomposingObjectToFirstAggregation(this IfcObjectDefinition obj, IModel model,
                                                                  IfcObjectDefinition decomposingObject)
        {
            IfcRelAggregates rel =
                model.Instances.Where <IfcRelAggregates>(r => r.RelatingObject == obj).FirstOrDefault() ??
                model.Instances.New <IfcRelAggregates>(r => r.RelatingObject = obj);

            rel.RelatedObjects.Add(decomposingObject);
        }
コード例 #8
0
        public void AddStorey(IfcStore model, BuildingStorey storey)
        {
            IfcRelAggregates StoryBuildingRel = model.Instances.New <IfcRelAggregates>(p =>
            {
                p.RelatingObject = building.IfcBuilding;
                p.RelatedObjects.Add(storey.IfcBuildingStorey);
            });

            stories.Add(storey);
        }
コード例 #9
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
                    },
                };
            }
        }
コード例 #10
0
        /// <summary>
        ///   Adds Building to the IsDecomposedBy Collection.
        /// </summary>
        public static void AddBuilding(this IfcProject ifcProject, IfcBuilding building)
        {
            IEnumerable <IfcRelDecomposes> decomposition = ifcProject.IsDecomposedBy;

            if (decomposition.Count() == 0) //none defined create the relationship
            {
                IfcRelAggregates relSub = ifcProject.ModelOf.Instances.New <IfcRelAggregates>();
                relSub.RelatingObject = ifcProject;
                relSub.RelatedObjects.Add(building);
            }
            else
            {
                decomposition.First().RelatedObjects.Add(building);
            }
        }
コード例 #11
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);
            }
        }
コード例 #12
0
ファイル: CcIfcSpaces.cs プロジェクト: sxh2000251/Ifc.NET
        public IfcSpace AddNewSpace()
        {
            EventType enabledEventTypes = BaseObject.EventsEnabled;

            BaseObject.EventsEnabled = EventType.None;
            try
            {
                T ifcSpace = (T)AddNew();

                // ------------------------------------------------------------------------------
                IEnumerable <IfcRelAggregates> ifcRelAggregatesCollection = this.Document.IfcXmlDocument.Items.OfType <IfcRelAggregates>().Where(item => item.RelatingObject != null && item.RelatingObject.Ref == ((Ifc4.Entity) this.Parent).Id).ToList();
                if (ifcRelAggregatesCollection.Any())
                {
                    foreach (IfcRelAggregates ifcRelAggregates in ifcRelAggregatesCollection)
                    {
                        var relatedObject = ifcRelAggregates.RelatedObjects.Items.FirstOrDefault(item => item.Ref == ifcSpace.Id);
                        if (relatedObject == null)
                        {
                            ifcRelAggregates.RelatedObjects.Items.Add(ifcSpace.RefInstance());
                        }
                    }
                }
                else
                {
                    IfcRelAggregates relAggregatesBuildingStorey = new IfcRelAggregates()
                    {
                        GlobalId       = Document.GetNewGlobalId(),
                        RelatingObject = new Ifc4.IfcBuildingStorey()
                        {
                            Ref = ((Ifc4.Entity) this.Parent).Id
                        }
                    };
                    relAggregatesBuildingStorey.RelatedObjects = new IfcRelAggregatesRelatedObjects();
                    relAggregatesBuildingStorey.RelatedObjects.Items.Add(ifcSpace.RefInstance());
                    this.Document.IfcXmlDocument.Items.Add(relAggregatesBuildingStorey);
                }
                // ------------------------------------------------------------------------------
                return(ifcSpace);
            }
            catch (Exception exc)
            {
                return(default(T));
            }
            finally
            {
                BaseObject.EventsEnabled = enabledEventTypes;
            }
        }
コード例 #13
0
        /// <summary>
        ///   Adds specified IfcSpatialStructureElement to the decomposition of this spatial structure element.
        /// </summary>
        /// <param name = "se"></param>
        /// <param name = "child">Child spatial structure element.</param>
        public static void AddToSpatialDecomposition(this IfcSpatialStructureElement se,
                                                     IfcSpatialStructureElement child)
        {
            IEnumerable <IfcRelDecomposes> decomposition = se.IsDecomposedBy;

            if (decomposition.Count() == 0) //none defined create the relationship
            {
                IfcRelAggregates relSub = se.Model.Instances.New <IfcRelAggregates>();
                relSub.RelatingObject = se;
                relSub.RelatedObjects.Add(child);
            }
            else
            {
                decomposition.First().RelatedObjects.Add(child);
            }
        }
コード例 #14
0
ファイル: BbSite.cs プロジェクト: JackTing/ifctoolkit
        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 },
                };
            }
        }
コード例 #15
0
ファイル: IFCHelper.cs プロジェクト: 15831944/CADTo3D-1
        internal static IfcBuildingStorey CreateStorey(IfcStore model, IfcBuilding building, string BlkName, int storeyNumber, FloorBase cadFloor)
        {
            IfcBuildingStorey storey;

            using (var trans = model.BeginTransaction("Add Storey"))
            {
                storey      = model.Instances.New <IfcBuildingStorey>();
                storey.Name = BlkName + $"F{storeyNumber}";
                IfcRelAggregates rel = model.Instances.New <IfcRelAggregates>();
                rel.RelatingObject = building;
                rel.RelatedObjects.Add(storey);

                XbimCreateBuilding.AddStoreyProperties(model, storey, cadFloor.Height, cadFloor.Level);

                trans.Commit();
            }

            return(storey);
        }
コード例 #16
0
        BbFloor(
            string name,
            double elevation,
            BbBuilding building)
        {
            ObjectBbLocalPlacement = BbLocalPlacement3D.Create(building.ObjectBbLocalPlacement, BbHeaderSetting.Setting3D.DefaultBbPosition3D);

            IfcSpatialStructureElement = new IfcBuildingStorey
            {
                GlobalId = IfcGloballyUniqueId.NewGuid(),

                OwnerHistory = BbHeaderSetting.Setting3D.IfcOwnerHistory,
                Name         = name,
                //Description = "",
                //ObjectType = "",
                ObjectPlacement = ObjectBbLocalPlacement.IfcLocalPlacement,
                //Representation =
                //LongName = "",
                CompositionType = IfcElementCompositionEnum.ELEMENT,
                Elevation       = elevation,
            };

            //building.AddFloor(this);
            BbBuilding = building;

            if (true)
            {
                IfcRelAggregates = new IfcRelAggregates()
                {
                    GlobalId       = IfcGloballyUniqueId.NewGuid(),
                    OwnerHistory   = BbHeaderSetting.Setting3D.IfcOwnerHistory,
                    RelatingObject = BbBuilding.IfcSpatialStructureElement,
                    RelatedObjects = new List <IfcObjectDefinition>()
                    {
                        IfcSpatialStructureElement
                    },
                };
            }
        }
コード例 #17
0
ファイル: BbFloor.cs プロジェクト: JackTing/ifctoolkit
        BbFloor(
            string name,
            double elevation,
            BbBuilding building)
        {
            ObjectBbLocalPlacement = BbLocalPlacement3D.Create(building.ObjectBbLocalPlacement, BbHeaderSetting.Setting3D.DefaultBbPosition3D);

            IfcSpatialStructureElement = new IfcBuildingStorey
            {
                GlobalId = IfcGloballyUniqueId.NewGuid(),

                OwnerHistory = BbHeaderSetting.Setting3D.IfcOwnerHistory,
                Name = name,
                //Description = "",
                //ObjectType = "",
                ObjectPlacement = ObjectBbLocalPlacement.IfcLocalPlacement,
                //Representation =
                //LongName = "",
                CompositionType = IfcElementCompositionEnum.ELEMENT,
                Elevation = elevation,
            };

            //building.AddFloor(this);
            BbBuilding = building;

            if (true)
            {
                IfcRelAggregates = new IfcRelAggregates()
                {
                    GlobalId = IfcGloballyUniqueId.NewGuid(),
                    OwnerHistory = BbHeaderSetting.Setting3D.IfcOwnerHistory,
                    RelatingObject = BbBuilding.IfcSpatialStructureElement,
                    RelatedObjects = new List<IfcObjectDefinition>() { IfcSpatialStructureElement },
                };
            }
        }
コード例 #18
0
 protected BbBuilding(BbSite site, IfcBuilding building, IfcRelAggregates ifcRelAggregates)
 {
     BbSite = site;
     IfcSpatialStructureElement = building;
     IfcRelAggregates           = ifcRelAggregates;
 }
コード例 #19
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));
        }
コード例 #20
0
ファイル: BbBuilding.cs プロジェクト: JackTing/ifctoolkit
 protected BbBuilding(BbSite site, IfcBuilding building, IfcRelAggregates ifcRelAggregates)
 {
     BbSite = site;
     IfcSpatialStructureElement = building;
     IfcRelAggregates = ifcRelAggregates;
 }
コード例 #21
0
ファイル: BbFloor.cs プロジェクト: JackTing/ifctoolkit
 protected BbFloor(BbBuilding building, IfcBuildingStorey floor, IfcRelAggregates ifcRelAggregates)
 {
     BbBuilding = building;
     IfcSpatialStructureElement = floor;
     IfcRelAggregates = ifcRelAggregates;
 }
コード例 #22
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));
        }
コード例 #23
0
ファイル: CcFacilities.cs プロジェクト: sxh2000251/Ifc.NET
        public T AddNewFacility(CcFacility cloneFacility = null, bool oneToOneCopy = false)
        {
            EventType enabledEventTypes = BaseObject.EventsEnabled;

            BaseObject.EventsEnabled = EventType.None;
            try
            {
                T facility = (T)AddNew();
                // ------------------------------------------------------------------------------
                // Annahme Anlage = IfcBuildingElementProxy
                IfcBuildingElementProxy ifcBuildingElementProxy = new IfcBuildingElementProxy();

                facility.IfcObjectDefinition   = ifcBuildingElementProxy;
                ifcBuildingElementProxy.Parent = this;

                Ifc4.Document document = this.GetParent <Ifc4.Document>();
                if (document != null)
                {
                    Entity entity = ifcBuildingElementProxy as Entity;
                    if (entity != null)
                    {
                        entity.Id = document.GetNextSid();
                        document.IfcXmlDocument.Items.Add(entity);
                    }
                    IfcRoot ifcRoot = ifcBuildingElementProxy as IfcRoot;
                    if (ifcRoot != null)
                    {
                        ifcRoot.GlobalId = document.GetNewGlobalId();
                    }
                }
                // ------------------------------------------------------------------------------
                if (this.Parent.GetType() == typeof(Ifc4.IfcProject))
                {
                    IEnumerable <IfcRelAggregates> ifcRelAggregatesCollection = this.Document.IfcXmlDocument.Items.OfType <IfcRelAggregates>()
                                                                                .Where(item => item.RelatingObject != null && item.RelatingObject.Ref == ((Ifc4.IfcProject) this.Parent).Id).ToList();
                    if (ifcRelAggregatesCollection.Any())
                    {
                        foreach (IfcRelAggregates ifcRelAggregates in ifcRelAggregatesCollection)
                        {
                            var relatedObject = ifcRelAggregates.RelatedObjects.Items.FirstOrDefault(item => item.Ref == ifcBuildingElementProxy.Id);
                            if (relatedObject == null)
                            {
                                ifcRelAggregates.RelatedObjects.Items.Add(ifcBuildingElementProxy.RefInstance());
                            }
                        }
                    }
                    else
                    {
                        IfcRelAggregates relAggregatesProject = new IfcRelAggregates()
                        {
                            GlobalId = Document.GetNewGlobalId(),
                            // kann aktuell nur IfcProject sein
                            RelatingObject = new Ifc4.IfcProject()
                            {
                                Ref = ((Ifc4.IfcProject) this.Parent).Id
                            }
                        };
                        relAggregatesProject.RelatedObjects = new IfcRelAggregatesRelatedObjects();
                        relAggregatesProject.RelatedObjects.Items.Add(ifcBuildingElementProxy.RefInstance());
                        this.Document.IfcXmlDocument.Items.Add(relAggregatesProject);
                    }
                }
                // ------------------------------------------------------------------------------
                if (this.Parent.GetType() == typeof(Ifc4.CcFacility))
                {
                    if (((Ifc4.CcFacility) this.Parent).IfcObjectDefinition != null)
                    {
                        Ifc4.IfcRelAggregates ifcRelAggregates = ((Ifc4.CcFacility) this.Parent).GetIfcRelAggregates();
                        ifcRelAggregates.RelatedObjects.Items.Add(ifcBuildingElementProxy.RefInstance());
                    }
                    else if (((Ifc4.CcFacility) this.Parent).IfcSystem != null)
                    {
                        Ifc4.IfcRelAssignsToGroup ifcRelAssignsToGroup = ((Ifc4.CcFacility) this.Parent).GetIfcRelAssignsToGroup();
                        ifcRelAssignsToGroup.RelatedObjects.Items.Add(ifcBuildingElementProxy.RefInstance());
                    }
                }
                // ------------------------------------------------------------------------------
                // assign facility properties from clipboard facility
                facility.AssignPropertiesFromFacility(cloneFacility, oneToOneCopy);
                // ------------------------------------------------------------------------------

                return(facility);
            }
            catch (Exception exc)
            {
                return(default(T));
            }
            finally
            {
                BaseObject.EventsEnabled = enabledEventTypes;
            }
        }
コード例 #24
0
ファイル: CcFacilities.cs プロジェクト: sxh2000251/Ifc.NET
        public T AddNewSystem(Ifc4.IfcObjectDefinition relatingObject)
        {
            EventType enabledEventTypes = BaseObject.EventsEnabled;

            BaseObject.EventsEnabled = EventType.None;
            try
            {
                T facility = (T)AddNew();

                var ifcSystem = new IfcSystem();
                // ifcSystem.Parent = this;
                ifcSystem.Parent            = facility;
                ifcSystem.ParentIBaseObject = facility;
                facility.IfcSystem          = ifcSystem;

                var document = this.GetParent <Ifc4.Document>();
                if (document != null)
                {
                    Entity entity = ifcSystem as Entity;
                    if (entity != null)
                    {
                        entity.Id = document.GetNextSid();
                        document.IfcXmlDocument.Items.Add(entity);
                    }
                }
                // ------------------------------------------------------------------------------
                string Ref = String.Empty;
                if (relatingObject == null)
                {
                    Ref = document.Project.Id;
                }
                else
                {
                    Ref = relatingObject.Id;
                }


                //<IfcRelAggregates id="i84" GlobalId="3SVa7UPpXAux$wEdBKgcDI">
                //    <RelatingObject xsi:type="IfcProject" xsi:nil="true" ref="i100"/>
                //    <RelatedObjects>
                //        <IfcSite ref="i83" xsi:nil="true"/>
                //        <IfcSystem ref="i2501" xsi:nil="true"/>  <!-- 431 Lüftungsanlagen -->
                //        <IfcSystem ref="i2508" xsi:nil="true"/>  <!-- 461 Aufzugsanlagen -->
                //    </RelatedObjects>
                //</IfcRelAggregates>

                if (relatingObject != null)
                {
                    IEnumerable <IfcRelAggregates> ifcRelAggregatesCollection = this.Document.IfcXmlDocument.Items.OfType <IfcRelAggregates>().Where(item => item.RelatingObject != null && item.RelatingObject.Ref == Ref).ToList();
                    if (ifcRelAggregatesCollection.Any())
                    {
                        foreach (var ifcRelAggregates in ifcRelAggregatesCollection)
                        {
                            var relatedObject = ifcRelAggregates.RelatedObjects.Items.FirstOrDefault(item => item.Ref == ifcSystem.Id);
                            if (relatedObject == null)
                            {
                                ifcRelAggregates.RelatedObjects.Items.Add(ifcSystem.RefInstance());
                                // add only to one IfcRelAggregates - RelatedObjects List - RelatingObject xsi:type="IfcProject"
                                break;
                            }
                        }
                    }
                    else
                    {
                        var relAggregatesProject = new IfcRelAggregates()
                        {
                            GlobalId       = Document.GetNewGlobalId(),
                            RelatingObject = new Ifc4.IfcProject()
                            {
                                Ref = Ref
                            }
                        };
                        relAggregatesProject.RelatedObjects = new IfcRelAggregatesRelatedObjects();
                        relAggregatesProject.RelatedObjects.Items.Add(ifcSystem.RefInstance());
                        this.Document.IfcXmlDocument.Items.Add(relAggregatesProject);
                    }
                }
                return(facility);
            }
            catch (Exception exc)
            {
                return(default(T));
            }
            finally
            {
                BaseObject.EventsEnabled = enabledEventTypes;
            }
        }
コード例 #25
0
ファイル: BbProduct.cs プロジェクト: JackTing/ifctoolkit
        public void AddToHostObject(BbProduct hostObject)
        {
            HostObject = hostObject;
            var a = EarlyBindingInstanceModel.GetReferencedEntities(hostObject.IfcObject.EIN).Values;

            var b = (from x in a.OfType<IfcRelAggregates>()
                     where x.RelatingObject.EIN == hostObject.IfcObject.EIN
                     select x).ToList();

            switch (b.Count)
            {

                case 0:
                    IfcRelAggregates = new IfcRelAggregates
                    {
                        GlobalId = IfcGloballyUniqueId.NewGuid(),
                        OwnerHistory = hostObject.IfcObject.OwnerHistory,
                        RelatingObject = hostObject.IfcObject,
                        RelatedObjects = new List<IfcObjectDefinition>() { },
                    };
                    break;
                case 1:
                    IfcRelAggregates = b[0];
                    break;
                default:
                    throw new NotImplementedException();
            }
            var aa = GetType().GetProperty("IfcObject").GetValue(this, null) as IfcObject;

            IfcRelAggregates.RelatedObjects.Add(aa);
        }
コード例 #26
0
 protected BbFloor(BbBuilding building, IfcBuildingStorey floor, IfcRelAggregates ifcRelAggregates)
 {
     BbBuilding = building;
     IfcSpatialStructureElement = floor;
     IfcRelAggregates           = ifcRelAggregates;
 }
コード例 #27
0
        private IfcStair CreateIfcStair(IfcStore model, Stair stair)
        {
            //begin a transaction
            using (var trans = model.BeginTransaction("Create Stair"))
            {
                IfcStair stairToCreate = model.Instances.New <IfcStair>();
                stairToCreate.Name = " stair - Wall:UC305x305x97:" + 1500;


                IfcDirection extrusionDir = model.Instances.New <IfcDirection>();
                extrusionDir.SetXYZ(0, 0, -1);

                //Create a Definition shape to hold the geometry of the Stair 3D body
                IfcShapeRepresentation shape = IFCHelper.ShapeRepresentationCreate(model, "SweptSolid", "Body");

                for (int i = 0; i < stair.LstStep.Count; i++)
                {
                    IfcArbitraryClosedProfileDef stepProfile = IFCHelper.ArbitraryClosedProfileCreate(model, (stair.LstStep[i].Vertices /*.Select(v => v * 1000)*/).ToList());

                    IfcExtrudedAreaSolid body = IFCHelper.ProfileSweptSolidCreate(model, stair.Thickness, stepProfile, extrusionDir);

                    body.BodyPlacementSet(model, 0, 0, stair.IsUp ? stair.Thickness * i : stair.Thickness * -i);

                    shape.Items.Add(body);
                }



                //Create a Product Definition and add the model geometry to the wall
                IfcProductDefinitionShape prDefShape = model.Instances.New <IfcProductDefinitionShape>();
                prDefShape.Representations.Add(shape);

                IfcStairFlight flight = model.Instances.New <IfcStairFlight>();
                flight.Representation = prDefShape;

                IfcRelAggregates relAggregate = model.Instances.New <IfcRelAggregates>();
                relAggregate.RelatingObject = stairToCreate;
                relAggregate.RelatedObjects.Add(flight);

                //Create Local axes system and assign it to the column
                IfcCartesianPoint location3D = model.Instances.New <IfcCartesianPoint>();
                location3D.SetXYZ(0, 0, 0);

                //var uvColLongDir = MathHelper.UnitVectorPtFromPt1ToPt2(cadSlab.CenterPt, cadSlab.PtLengthDir);

                IfcDirection localXDir = model.Instances.New <IfcDirection>();
                localXDir.SetXYZ(1, 0, 0);

                IfcDirection localZDir = model.Instances.New <IfcDirection>();
                localZDir.SetXYZ(0, 0, 1);

                IfcAxis2Placement3D ax3D = IFCHelper.LocalAxesSystemCreate(model, location3D, localXDir, localZDir);

                //now place the slab into the model
                IfcLocalPlacement lp = IFCHelper.LocalPlacemetCreate(model, ax3D);
                flight.ObjectPlacement = lp;

                trans.Commit();
                return(stairToCreate);
            }
        }
コード例 #28
0
ファイル: IFCExtensions.cs プロジェクト: simonmoreau/elements
        /// <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);

            // Materials
            // foreach(var m in model.Materials.Values)
            // {
            //     var ifcMaterial = new IfcMaterial(m.Name);
            //     ifc.AddEntity(ifcMaterial);
            // }

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

            foreach (var e in model.Elements.Values)
            {
                try
                {
                    if (e is Wall)
                    {
                        var w       = (Wall)e;
                        var ifcWall = w.ToIfcWallStandardCase(context, ifc);
                        products.Add(ifcWall);
                    }

                    if (e is Beam)
                    {
                        var b       = (Beam)e;
                        var ifcBeam = b.ToIfcBeam(context, ifc);
                        products.Add(ifcBeam);
                    }
                }
                catch
                {
                    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));
        }