예제 #1
0
파일: Slab.cs 프로젝트: tsiddikee/IfcScript
        internal static void GenerateData(STPModelData md, IfcBuilding building, bool openings)
        {
            IfcMaterial         concrete         = new IfcMaterial(md, "Concrete", "", "");
            int                 thickness        = 200;
            IfcMaterialLayer    materialLayer    = new IfcMaterialLayer(md, concrete, thickness, false, "Core", "", "", 0);
            string              name             = thickness + "mm Concrete";
            IfcMaterialLayerSet materialLayerSet = new IfcMaterialLayerSet(md, materialLayer, name, "");

            materialLayerSet.Associates.GlobalId = "2l_enLhI93reVwnim9gXUq";
            md.NextObjectRecord = 300;
            IfcSlabType slabType = new IfcSlabType(md, new IfcElemTypeParams("0RSW$KKbzCZ9QaSm3GoEan", name, "", "", ""), materialLayerSet, null, IfcSlabTypeEnum.FLOOR);

            slabType.ObjectTypeOf.GlobalId = "3wwDcmW5T3HfafURQewdD0";
            PolyCurve polycurve = new PolyCurve();

            polycurve.Append(new Line(0, 0, 0, 1000, 0, 0));
            polycurve.Append(new Arc(new Point3d(1000, 0, 0), new Point3d(1400, 2000, 0), new Point3d(1000, 4000, 0)));
            polycurve.Append(new Line(1000, 4000, 0, 0, 4000, 0));
            polycurve.Append(new Arc(new Point3d(0, 4000, 0), new Point3d(-400, 2000, 0), new Point3d(0, 0, 0)));
            IfcSlabStandardCase slabStandardCase = new IfcSlabStandardCase(building, new IfcElemParams("1wAj$J2Az2V8wnBiVYd3bU", "", "", "", ""), slabType, polycurve, -200, true, null);

            slabStandardCase.Material.Associates.GlobalId = "3ESAzibgr9BvK9M75iV84w";
            if (openings)
            {
                IfcCircleProfileDef    cpd     = new IfcCircleProfileDef(md, IfcProfileTypeEnum.AREA, "100DIA", null, 50);
                IfcExtrudedAreaSolid   eas     = new IfcExtrudedAreaSolid(cpd, new IfcAxis2Placement3D(md, new Plane(new Point3d(100, 300, -200), Vector3d.XAxis, Vector3d.YAxis)), new IfcDirection(md, 0, 0, 1), thickness);
                IfcOpeningStandardCase opening = new IfcOpeningStandardCase(slabStandardCase, new IfcElemParams("15RSTHd8nFVQWMRE7og7sd", "Opening", "", "", ""), null, eas);
                opening.VoidsElement.GlobalId = "0gqEDsyEzFXvY$fc_rUxyO";
                IfcRectangleProfileDef rpd = new IfcRectangleProfileDef(md, IfcProfileTypeEnum.AREA, "RecessRectangle", null, 500, 1000);
                eas = new IfcExtrudedAreaSolid(rpd, new IfcAxis2Placement3D(md, new Plane(new Point3d(500, 1000, -50), Vector3d.XAxis, Vector3d.YAxis)), new IfcDirection(md, 0, 0, 1), 50);
                IfcOpeningElement recess = new IfcOpeningElement(slabStandardCase, new IfcElemParams("0w93HZ19H2D99zbAVNb4o2", "Recess", "", "", ""), eas, IfcOpeningElementTypeEnum.RECESS);
                recess.VoidsElement.GlobalId = "3iUkij4q1DmxlXuHzQVJaM";
            }
        }
예제 #2
0
파일: Slab.cs 프로젝트: mccune/IfcScript
		internal static void GenerateData(STPModelData md, IfcBuilding building,bool openings)
		{
			IfcMaterial concrete = new IfcMaterial(md, "Concrete", "", "");
			int thickness = 200;
			IfcMaterialLayer materialLayer = new IfcMaterialLayer(md, concrete, thickness, false, "Core", "", "", 0);
			string name = thickness + "mm Concrete";
			IfcMaterialLayerSet materialLayerSet = new IfcMaterialLayerSet( materialLayer, name, "");
			materialLayerSet.Associates.GlobalId = "2l_enLhI93reVwnim9gXUq";
			md.NextObjectRecord = 300;
			IfcSlabType slabType = new IfcSlabType(name, materialLayerSet, IfcSlabTypeEnum.FLOOR) { GlobalId = "0RSW$KKbzCZ9QaSm3GoEan" };
			slabType.ObjectTypeOf.GlobalId = "3wwDcmW5T3HfafURQewdD0";
			PolyCurve polycurve = new PolyCurve();
			polycurve.Append(new Line(0, 0, 0, 1000, 0, 0));
			polycurve.Append(new Arc(new Point3d(1000, 0, 0), new Point3d(1400, 2000, 0), new Point3d(1000, 4000, 0)));
			polycurve.Append(new Line(1000, 4000, 0, 0, 4000, 0));
			polycurve.Append(new Arc(new Point3d(0, 4000, 0), new Point3d(-400, 2000, 0), new Point3d(0, 0, 0)));
			IfcSlabStandardCase slabStandardCase = new IfcSlabStandardCase(building, slabType, polycurve, -200, true, null) { GlobalId = "1wAj$J2Az2V8wnBiVYd3bU" };
			slabStandardCase.Material.Associates.GlobalId = "3ESAzibgr9BvK9M75iV84w";
			if (openings)
			{
				IfcCircleProfileDef cpd = new IfcCircleProfileDef(md, "100DIA", 50);
				IfcExtrudedAreaSolid eas = new IfcExtrudedAreaSolid(cpd,new IfcAxis2Placement3D(md,new Plane(new Point3d(100,300,-200),Vector3d.XAxis,Vector3d.YAxis)),new IfcDirection(md,0,0,1),thickness);
				IfcOpeningStandardCase opening = new IfcOpeningStandardCase(slabStandardCase, null, eas) { GlobalId = "15RSTHd8nFVQWMRE7og7sd", Name = "Opening" };
				opening.VoidsElement.GlobalId = "0gqEDsyEzFXvY$fc_rUxyO";
				IfcRectangleProfileDef rpd = new IfcRectangleProfileDef(md, "RecessRectangle", 500, 1000);
				eas = new IfcExtrudedAreaSolid(rpd, new IfcAxis2Placement3D(md, new Plane(new Point3d(500, 1000, -50), Vector3d.XAxis, Vector3d.YAxis)), new IfcDirection(md, 0, 0, 1), 50);
				IfcOpeningElement recess = new IfcOpeningElement(slabStandardCase, eas, IfcOpeningElementTypeEnum.RECESS) { GlobalId = "0w93HZ19H2D99zbAVNb4o2", Name = "Recess" };
				recess.VoidsElement.GlobalId = "3iUkij4q1DmxlXuHzQVJaM";
			}
		}
예제 #3
0
        internal static void AttchOpening(this IfcElement element, IfcStore model, IfcOpeningElement opening)
        {
            IfcRelVoidsElement relVoids = model.Instances.New <IfcRelVoidsElement>();

            relVoids.RelatedOpeningElement   = opening;
            relVoids.RelatingBuildingElement = element;
        }
예제 #4
0
        public BbCutCope(
            BbElement hostElement,
            BbProfile profile,
            double length,
            double[] zAxis,
            double[] xAxis,
            double[] extrudeDirection,
            double[] position)
        {
            //ObjectLocalPlacement = new LocalPlacement3D(hostElement.ObjectLocalPlacement, new Position3D(position));

            /// from main piece
            BbPosition3D pos = BbPosition3D.Create(
                BbCoordinate3D.Create(position),
                BbDirection3D.Create(zAxis),
                BbDirection3D.Create(xAxis));

            ObjectBbLocalPlacement = BbLocalPlacement3D.Create(
                hostElement.ObjectBbLocalPlacement, pos);

            BbDirection3D exDir;

            if (Math.Round(extrudeDirection[0], 8) == 0.0 && Math.Round(extrudeDirection[0], 8) == 0 && Math.Round(extrudeDirection[0], 8) == 1)
            {
                exDir = BbHeaderSetting.Setting3D.ZAxis;
            }
            else
            {
                exDir = BbDirection3D.Create(extrudeDirection);
            }


            BbExtrudedGeometry bbExtrudedGeometry = BbExtrudedGeometry.Create(
                profile,
                BbHeaderSetting.Setting3D.DefaultBbPosition3D,
                exDir,
                length);

            _ifcOpeningElement = new IfcOpeningElement
            {
                GlobalId     = IfcGloballyUniqueId.NewGuid(),
                OwnerHistory = hostElement.IfcObject.OwnerHistory,
                // Name =
                // Description =
                ObjectType      = "Opening",
                ObjectPlacement = ObjectBbLocalPlacement.IfcLocalPlacement,
                Representation  = bbExtrudedGeometry.IfcProductDefinitionShape,
            };

            _ifcRelVoidsElement = new IfcRelVoidsElement
            {
                GlobalId                = IfcGloballyUniqueId.NewGuid(),
                OwnerHistory            = hostElement.IfcObject.OwnerHistory,
                Name                    = "Cope",
                RelatingBuildingElement = hostElement.IfcObject as IfcElement,
                RelatedOpeningElement   = _ifcOpeningElement,
            };
        }
예제 #5
0
        private static IfcOpeningElement ToIfc(this Opening opening, Guid id, IfcLocalPlacement localPlacement, IfcProductDefinitionShape shape)
        {
            var ifcOpening = new IfcOpeningElement(IfcGuid.ToIfcGuid(id),
                                                   null,
                                                   null,
                                                   null,
                                                   null,
                                                   localPlacement,
                                                   shape,
                                                   null,
                                                   IfcOpeningElementTypeEnum.OPENING);

            return(ifcOpening);
        }
예제 #6
0
        public BbCutCope(
            BbElement hostElement,
            double copeWidth,
            double copeDepth,
            double copeRadius,
            double[] position)
        {
            BbCopeProfile profile = BbCopeProfile.Create(copeWidth, copeDepth, copeRadius);

            var mainPart = hostElement as BbPiece;

            if (mainPart == null)
            {
                return;
            }

            BbPosition3D pos = BbPosition3D.Create(
                BbCoordinate3D.Create(position),
                BbHeaderSetting.Setting3D.XAxisMinus,
                BbHeaderSetting.Setting3D.ZAxis);

            ObjectBbLocalPlacement = BbLocalPlacement3D.Create(
                hostElement.ObjectBbLocalPlacement, pos);

            BbExtrudedGeometry bbExtrudedGeometry = BbExtrudedGeometry.Create(
                profile,
                BbHeaderSetting.Setting3D.DefaultBbPosition3D,
                BbHeaderSetting.Setting3D.ZAxis,
                mainPart.Profile.Width);

            _ifcOpeningElement = new IfcOpeningElement
            {
                GlobalId     = IfcGloballyUniqueId.NewGuid(),
                OwnerHistory = hostElement.IfcObject.OwnerHistory,
                // Name =
                // Description =
                ObjectType      = "Opening",
                ObjectPlacement = ObjectBbLocalPlacement.IfcLocalPlacement,
                Representation  = bbExtrudedGeometry.IfcProductDefinitionShape,
            };

            _ifcRelVoidsElement = new IfcRelVoidsElement
            {
                GlobalId                = IfcGloballyUniqueId.NewGuid(),
                OwnerHistory            = hostElement.IfcObject.OwnerHistory,
                Name                    = "Cope",
                RelatingBuildingElement = hostElement.IfcObject as IfcElement,
                RelatedOpeningElement   = _ifcOpeningElement,
            };
        }
예제 #7
0
        public BbCutCope(
            BbElement hostElement,
            double copeWidth,
            double copeDepth,
            double copeRadius,
            double[] position)
        {
            BbCopeProfile profile = BbCopeProfile.Create(copeWidth, copeDepth, copeRadius);

            var mainPart = hostElement as BbPiece;
            if (mainPart == null)
                return;

            BbPosition3D pos = BbPosition3D.Create(
                BbCoordinate3D.Create(position),
                BbHeaderSetting.Setting3D.XAxisMinus,
                BbHeaderSetting.Setting3D.ZAxis);

            ObjectBbLocalPlacement = BbLocalPlacement3D.Create(
                hostElement.ObjectBbLocalPlacement, pos);

            BbExtrudedGeometry bbExtrudedGeometry = BbExtrudedGeometry.Create(
                profile,
                BbHeaderSetting.Setting3D.DefaultBbPosition3D,
                BbHeaderSetting.Setting3D.ZAxis,
                mainPart.Profile.Width);

            _ifcOpeningElement = new IfcOpeningElement
            {
                GlobalId = IfcGloballyUniqueId.NewGuid(),
                OwnerHistory = hostElement.IfcObject.OwnerHistory,
                // Name =
                // Description =
                ObjectType = "Opening",
                ObjectPlacement = ObjectBbLocalPlacement.IfcLocalPlacement,
                Representation = bbExtrudedGeometry.IfcProductDefinitionShape,
            };

            _ifcRelVoidsElement = new IfcRelVoidsElement
            {
                GlobalId = IfcGloballyUniqueId.NewGuid(),
                OwnerHistory = hostElement.IfcObject.OwnerHistory,
                Name = "Cope",
                RelatingBuildingElement = hostElement.IfcObject as IfcElement,
                RelatedOpeningElement = _ifcOpeningElement,
            };
        }
예제 #8
0
        /// <summary>
        /// Convert an IfcOpening to an Opening.
        /// </summary>
        /// <param name="opening"></param>
        public static Opening ToOpening(this IfcOpeningElement opening)
        {
            var openingTransform = opening.ObjectPlacement.ToTransform();
            var s = opening.RepresentationsOfType <IfcExtrudedAreaSolid>().FirstOrDefault();

            if (s != null)
            {
                var solidTransform = s.Position.ToTransform();
                solidTransform.Concatenate(openingTransform);
                var profile = (Polygon)s.SweptArea.ToICurve();
                // var newOpening = new Opening(profile, (IfcLengthMeasure)s.Depth, solidTransform);
                var newOpening = new Opening(profile);
                newOpening.Name = opening.Name;
                return(newOpening);
            }
            return(null);
        }
        private IEnumerable <IfcProduct> GetProductsInProduct(IfcProduct prod)
        {
            //decomposes is a supertype of IfcRelAggregates, IfcRelNests
            IEnumerable <IfcRelDecomposes> decompRels = _model.Instances.Where <IfcRelDecomposes>(r => r.RelatingObject == prod);

            foreach (var item in decompRels)
            {
                foreach (var p in item.RelatedObjects)
                {
                    IfcProduct product = p as IfcProduct;
                    yield return(product);
                }
            }

            //fills
            IfcOpeningElement opening = prod as IfcOpeningElement;

            if (opening != null)
            {
                IEnumerable <IfcRelFillsElement> fillsRels = _model.Instances.Where <IfcRelFillsElement>(r => r.RelatingOpeningElement == opening);
                foreach (var rel in fillsRels)
                {
                    yield return(rel.RelatedBuildingElement);
                }
            }

            //voids
            IfcElement element = prod as IfcElement;

            if (element != null)
            {
                IEnumerable <IfcRelVoidsElement> voidsRels = _model.Instances.Where <IfcRelVoidsElement>(r => r.RelatingBuildingElement == element);
                foreach (var rel in voidsRels)
                {
                    yield return(rel.RelatedOpeningElement);

                    //go one level deeper to the elements filling the opening because these are spatialy in the original product as well
                    foreach (var e in GetFillingProducts(rel.RelatedOpeningElement))
                    {
                        yield return(e);
                    }
                }
            }
        }
예제 #10
0
        private void CountDoor(IModel model)
        {
            List <IfcDoor> doors = new List <IfcDoor>();
            IEnumerable <IfcRelContainedInSpatialStructure> relations = model.
                                                                        Instances.Where <IfcRelContainedInSpatialStructure>(rel => rel.RelatingStructure.Name == "311"
                                                                                                                            );
            List <IfcWall> walls = new List <IfcWall>();

            foreach (IfcRelContainedInSpatialStructure relation in relations)
            {
                if (relation != null)
                {
                    IEnumerable <IfcWall> w = relation.RelatedElements.OfType <IfcWall>();
                    walls.AddRange(w);
                }
            }

            foreach (IfcWall wall in walls)
            {
                IEnumerable <IfcRelVoidsElement> relsVoid = model.Instances.
                                                            Where <IfcRelVoidsElement>(rel => rel.RelatingBuildingElement == wall);
                foreach (var relation in relsVoid)
                {
                    IfcOpeningElement opening = relation.RelatedOpeningElement as IfcOpeningElement;
                    if (opening != null)
                    {
                        IEnumerable <IfcRelFillsElement> relsFill = model.Instances.
                                                                    Where <IfcRelFillsElement>(r =>
                                                                                               r.RelatingOpeningElement == opening &&
                                                                                               r.RelatedBuildingElement is IfcDoor
                                                                                               );
                        foreach (IfcRelFillsElement relFill in relsFill)
                        {
                            doors.Add(relFill.RelatedBuildingElement as IfcDoor);
                        }
                    }
                }
            }
        }
예제 #11
0
        internal static Opening ToOpening(this IfcOpeningElement opening)
        {
            var openingTransform = opening.ObjectPlacement.ToTransform();
            var s = opening.RepresentationsOfType <IfcExtrudedAreaSolid>().FirstOrDefault();

            if (s != null)
            {
                var solidTransform = s.Position.ToTransform();
                solidTransform.Concatenate(openingTransform);
                var profile = (Polygon)s.SweptArea.ToCurve();
                // Console.WriteLine($"Opening profile:\n{profile.ToString()}\n");

                var newOpening = new Opening(profile,
                                             (IfcLengthMeasure)s.Depth,
                                             solidTransform,
                                             null,
                                             false,
                                             IfcGuid.FromIfcGUID(opening.GlobalId));
                return(newOpening);
            }
            return(null);
        }
        public override void Parse(int propIndex, IPropertyValue value, int[] nestedIndex)
        {
            switch (propIndex)
            {
            case 0:
            case 1:
            case 2:
            case 3:
                base.Parse(propIndex, value, nestedIndex);
                return;

            case 4:
                _relatingOpeningElement = (IfcOpeningElement)(value.EntityVal);
                return;

            case 5:
                _relatedBuildingElement = (IfcElement)(value.EntityVal);
                return;

            default:
                throw new XbimParserException(string.Format("Attribute index {0} is out of range for {1}", propIndex + 1, GetType().Name.ToUpper()));
            }
        }
예제 #13
0
        private static IfcOpeningElement ToIfcOpeningElement(this Opening opening, IfcRepresentationContext context, Document doc, IfcObjectPlacement parent)
        {
            // var sweptArea = opening.Profile.Perimeter.ToIfcArbitraryClosedProfileDef(doc);
            // We use the Z extrude direction because the direction is
            // relative to the local placement, which is a transform at the
            // beam's end with the Z axis pointing along the direction.

            // var extrudeDirection = opening.ExtrudeDirection.ToIfcDirection();
            // var position = new Transform().ToIfcAxis2Placement3D(doc);
            // var solid = new IfcExtrudedAreaSolid(sweptArea, position,
            //     extrudeDirection, new IfcPositiveLengthMeasure(opening.ExtrudeDepth));

            var solid          = opening.ToIfcExtrudedAreaSolid(new Transform(), doc);
            var localPlacement = new Transform().ToIfcLocalPlacement(doc, parent);

            var shape = new IfcShapeRepresentation(context, "Body", "SweptSolid", new List <IfcRepresentationItem> {
                solid
            });
            var productRep = new IfcProductDefinitionShape(new List <IfcRepresentation> {
                shape
            });

            var ifcOpening = new IfcOpeningElement(IfcGuid.ToIfcGuid(Guid.NewGuid()), null, null, null, null, localPlacement, productRep, null);

            // doc.AddEntity(sweptArea);
            // doc.AddEntity(extrudeDirection);
            // doc.AddEntity(position);
            // doc.AddEntity(repItem);

            doc.AddEntity(solid);
            doc.AddEntity(localPlacement);
            doc.AddEntity(shape);
            doc.AddEntity(productRep);

            return(ifcOpening);
        }
예제 #14
0
        public XbimCreateBuilding(Building cadBuilding, string pathToSave)
        {
            using (var model = CreateandInitModel("Demo1"))
            {
                List <IFloor> lstSortedFloors = cadBuilding.Floors.OrderByDescending(f => f.Level).ToList();

                if (model != null)
                {
                    IfcBuilding building = CreateBuilding(model, "Default Building");

                    for (int i = 0; i < lstSortedFloors.Count; i++)
                    {
                        Floor floor = lstSortedFloors[i] as Floor;
                        if (floor != null)
                        {
                            if (i + 1 == lstSortedFloors.Count)
                            {
                                break;
                            }
                            double lvlDifference = lstSortedFloors[i].Level - lstSortedFloors[i + 1].Level;
                            double wallHeight    = lvlDifference - floor.Slabs[0].Thickness;
                            foreach (Wall cadWall in floor.Walls)
                            {
                                IfcWallStandardCase wall = CreateIfcWall(model, cadWall, wallHeight);

                                if (wall != null)
                                {
                                    AddPropertiesToWall(model, wall);
                                }
                                using (var txn = model.BeginTransaction("Add Wall"))
                                {
                                    building.AddElement(wall);
                                    txn.Commit();
                                }
                            }

                            foreach (RectColumn cadCol in floor.Columns)
                            {
                                IfcColumn column = CreateIfcColumn(model, cadCol, lvlDifference);

                                using (var txn = model.BeginTransaction("Add column"))
                                {
                                    building.AddElement(column);
                                    txn.Commit();
                                }
                            }

                            foreach (Slab cadSlab in floor.Slabs)
                            {
                                slab = CreateIfcSlab(model, cadSlab);
                                using (var trans = model.BeginTransaction("Add Slab"))
                                {
                                    building.AddElement(slab);
                                    trans.Commit();
                                }
                            }



                            IfcOpeningElement opening = null;
                            foreach (var cadOpening in floor.Openings)
                            {
                                opening = CreateIfcOpening(model, cadOpening, floor.Slabs[0].Thickness);
                                using (var trans = model.BeginTransaction("Add Opening"))
                                {
                                    building.AddElement(opening);
                                    //attach opening
                                    slab.AttchOpening(model, opening);
                                    trans.Commit();
                                }
                            }

                            //Create stairs
                            foreach (Stair cadStair in floor.Stairs)
                            {
                                IfcStair stair = CreateIfcStair(model, cadStair);

                                using (var txn = model.BeginTransaction("Add Stair"))
                                {
                                    building.AddElement(stair);
                                    txn.Commit();
                                }
                            }
                            foreach (LinearPath cadLanding in floor.Landings)
                            {
                                IfcSlab landing = CreateIfcLanding(model, cadLanding, DefaultValues.SlabThinkess);

                                using (var txn = model.BeginTransaction("Add Landing"))
                                {
                                    building.AddElement(landing);
                                    txn.Commit();
                                }
                            }
                        }
                        else
                        {
                            Foundation foundation = lstSortedFloors[i] as Foundation;
                            foreach (PCRectFooting cadFooting in foundation.PCFooting)
                            {
                                IfcFooting footing = CreateIfcFooting(model, cadFooting);

                                using (var txn = model.BeginTransaction("Add Footing"))
                                {
                                    building.AddElement(footing);
                                    txn.Commit();
                                }
                            }
                            foreach (RCRectFooting cadFooting in foundation.RCFooting)
                            {
                                IfcFooting footing = CreateIfcFooting(model, cadFooting);

                                using (var txn = model.BeginTransaction("Add Footing"))
                                {
                                    building.AddElement(footing);
                                    txn.Commit();
                                }
                            }
                            foreach (SlopedSlab cadRamp in foundation.Ramps)
                            {
                                IfcSlab ramp = CreateIfcSlopedSlab(model, cadRamp);

                                using (var txn = model.BeginTransaction("Add Ramp"))
                                {
                                    building.AddElement(ramp);
                                    txn.Commit();
                                }
                            }
                        }
                    }

                    try
                    {
                        Console.WriteLine("Standard Wall successfully created....");
                        //write the Ifc File
                        model.SaveAs(pathToSave + @"\Demo1.ifc", IfcStorageType.Ifc);
                        Console.WriteLine("WallIfc4.ifc has been successfully written");
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Failed to save!");
                        Console.WriteLine(e.Message);
                    }
                }
            }
        }
예제 #15
0
        internal static void GenerateInstance(IfcBuilding building, bool openings)
        {
            DatabaseIfc db       = building.Database;
            IfcMaterial concrete = new IfcMaterial(db, "Concrete")
            {
                Category = "Concrete"
            };
            int thickness = 200;
            IfcMaterialLayer    materialLayer    = new IfcMaterialLayer(concrete, thickness, "Core");
            string              name             = thickness + "mm Concrete";
            IfcMaterialLayerSet materialLayerSet = new IfcMaterialLayerSet(materialLayer, name);

            db.NextObjectRecord = 300;
            IfcSlabType slabType = new IfcSlabType(name, materialLayerSet, IfcSlabTypeEnum.FLOOR);

            db.Context.AddDeclared(slabType);
            List <Coord2d> points = new List <Coord2d>()
            {
                new Coord2d(0, 0), new Coord2d(1000, 0), new Coord2d(1400, 2000), new Coord2d(1000, 4000), new Coord2d(0, 4000), new Coord2d(-400, 2000)
            };

            List <IfcSegmentIndexSelect> segments = new List <IfcSegmentIndexSelect>();

            segments.Add(new IfcLineIndex(1, 2));
            segments.Add(new IfcArcIndex(2, 3, 4));
            segments.Add(new IfcLineIndex(4, 5));
            segments.Add(new IfcArcIndex(5, 6, 1));
            IfcBoundedCurve          boundedCurve  = IfcBoundedCurve.Generate(db, points, segments);
            IfcMaterialLayerSetUsage layerSetUsage = new IfcMaterialLayerSetUsage(materialLayerSet, IfcLayerSetDirectionEnum.AXIS3, IfcDirectionSenseEnum.NEGATIVE, 0);
            IfcSlab slabStandardCase = new IfcSlabStandardCase(building, layerSetUsage, new IfcAxis2Placement3D(new IfcCartesianPoint(db, 0, 0, 0)), new IfcArbitraryClosedProfileDef("Slab Perimeter", boundedCurve))
            {
                RelatingType = slabType
            };

            slabStandardCase.RelatingType = slabType;
            if (openings)
            {
                IfcCircleProfileDef    cpd     = new IfcCircleProfileDef(db, "100DIA", 50);
                IfcExtrudedAreaSolid   eas     = new IfcExtrudedAreaSolid(cpd, new IfcAxis2Placement3D(new IfcCartesianPoint(db, 100, 300, -200)), new IfcDirection(db, 0, 0, 1), thickness);
                IfcOpeningStandardCase opening = new IfcOpeningStandardCase(slabStandardCase, null, eas)
                {
                    Name = "Opening"
                };
                IfcRectangleProfileDef rpd = new IfcRectangleProfileDef(db, "RecessRectangle", 500, 1000);
                eas = new IfcExtrudedAreaSolid(rpd, new IfcAxis2Placement3D(new IfcCartesianPoint(db, 500, 1000, -50)), new IfcDirection(db, 0, 0, 1), 50);
                IfcOpeningElement recess = new IfcOpeningElement(slabStandardCase, null, new IfcProductDefinitionShape(new IfcShapeRepresentation(eas)))
                {
                    Name = "Recess", PredefinedType = IfcOpeningElementTypeEnum.RECESS
                };

                //Unique ids assigned to generate constant IfcScript  sample files, remove otherwise
                opening.GlobalId = "15RSTHd8nFVQWMRE7og7sd";
                opening.VoidsElement.GlobalId = "0gqEDsyEzFXvY$fc_rUxyO";
                recess.GlobalId = "0w93HZ19H2D99zbAVNb4o2";
                recess.VoidsElement.GlobalId = "3iUkij4q1DmxlXuHzQVJaM";
            }

            //Unique ids assigned to generate constant IfcScript  sample files, remove otherwise
            slabType.GlobalId                    = "0RSW$KKbzCZ9QaSm3GoEan";
            slabStandardCase.GlobalId            = "1wAj$J2Az2V8wnBiVYd3bU";
            materialLayerSet.Associates.GlobalId = "2l_enLhI93reVwnim9gXUq";
            slabType.ObjectTypeOf.GlobalId       = "3wwDcmW5T3HfafURQewdD0";
            slabStandardCase.MaterialSelect.Associates.GlobalId = "3ESAzibgr9BvK9M75iV84w";
        }
예제 #16
0
        BbCutCope(
            BbElement hostElement,
            double copeWidth,
            double copeDepth,
            double copeRadius,
            SemCopeLocation copeLocation)
        {
            BbCopeProfile profile = BbCopeProfile.Create(copeWidth, copeDepth, copeRadius, copeLocation);

            var mainPart = hostElement as BbPiece;
            if (mainPart == null)
                return;

            BbPosition3D pos;

            switch (copeLocation)
            {

                case SemCopeLocation.BottomLeft:
                    pos = BbPosition3D.Create(
                        BbCoordinate3D.Create(new double[] {
                    mainPart.Profile.Width / 2,
                    -mainPart.Profile.Depth / 2,
                    0
                }),
                        BbHeaderSetting.Setting3D.XAxisMinus,
                        BbHeaderSetting.Setting3D.ZAxis);
                    break;
                case SemCopeLocation.BottomRight:
                    pos = BbPosition3D.Create(
                        BbCoordinate3D.Create(new double[] {
                    mainPart.Profile.Width / 2,
                    - mainPart.Profile.Depth / 2,
                    mainPart.Length
                }),
                        BbHeaderSetting.Setting3D.XAxisMinus,
                        BbHeaderSetting.Setting3D.ZAxis);
                    break;
                case SemCopeLocation.TopRight:
                    pos = BbPosition3D.Create(
                        BbCoordinate3D.Create(new double[] {
                    mainPart.Profile.Width / 2,
                    mainPart.Profile.Depth / 2,
                    mainPart.Length
                }),
                        BbHeaderSetting.Setting3D.XAxisMinus,
                        BbHeaderSetting.Setting3D.ZAxis);
                    break;
                default: // TopLeft
                    pos = BbPosition3D.Create(
                        BbCoordinate3D.Create(new double[] {
                    mainPart.Profile.Width / 2,
                    mainPart.Profile.Depth / 2,
                    0
                }),
                        BbHeaderSetting.Setting3D.XAxisMinus,
                        BbHeaderSetting.Setting3D.ZAxis);
                    break;
            }

            ObjectBbLocalPlacement = BbLocalPlacement3D.Create(
                hostElement.ObjectBbLocalPlacement, pos);

            BbExtrudedGeometry bbExtrudedGeometry = BbExtrudedGeometry.Create(
                profile,
                BbHeaderSetting.Setting3D.DefaultBbPosition3D,
                BbHeaderSetting.Setting3D.ZAxis,
                mainPart.Profile.Width);

            _ifcOpeningElement = new IfcOpeningElement
            {
                GlobalId = IfcGloballyUniqueId.NewGuid(),
                OwnerHistory = hostElement.IfcObject.OwnerHistory,
                // Name =
                // Description =
                ObjectType = "Opening",
                ObjectPlacement = ObjectBbLocalPlacement.IfcLocalPlacement,
                Representation = bbExtrudedGeometry.IfcProductDefinitionShape,
            };

            _ifcRelVoidsElement = new IfcRelVoidsElement
            {
                GlobalId = IfcGloballyUniqueId.NewGuid(),
                OwnerHistory = hostElement.IfcObject.OwnerHistory,
                Name = "Cope",
                RelatingBuildingElement = hostElement.IfcObject as IfcElement,
                RelatedOpeningElement = _ifcOpeningElement,
            };
        }
예제 #17
0
        public BbCutCope(
            BbElement hostElement,
            BbProfile profile,
            double length,
            double[] zAxis,
            double[] xAxis,
            double[] extrudeDirection,
            double[] position)
        {
            //ObjectLocalPlacement = new LocalPlacement3D(hostElement.ObjectLocalPlacement, new Position3D(position));

            /// from main piece
            BbPosition3D pos = BbPosition3D.Create(
                BbCoordinate3D.Create(position),
                BbDirection3D.Create(zAxis),
                BbDirection3D.Create(xAxis));

            ObjectBbLocalPlacement = BbLocalPlacement3D.Create(
                hostElement.ObjectBbLocalPlacement, pos);

            BbDirection3D exDir;

            if (Math.Round(extrudeDirection[0], 8) == 0.0 && Math.Round(extrudeDirection[0], 8) == 0 && Math.Round(extrudeDirection[0], 8) == 1)
            {
                exDir = BbHeaderSetting.Setting3D.ZAxis;
            }
            else
            {
                exDir = BbDirection3D.Create(extrudeDirection);
            }

            BbExtrudedGeometry bbExtrudedGeometry = BbExtrudedGeometry.Create(
                profile,
                BbHeaderSetting.Setting3D.DefaultBbPosition3D,
                exDir,
                length);

            _ifcOpeningElement = new IfcOpeningElement
            {
                GlobalId = IfcGloballyUniqueId.NewGuid(),
                OwnerHistory = hostElement.IfcObject.OwnerHistory,
                // Name =
                // Description =
                ObjectType = "Opening",
                ObjectPlacement = ObjectBbLocalPlacement.IfcLocalPlacement,
                Representation = bbExtrudedGeometry.IfcProductDefinitionShape,
            };

            _ifcRelVoidsElement = new IfcRelVoidsElement
            {
                GlobalId = IfcGloballyUniqueId.NewGuid(),
                OwnerHistory = hostElement.IfcObject.OwnerHistory,
                Name = "Cope",
                RelatingBuildingElement = hostElement.IfcObject as IfcElement,
                RelatedOpeningElement = _ifcOpeningElement,
            };
        }
예제 #18
0
        BbSkewedEnd(
            BbElement hostElement,
            BbPosition3D pos)
        {
            var mainPart = hostElement as BbPiece;
            if (mainPart == null)
                return;

            var width = mainPart.Length > mainPart.Profile.Width ? mainPart.Length : mainPart.Profile.Width;
            width = width * 100;
            var depth = mainPart.Length > mainPart.Profile.Depth ? mainPart.Length : mainPart.Profile.Depth;
            depth = depth* 100;
            var profile = BbNamedRectangleProfile.Create(width, depth);

            ObjectBbLocalPlacement = BbLocalPlacement3D.Create(
                hostElement.ObjectBbLocalPlacement, pos);

            //Direction3D exDir = Direction3D.Create(new[] {pos.Axis.X, pos.Axis.Y, pos.Axis.Z});

            BbExtrudedGeometry bbExtrudedGeometry = BbExtrudedGeometry.Create(
                profile,
                BbHeaderSetting.Setting3D.DefaultBbPosition3D,
                BbHeaderSetting.Setting3D.ZAxis,
                mainPart.Length);

            //IfcHalfSpaceSolid ifcHalfSpaceSolid = new IfcHalfSpaceSolid
            //    {
            //        BaseSurface = new IfcPlane
            //            {
            //                Position = pos.IfcAxis2Placement3D,
            //            },
            //            AgreementFlag = true,

            //    };

            //IfcShapeRepresentation ifcShapeRepresentation = new IfcShapeRepresentation
            //{
            //    ContextOfItems = HeaderSetting.Setting3D.GeometricRepresentationContext,
            //    RepresentationIdentifier = "Body",
            //    RepresentationType = "SweptSolid",
            //    //RepresentationIdentifier = "Body",
            //    //RepresentationType = "SolidModel",
            //    Items = new List<IfcRepresentationItem>(),
            //};
            //ifcShapeRepresentation.Items.Add(ifcHalfSpaceSolid);

            //IfcProductDefinitionShape ifcProductDefinitionShape = new IfcProductDefinitionShape
            //{
            //    // Name=
            //    // Description =
            //    Representations = new List<IfcRepresentation>(),
            //};
            //ifcProductDefinitionShape.Representations.Add(ifcShapeRepresentation);

            _ifcOpeningElement = new IfcOpeningElement
                {
                    GlobalId = IfcGloballyUniqueId.NewGuid(),
                    OwnerHistory = hostElement.IfcObject.OwnerHistory,
                    // Name =
                    // Description =
                    ObjectType = "Opening",
                    ObjectPlacement = ObjectBbLocalPlacement.IfcLocalPlacement,
                    Representation = bbExtrudedGeometry.IfcProductDefinitionShape,
                    //Representation = ifcProductDefinitionShape,
                };

            _ifcRelVoidsElement = new IfcRelVoidsElement
                {
                    GlobalId = IfcGloballyUniqueId.NewGuid(),
                    OwnerHistory = hostElement.IfcObject.OwnerHistory,
                    Name = "Skewed End",
                    RelatingBuildingElement = hostElement.IfcObject as IfcElement,
                    RelatedOpeningElement = _ifcOpeningElement,
                };
        }
예제 #19
0
        BbCutCope(
            BbElement hostElement,
            double copeWidth,
            double copeDepth,
            double copeRadius,
            SemCopeLocation copeLocation)
        {
            BbCopeProfile profile = BbCopeProfile.Create(copeWidth, copeDepth, copeRadius, copeLocation);

            var mainPart = hostElement as BbPiece;

            if (mainPart == null)
            {
                return;
            }

            BbPosition3D pos;

            switch (copeLocation)
            {
            case SemCopeLocation.BottomLeft:
                pos = BbPosition3D.Create(
                    BbCoordinate3D.Create(new double[] {
                    mainPart.Profile.Width / 2,
                    -mainPart.Profile.Depth / 2,
                    0
                }),
                    BbHeaderSetting.Setting3D.XAxisMinus,
                    BbHeaderSetting.Setting3D.ZAxis);
                break;

            case SemCopeLocation.BottomRight:
                pos = BbPosition3D.Create(
                    BbCoordinate3D.Create(new double[] {
                    mainPart.Profile.Width / 2,
                    -mainPart.Profile.Depth / 2,
                    mainPart.Length
                }),
                    BbHeaderSetting.Setting3D.XAxisMinus,
                    BbHeaderSetting.Setting3D.ZAxis);
                break;

            case SemCopeLocation.TopRight:
                pos = BbPosition3D.Create(
                    BbCoordinate3D.Create(new double[] {
                    mainPart.Profile.Width / 2,
                    mainPart.Profile.Depth / 2,
                    mainPart.Length
                }),
                    BbHeaderSetting.Setting3D.XAxisMinus,
                    BbHeaderSetting.Setting3D.ZAxis);
                break;

            default:     // TopLeft
                pos = BbPosition3D.Create(
                    BbCoordinate3D.Create(new double[] {
                    mainPart.Profile.Width / 2,
                    mainPart.Profile.Depth / 2,
                    0
                }),
                    BbHeaderSetting.Setting3D.XAxisMinus,
                    BbHeaderSetting.Setting3D.ZAxis);
                break;
            }

            ObjectBbLocalPlacement = BbLocalPlacement3D.Create(
                hostElement.ObjectBbLocalPlacement, pos);

            BbExtrudedGeometry bbExtrudedGeometry = BbExtrudedGeometry.Create(
                profile,
                BbHeaderSetting.Setting3D.DefaultBbPosition3D,
                BbHeaderSetting.Setting3D.ZAxis,
                mainPart.Profile.Width);

            _ifcOpeningElement = new IfcOpeningElement
            {
                GlobalId     = IfcGloballyUniqueId.NewGuid(),
                OwnerHistory = hostElement.IfcObject.OwnerHistory,
                // Name =
                // Description =
                ObjectType      = "Opening",
                ObjectPlacement = ObjectBbLocalPlacement.IfcLocalPlacement,
                Representation  = bbExtrudedGeometry.IfcProductDefinitionShape,
            };

            _ifcRelVoidsElement = new IfcRelVoidsElement
            {
                GlobalId                = IfcGloballyUniqueId.NewGuid(),
                OwnerHistory            = hostElement.IfcObject.OwnerHistory,
                Name                    = "Cope",
                RelatingBuildingElement = hostElement.IfcObject as IfcElement,
                RelatedOpeningElement   = _ifcOpeningElement,
            };
        }
예제 #20
0
        protected BbOpening(
            BbElement hostElement,
            BbCoordinate2D position,
            BbProfile profile,
            SemHoleLocation location,
            bool through,
            string type
            )
        {
            var mainPart = hostElement as BbPiece;
            if (mainPart == null)
                return;

            double thickness;
            BbPosition3D pos;

            // x direction follows extrusion direction
            // extrude origin  projected to bottom or left becomes the origin

            switch (location)
            {

                case SemHoleLocation.Left:
                    pos = BbPosition3D.Create(
                        BbCoordinate3D.Create(
                            -(mainPart.Profile.Width / 2),
                            position.Y,
                            position.X),
                        BbHeaderSetting.Setting3D.XAxis,
                        BbHeaderSetting.Setting3D.ZAxis);
                    if (through)
                        thickness = mainPart.Profile.Width;
                    else
                        thickness = mainPart.Profile.Width / 2;
                    break;
                case SemHoleLocation.Right:
                    pos = BbPosition3D.Create(
                        BbCoordinate3D.Create(
                            (mainPart.Profile.Width / 2),
                            position.Y,
                            position.X),
                        BbHeaderSetting.Setting3D.XAxisMinus,
                        BbHeaderSetting.Setting3D.ZAxis);
                    if (through)
                        thickness = mainPart.Profile.Width;
                    else
                        thickness = mainPart.Profile.Width / 2;
                    break;
                case SemHoleLocation.Web:
                    if (through)
                    {
                        pos = BbPosition3D.Create(
                            BbCoordinate3D.Create(
                                (mainPart.Profile.Width / 2),
                                position.Y,
                                position.X
                                ),
                            BbHeaderSetting.Setting3D.XAxisMinus,
                            BbHeaderSetting.Setting3D.ZAxis);
                        thickness = mainPart.Profile.Width;
                    }
                    else
                    {
                        pos = BbPosition3D.Create(
                            BbCoordinate3D.Create(
                                (mainPart.Profile.Width / 4),
                                position.Y,
                                position.X
                                ),
                            BbHeaderSetting.Setting3D.XAxisMinus,
                            BbHeaderSetting.Setting3D.ZAxis);
                        thickness = mainPart.Profile.Width / 2;
                    }
                    break;

                case SemHoleLocation.Bottom:
                    pos = BbPosition3D.Create(
                        BbCoordinate3D.Create(
                            position.Y,
                            -(mainPart.Profile.Depth / 2),
                            position.X
                            ),
                        BbHeaderSetting.Setting3D.YAxis,
                        BbHeaderSetting.Setting3D.ZAxis);
                    if (through)
                        thickness = mainPart.Profile.Depth;
                    else
                        thickness = mainPart.Profile.Depth / 2;
                    break;
                case SemHoleLocation.Top:
                default:
                    pos = BbPosition3D.Create(
                        BbCoordinate3D.Create(
                            position.Y,
                            (mainPart.Profile.Depth / 2),
                            position.X
                            ),
                        BbHeaderSetting.Setting3D.YAxisMinus,
                        BbHeaderSetting.Setting3D.ZAxis);
                    if (through)
                        thickness = mainPart.Profile.Depth;
                    else
                        thickness = mainPart.Profile.Depth / 2;
                    break;
            }

            ObjectBbLocalPlacement = BbLocalPlacement3D.Create(
                hostElement.ObjectBbLocalPlacement, pos);

            BbExtrudedGeometry bbExtrudedGeometry = BbExtrudedGeometry.Create(
                profile,
                BbHeaderSetting.Setting3D.DefaultBbPosition3D,
                BbHeaderSetting.Setting3D.ZAxis,
                thickness);

            _ifcOpeningElement = new IfcOpeningElement
                {
                    GlobalId = IfcGloballyUniqueId.NewGuid(),
                    OwnerHistory = hostElement.IfcObject.OwnerHistory,
                    // Name =
                    // Description =
                    ObjectType = "Opening",
                    ObjectPlacement = ObjectBbLocalPlacement.IfcLocalPlacement,
                    Representation = bbExtrudedGeometry.IfcProductDefinitionShape,
                };

            _ifcRelVoidsElement = new IfcRelVoidsElement
                {
                    GlobalId = IfcGloballyUniqueId.NewGuid(),
                    OwnerHistory = hostElement.IfcObject.OwnerHistory,
                    Name = type,
                    RelatingBuildingElement = hostElement.IfcObject as IfcElement,
                    RelatedOpeningElement = _ifcOpeningElement,
                };
        }
예제 #21
0
        protected BbOpening(
            BbElement hostElement,
            BbCoordinate2D position,
            BbProfile profile,
            SemHoleLocation location,
            bool through,
            string type
            )
        {
            var mainPart = hostElement as BbPiece;

            if (mainPart == null)
            {
                return;
            }


            double       thickness;
            BbPosition3D pos;

            // x direction follows extrusion direction
            // extrude origin  projected to bottom or left becomes the origin

            switch (location)
            {
            case SemHoleLocation.Left:
                pos = BbPosition3D.Create(
                    BbCoordinate3D.Create(
                        -(mainPart.Profile.Width / 2),
                        position.Y,
                        position.X),
                    BbHeaderSetting.Setting3D.XAxis,
                    BbHeaderSetting.Setting3D.ZAxis);
                if (through)
                {
                    thickness = mainPart.Profile.Width;
                }
                else
                {
                    thickness = mainPart.Profile.Width / 2;
                }
                break;

            case SemHoleLocation.Right:
                pos = BbPosition3D.Create(
                    BbCoordinate3D.Create(
                        (mainPart.Profile.Width / 2),
                        position.Y,
                        position.X),
                    BbHeaderSetting.Setting3D.XAxisMinus,
                    BbHeaderSetting.Setting3D.ZAxis);
                if (through)
                {
                    thickness = mainPart.Profile.Width;
                }
                else
                {
                    thickness = mainPart.Profile.Width / 2;
                }
                break;

            case SemHoleLocation.Web:
                if (through)
                {
                    pos = BbPosition3D.Create(
                        BbCoordinate3D.Create(
                            (mainPart.Profile.Width / 2),
                            position.Y,
                            position.X
                            ),
                        BbHeaderSetting.Setting3D.XAxisMinus,
                        BbHeaderSetting.Setting3D.ZAxis);
                    thickness = mainPart.Profile.Width;
                }
                else
                {
                    pos = BbPosition3D.Create(
                        BbCoordinate3D.Create(
                            (mainPart.Profile.Width / 4),
                            position.Y,
                            position.X
                            ),
                        BbHeaderSetting.Setting3D.XAxisMinus,
                        BbHeaderSetting.Setting3D.ZAxis);
                    thickness = mainPart.Profile.Width / 2;
                }
                break;

            case SemHoleLocation.Bottom:
                pos = BbPosition3D.Create(
                    BbCoordinate3D.Create(
                        position.Y,
                        -(mainPart.Profile.Depth / 2),
                        position.X
                        ),
                    BbHeaderSetting.Setting3D.YAxis,
                    BbHeaderSetting.Setting3D.ZAxis);
                if (through)
                {
                    thickness = mainPart.Profile.Depth;
                }
                else
                {
                    thickness = mainPart.Profile.Depth / 2;
                }
                break;

            case SemHoleLocation.Top:
            default:
                pos = BbPosition3D.Create(
                    BbCoordinate3D.Create(
                        position.Y,
                        (mainPart.Profile.Depth / 2),
                        position.X
                        ),
                    BbHeaderSetting.Setting3D.YAxisMinus,
                    BbHeaderSetting.Setting3D.ZAxis);
                if (through)
                {
                    thickness = mainPart.Profile.Depth;
                }
                else
                {
                    thickness = mainPart.Profile.Depth / 2;
                }
                break;
            }

            ObjectBbLocalPlacement = BbLocalPlacement3D.Create(
                hostElement.ObjectBbLocalPlacement, pos);

            BbExtrudedGeometry bbExtrudedGeometry = BbExtrudedGeometry.Create(
                profile,
                BbHeaderSetting.Setting3D.DefaultBbPosition3D,
                BbHeaderSetting.Setting3D.ZAxis,
                thickness);

            _ifcOpeningElement = new IfcOpeningElement
            {
                GlobalId     = IfcGloballyUniqueId.NewGuid(),
                OwnerHistory = hostElement.IfcObject.OwnerHistory,
                // Name =
                // Description =
                ObjectType      = "Opening",
                ObjectPlacement = ObjectBbLocalPlacement.IfcLocalPlacement,
                Representation  = bbExtrudedGeometry.IfcProductDefinitionShape,
            };

            _ifcRelVoidsElement = new IfcRelVoidsElement
            {
                GlobalId                = IfcGloballyUniqueId.NewGuid(),
                OwnerHistory            = hostElement.IfcObject.OwnerHistory,
                Name                    = type,
                RelatingBuildingElement = hostElement.IfcObject as IfcElement,
                RelatedOpeningElement   = _ifcOpeningElement,
            };
        }
예제 #22
0
        private IfcOpeningElement CreateIfcOpening(IfcStore model, Opening cadOpening, double thickness)
        {
            //cadOpening.CenterPt.X *= 1000;
            //cadOpening.CenterPt.Y *= 1000;

            //cadOpening.PtLengthDir.X *= 1000;
            //cadOpening.PtLengthDir.Y *= 1000;

            //cadOpening.Length *= 1000;
            //cadOpening.Width *= 1000;
            //
            double length = cadOpening.Length;
            double width  = cadOpening.Width;

            //begin a transaction
            using (var trans = model.BeginTransaction("Create Opening"))
            {
                IfcOpeningElement openingToCreate = model.Instances.New <IfcOpeningElement>();
                openingToCreate.Name = " Openings - Openings:UC305x305x97:" + random.Next(1000, 10000);

                //represent wall as a rectangular profile
                IfcRectangleProfileDef rectProf = IFCHelper.RectProfileCreate(model, length, width);

                //Profile insertion point
                rectProf.ProfileInsertionPointSet(model, 0, 0);

                var insertPoint = model.Instances.New <IfcCartesianPoint>();
                insertPoint.SetXYZ(0, 0, cadOpening.CenterPt.Z);  //insert at arbitrary position
                rectProf.Position          = model.Instances.New <IfcAxis2Placement2D>();
                rectProf.Position.Location = insertPoint;

                //model as a swept area solid
                IfcDirection extrusionDir = model.Instances.New <IfcDirection>();
                extrusionDir.SetXYZ(0, 0, -1);

                IfcExtrudedAreaSolid body = IFCHelper.ProfileSweptSolidCreate(model, thickness, rectProf, extrusionDir);


                //parameters to insert the geometry in the model
                body.BodyPlacementSet(model, 0, 0, 0);


                //Create a Definition shape to hold the geometry
                IfcShapeRepresentation shape = IFCHelper.ShapeRepresentationCreate(model, "SweptSolid", "Body");
                shape.Items.Add(body);

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

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

                var uvColLongDir = MathHelper.UnitVectorFromPt1ToPt2(cadOpening.CenterPt, cadOpening.PtLengthDir);

                IfcDirection localXDir = model.Instances.New <IfcDirection>();
                localXDir.SetXYZ(uvColLongDir.X, uvColLongDir.Y, uvColLongDir.Z);

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

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

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


                //commit transaction
                trans.Commit();

                return(openingToCreate);
            }
        }
예제 #23
0
        BbSkewedEnd(
            BbElement hostElement,
            BbPosition3D pos)
        {
            var mainPart = hostElement as BbPiece;

            if (mainPart == null)
            {
                return;
            }

            var width = mainPart.Length > mainPart.Profile.Width ? mainPart.Length : mainPart.Profile.Width;

            width = width * 100;
            var depth = mainPart.Length > mainPart.Profile.Depth ? mainPart.Length : mainPart.Profile.Depth;

            depth = depth * 100;
            var profile = BbNamedRectangleProfile.Create(width, depth);

            ObjectBbLocalPlacement = BbLocalPlacement3D.Create(
                hostElement.ObjectBbLocalPlacement, pos);



            //Direction3D exDir = Direction3D.Create(new[] {pos.Axis.X, pos.Axis.Y, pos.Axis.Z});

            BbExtrudedGeometry bbExtrudedGeometry = BbExtrudedGeometry.Create(
                profile,
                BbHeaderSetting.Setting3D.DefaultBbPosition3D,
                BbHeaderSetting.Setting3D.ZAxis,
                mainPart.Length);


            //IfcHalfSpaceSolid ifcHalfSpaceSolid = new IfcHalfSpaceSolid
            //    {
            //        BaseSurface = new IfcPlane
            //            {
            //                Position = pos.IfcAxis2Placement3D,
            //            },
            //            AgreementFlag = true,

            //    };

            //IfcShapeRepresentation ifcShapeRepresentation = new IfcShapeRepresentation
            //{
            //    ContextOfItems = HeaderSetting.Setting3D.GeometricRepresentationContext,
            //    RepresentationIdentifier = "Body",
            //    RepresentationType = "SweptSolid",
            //    //RepresentationIdentifier = "Body",
            //    //RepresentationType = "SolidModel",
            //    Items = new List<IfcRepresentationItem>(),
            //};
            //ifcShapeRepresentation.Items.Add(ifcHalfSpaceSolid);

            //IfcProductDefinitionShape ifcProductDefinitionShape = new IfcProductDefinitionShape
            //{
            //    // Name=
            //    // Description =
            //    Representations = new List<IfcRepresentation>(),
            //};
            //ifcProductDefinitionShape.Representations.Add(ifcShapeRepresentation);

            _ifcOpeningElement = new IfcOpeningElement
            {
                GlobalId     = IfcGloballyUniqueId.NewGuid(),
                OwnerHistory = hostElement.IfcObject.OwnerHistory,
                // Name =
                // Description =
                ObjectType      = "Opening",
                ObjectPlacement = ObjectBbLocalPlacement.IfcLocalPlacement,
                Representation  = bbExtrudedGeometry.IfcProductDefinitionShape,
                //Representation = ifcProductDefinitionShape,
            };

            _ifcRelVoidsElement = new IfcRelVoidsElement
            {
                GlobalId                = IfcGloballyUniqueId.NewGuid(),
                OwnerHistory            = hostElement.IfcObject.OwnerHistory,
                Name                    = "Skewed End",
                RelatingBuildingElement = hostElement.IfcObject as IfcElement,
                RelatedOpeningElement   = _ifcOpeningElement,
            };
        }