Пример #1
0
        internal static IfcFootingType generate(DatabaseIfc db, bool parametric, double length, double width, double height)
        {
            string                 name        = parametric ? "PadFootingParametric" : "PadFooting" + length + "x" + width + "x" + height;
            IfcFootingType         footingType = new IfcFootingType(db, name, IfcFootingTypeEnum.PAD_FOOTING);
            IfcRectangleProfileDef rpd         = new IfcRectangleProfileDef(db, name, length, width);

            footingType.RepresentationMaps.Add(new IfcRepresentationMap(new IfcExtrudedAreaSolid(rpd, new IfcAxis2Placement3D(new IfcCartesianPoint(db, 0, 0, 0)), db.Factory.ZAxisNegative, height)));
            Qto_FootingBaseQuantities baseQuantities = new Qto_FootingBaseQuantities(footingType);

            baseQuantities.Length = length;
            baseQuantities.Width  = width;
            baseQuantities.Height = height;
            ReadOnlyCollection <IfcPhysicalQuantity> quantities = new ReadOnlyCollection <IfcPhysicalQuantity>(baseQuantities.Quantities);

            if (parametric)
            {
                string prefix = @"RepresentationMaps[1].MappedRepresentation.Items[1]\IfcExtrudedAreaSolid.";
                CreateConstraint("Length", footingType, quantities[0], prefix + @"SweptArea\IfcRectangleProfileDef.XDim");
                CreateConstraint("Width", footingType, quantities[1], prefix + @"SweptArea\IfcRectangleProfileDef.YDim");
                CreateConstraint("Height", footingType, quantities[2], prefix + @"Depth");
                //IfcAppliedValue appv = new IfcAppliedValue(new IfcAppliedValue( IfcReference.ParseDescription(db, "HasPropertySets['" + baseQuantities.Name + "'].HasProperties['" +quantities[2].Name + "']")), IfcArithmeticOperatorEnum.MULTIPLY, new IfcAppliedValue(db, new IfcReal(-1)));
                //CreateConstraint("Offset",footingType,appv, @"Position.Location.Coordinates[3]");
            }
            return(footingType);
        }
Пример #2
0
		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 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";
            }
        }
Пример #4
0
        internal static void ProfileInsertionPointSet(this IfcRectangleProfileDef rectProf, IfcStore model, double x, double y)
        {
            IfcCartesianPoint insertionPoint = model.Instances.New <IfcCartesianPoint>();

            insertionPoint.SetXY(x, y);
            rectProf.Position          = model.Instances.New <IfcAxis2Placement2D>();
            rectProf.Position.Location = insertionPoint;
        }
Пример #5
0
		internal static void GenerateData(STPModelData md, IfcBuilding building,bool assembly)
		{
			IfcDocumentReference documentReference = new IfcDocumentReference(md, "", "MyReinforcementCode", "MyCodeISO3766", "", null);
			IfcRelAssociatesDocument associatesDocument = new IfcRelAssociatesDocument(md.Project, documentReference);
			associatesDocument.GlobalId = "1R7R97$uLAAv4wci$KGwn8";
			IfcMaterial material = new IfcMaterial(md, "ReinforcingSteel", "", "");
			List<Point3d> points = new List<Point3d>() { new Point3d(-69.0, 0.0, -122.0), new Point3d(-69.0, 0.0, -79.0), new Point3d(-54.9411254969541, 0.0, -45.0588745030455), new Point3d(-21.0, 0.0, -31.0), new Point3d(21.0, 0.0, -31.0), new Point3d(54.9411254969541, 0.0, -45.0588745030455), new Point3d(69.0, 0.0, -78.9999999999999), new Point3d(69.0, 0.00000000000000089, -321.0), new Point3d(54.9939785957165, 1.21791490472034, -354.941125496954), new Point3d(21.1804517666074, 4.15822158551252, -369.0), new Point3d(-20.6616529376114, 7.79666547283599, -369.0), new Point3d(-54.4751797667207, 10.7369721536282, -354.941125496954), new Point3d(-68.4812011710042, 11.9548870583485, -321.0), new Point3d(-69.0, 12.0, -79.0), new Point3d(-54.9411254969541, 12.0, -45.0588745030455), new Point3d(-21.0, 12.0, -31.0), new Point3d(21.0, 12.0, -31.0), new Point3d(54.9411254969541, 12.0, -45.0588745030455), new Point3d(69.0, 12.0, -78.9999999999999),new Point3d(69.0, 12.0, -122.0), };
			PolyCurve pc = new PolyCurve();
			pc.Append(new Line(points[0],points[1]));
			pc.Append(new Arc(points[1],points[2],points[3] ));
			pc.Append(new Line(points[3],points[4]));
			pc.Append(new Arc(points[4],points[5],points[6] ));
			pc.Append(new Line(points[6],points[7]));
			pc.Append(new Arc(points[7],points[8],points[9] ));
			pc.Append(new Line(points[9],points[10]));
			pc.Append(new Arc(points[10],points[11],points[12] ));
			pc.Append(new Line(points[12],points[13]));
			pc.Append(new Arc(points[13],points[14],points[15] ));
			pc.Append(new Line(points[15],points[16]));
			pc.Append(new Arc(points[16],points[17],points[18] ));
			pc.Append(new Line(points[18],points[19]));
			IfcBoundedCurve directrix = IfcBoundedCurve.ConvertCurve(md,pc);

			double barDiameter = 12, area = Math.PI * Math.Pow( barDiameter,2) / 4;
			IfcSweptDiskSolid sweptDiskSolid = new IfcSweptDiskSolid(directrix, barDiameter/2.0, 0);
			IfcRepresentationMap representationMap = new IfcRepresentationMap(sweptDiskSolid);
			string shapeCode = ""; //Todo
			IfcReinforcingBarType reinforcingBarType = new IfcReinforcingBarType(md, "12 Diameter Ligature", IfcReinforcingBarTypeEnum.LIGATURE, barDiameter, area, 1150, IfcReinforcingBarSurfaceEnum.TEXTURED, shapeCode, null) { GlobalId = "0jMRtfHYXE7u4s_CQ2uVE9", MaterialSelect = material, RepresentationMaps = new List<IfcRepresentationMap>() { representationMap} };
			reinforcingBarType.ObjectTypeOf.GlobalId = "1iAfl2ERbFmwi7uniy1H7j";
			reinforcingBarType.Material.Associates.GlobalId = "3gfVO40P5EfQyKZ_bF0R$6";
			if (assembly)
			{
				IfcMaterial concrete = new IfcMaterial(md,"Concrete","","Concrete");
				string name = "400x200RC";
				IfcRectangleProfileDef rectangleProfileDef = new IfcRectangleProfileDef(md, name, 400, 200);
				IfcMaterialProfile materialProfile = new IfcMaterialProfile(md,name,"",concrete,rectangleProfileDef,0,"");

				IfcBeamType beamType = new IfcBeamType(name, materialProfile, IfcBeamTypeEnum.BEAM) { GlobalId = "3bdpqVuWTCbxJ2S3ODYv6q"};
				beamType.ObjectTypeOf.GlobalId = "2oaQVVf79BrwRouvtRuQVg";
				beamType.Material.Associates.GlobalId = "2ZEgyI2v184hwa$_diRqS9";
				IfcBeamStandardCase beamStandardCase = new IfcBeamStandardCase(building, beamType, new Line(0, 0, 0, 0, 5000, 0), Vector3d.ZAxis, IfcCardinalPointReference.TOPMID, null) { GlobalId = "1yjQ2DwLnCC8k3i3X6D_ut" };
				beamStandardCase.Material.Associates.GlobalId = "3DWeleqqjEG9KshbOZXUdY";
				IfcElementAssembly elementAssembly = new IfcElementAssembly(beamStandardCase, IfcAssemblyPlaceEnum.FACTORY, IfcElementAssemblyTypeEnum.REINFORCEMENT_UNIT) { GlobalId = "0Q1tCJWdj4kOkZUg7rkf2h" };
				List<string> ids = new List<string>() { "0ohBfsArr3ruXYxacT4yl5","3YrK7RbE122fNRsP5djFAe","0wxAc63nj5AezFhfks7wLL","0bsov2wZL6tRRZmKy4vuUU","3qrgfIBb92ZegJTle7jou3","16m6R3JeT83fJPCze2yU$a","2SGIIYjSbCuu3HVwoLt1yh","0PsLby6eL8_hVEt4QwK0lZ","1325VJou5AngWp1djcV0hL","20zj_$BcH74xRgR4bDrLNb","3M4SfEMtHEJukgZR4hw$eV","23BYnIaOLBZPVTrKVEDJiy","2XulRByDL8ugyo4Uqv9rJr","2xvQMSga96XOT3VeCS6ZsK","2gUE6_w3j77f8YJGz_2RMl","0J0dRL4tT93REAabfASDom","048RJ151b81PqODsTMD4EA","3hXx9Kb6b5bvjgr9pwvpz0","0FmUHg8ZX0ZfY$0f5nkM2l","2_zvpwRdvAuRiTlHXX$Qp8","1mhkXHKfX6PxdS2vZn17wX","0CeIQzUqP5qOOeAjMtH2OX","3shtoAQL5BAhvwA_1Ph$lC","22j4RNKqD2IBRDGig5eaCF","3Wvu6qGJH4ChhTV3pl9CGh","37Qrf07Iz3tRMbSxEA4ynH","2gelqZ1Wv8BvCy6TstVGkd","1Q21dHc_X7eRppCHrT69Vb","0e6Wc08NLD59ueqCAK1gxp","3xdMOSZMj3cBOV_QTbXZha","1r_U9JTkHDWwkv_nfWFHVe","29I7_S2fT3WRD4zPH4YjmD","0$ciATTaP17PJMHQD0$N3Y","1irBeCCUf82wdGg7qTPCbW" };
				int jcounter = 0;
				for (int icounter = 25; icounter < 5000; icounter += 150)
				{
					IfcElement element = reinforcingBarType.GenerateMappedItemElement(elementAssembly, new Plane(new Point3d(0, icounter, 0), Vector3d.XAxis, Vector3d.YAxis));
					element.GlobalId = ids[jcounter++];
				}
				elementAssembly.IsDecomposedBy[0].GlobalId = "1WdB196Kb72f_pKgj5rklU";
			}
			else
			{ 
				IfcElement element = reinforcingBarType.GenerateMappedItemElement(building, Plane.WorldXY);
				element.GlobalId = "0WUveBtSTDbunNjDLsuRn$";
			}
		}
Пример #6
0
        internal static IfcRectangleProfileDef RectProfileCreate(IfcStore model, double length, double width)
        {
            IfcRectangleProfileDef rectProf = model.Instances.New <IfcRectangleProfileDef>();

            rectProf.ProfileType = IfcProfileTypeEnum.AREA;
            rectProf.XDim        = length;
            rectProf.YDim        = width;

            return(rectProf);
        }
        /// <summary>
        /// Compares two objects for geomtric equality
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b">object to compare with</param>
        /// <returns></returns>
        public static bool GeometricEquals(this IfcRectangleProfileDef a, IfcProfileDef b)
        {
            IfcRectangleProfileDef p = b as IfcRectangleProfileDef;

            if (p == null)
            {
                return(false);           //different types are not the same
            }
            return(a.XDim == p.XDim && a.YDim == p.YDim && a.Position.GeometricEquals(p.Position));
        }
Пример #8
0
        static void Main(string[] args)
        {
            var dbInitial = new DatabaseIfc(ModelView.Ifc4NotAssigned);

            dbInitial.Factory.Options.GenerateOwnerHistory = false;

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

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

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

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


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

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


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


            dbInitial.WriteFile("cube_double.ifc");
        }
 BbNamedRectangleProfile(double lengthX, double lengthY)
 {
     LengthX = lengthX;
     LengthY = lengthY;
     ifcRectangleProfileDef = new IfcRectangleProfileDef
     {
         ProfileType = IfcProfileTypeEnum.AREA,
         //ProfileName = Name,
         Position = BbHeaderSetting.Setting3D.Position2D.IfcAxis2Placement2D,
         XDim = LengthX,
         YDim = LengthY
     };
 }
Пример #10
0
 BbNamedRectangleProfile(double lengthX, double lengthY)
 {
     LengthX = lengthX;
     LengthY = lengthY;
     ifcRectangleProfileDef = new IfcRectangleProfileDef
     {
         ProfileType = IfcProfileTypeEnum.AREA,
         //ProfileName = Name,
         Position = BbHeaderSetting.Setting3D.Position2D.IfcAxis2Placement2D,
         XDim     = LengthX,
         YDim     = LengthY
     };
 }
Пример #11
0
        private static IfcBeam CreateBeam(XbimModel model, HndzStructuralElement genericProducthndz)
        {
            using (XbimReadWriteTransaction txn = model.BeginTransaction("Create" + genericProducthndz.ToString()))
            {
                IfcBeam genericProductIfc        = model.Instances.New <IfcBeam>();
                IfcExtrudedAreaSolid body        = model.Instances.New <IfcExtrudedAreaSolid>();
                IfcBeamType          elementType = model.Instances.New <IfcBeamType>();
                elementType.PredefinedType = IfcBeamTypeEnum.BEAM;


                if (genericProducthndz.Profile is HndzRectangularProfile)
                {
                    HndzRectangularProfile genericProfilehndz = genericProducthndz.Profile as HndzRectangularProfile;

                    IfcRectangleProfileDef ifcGenericProfile = AssignRectangularProfile(model, genericProducthndz, genericProductIfc, elementType, genericProfilehndz);

                    //model as a swept area solid
                    body.SweptArea = ifcGenericProfile;
                }

                if (genericProducthndz.Profile is HndzISectionProfile)
                {
                    HndzISectionProfile genericProfilehndz = genericProducthndz.Profile as HndzISectionProfile;

                    IfcIShapeProfileDef ifcGenericProfile = AssignIProfile(model, genericProducthndz, genericProductIfc, elementType, genericProfilehndz);


                    //model as a swept area solid
                    body.SweptArea = ifcGenericProfile;
                }
                if (genericProducthndz.Profile is HndzCSectionProfile)
                {
                    HndzCSectionProfile genericProfilehndz = genericProducthndz.Profile as HndzCSectionProfile;
                    IfcCShapeProfileDef ifcGenericProfile  = AssignCsectionProfile(model, genericProducthndz, genericProductIfc, elementType, genericProfilehndz);


                    //model as a swept area solid
                    body.SweptArea = ifcGenericProfile;
                }

                AdjustExtrusion(model, body, genericProducthndz, genericProductIfc);

                if (model.Validate(txn.Modified(), Console.Out) == 0)
                {
                    txn.Commit();
                    return(genericProductIfc);
                }

                return(null);
            }
        }
        /// <summary>
        /// returns a Hash for the geometric behaviour of this object
        /// </summary>
        /// <param name="solid"></param>
        /// <returns></returns>
        public static int GetGeometryHashCode(this IfcRectangleProfileDef profile)
        {
            Func <double, int> f = profile.ModelOf.ModelFactors.GetGeometryDoubleHash;

            if (profile.YDim != 0) //dividing x/y makes profile hash unique
            {
                return(f(profile.XDim) ^
                       f(profile.XDim / profile.YDim) ^
                       profile.Position.GetGeometryHashCode());
            }
            else
            {
                return(f(profile.XDim) ^
                       profile.Position.GetGeometryHashCode());
            }
        }
Пример #13
0
        static void Generate(TypeIFC type, ReleaseVersion release, string path)
        {
            DatabaseIfc db       = new DatabaseIfc(true, release);
            IfcBuilding building = new IfcBuilding(db, "IfcBuilding")
            {
            };
            IfcProject project = new IfcProject(building, "IfcProject", IfcUnitAssignment.Length.Millimetre)
            {
            };

            IfcRectangleProfileDef    rect      = new IfcRectangleProfileDef(db, "Rect", 1000, 500);
            IfcExtrudedAreaSolid      extrusion = new IfcExtrudedAreaSolid(rect, new IfcAxis2Placement3D(new IfcCartesianPoint(db, 0, 0, 0)), new IfcDirection(db, 0, 0, 1), 2000);
            IfcProductDefinitionShape rep       = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrusion));

            if (type == TypeIFC.Chiller)
            {
                IfcChiller chiller = new IfcChiller(building, null, rep, null)
                {
                    PredefinedType = IfcChillerTypeEnum.AIRCOOLED
                };
                if (release == ReleaseVersion.IFC2x3)
                {
                    chiller.RelatingType = new IfcChillerType(db, "MyChillerType", IfcChillerTypeEnum.AIRCOOLED);
                }
            }
            else if (type == TypeIFC.AirTerminal)
            {
                IfcAirTerminal terminal = new IfcAirTerminal(building, null, rep, null)
                {
                    PredefinedType = IfcAirTerminalTypeEnum.DIFFUSER
                };
                if (release == ReleaseVersion.IFC2x3)
                {
                    terminal.RelatingType = new IfcAirTerminalType(db, "MyAirTerminalType", IfcAirTerminalTypeEnum.DIFFUSER);
                }
            }
            else
            {
                IfcElectricDistributionPoint point = new IfcElectricDistributionPoint(building, null, rep, null)
                {
                    DistributionPointFunction = IfcElectricDistributionPointFunctionEnum.DISTRIBUTIONBOARD
                };
            }
            db.WriteFile(Path.Combine(path, type.ToString() + " " + release.ToString() + ".ifc"));
        }
Пример #14
0
        private static IfcRectangleProfileDef AssignRectangularProfile(XbimModel model, HndzStructuralElement genericProducthndz,
                                                                       IfcProduct genericProductIfc, IfcBuildingElementType elementType, HndzRectangularProfile genericProfilehndz)
        {
            #region Type & Material &Tags

            string typeText = genericProducthndz.ToString() + (int)genericProfilehndz.Rectangle.Width + " x "
                              + (int)genericProfilehndz.Rectangle.Height + " mm";

            elementType.Tag  = typeText;
            elementType.Name = typeText;
            IfcLabel columnLabel = new IfcLabel(typeText);
            elementType.ElementType          = columnLabel;
            elementType.ApplicableOccurrence = columnLabel;



            //genericProductIfc.Tag = typeText;
            genericProductIfc.Name        = typeText;
            genericProductIfc.Description = typeText;
            genericProductIfc.SetDefiningType(elementType, model);

            #endregion

            //represent column as a rectangular profile
            IfcRectangleProfileDef ifcGenericProfile = model.Instances.New <IfcRectangleProfileDef>();
            ifcGenericProfile.ProfileType = IfcProfileTypeEnum.AREA;
            ifcGenericProfile.XDim        = genericProfilehndz.Rectangle.Height;
            ifcGenericProfile.YDim        = genericProfilehndz.Rectangle.Width;

            ifcGenericProfile.Position = model.Instances.New <IfcAxis2Placement2D>();
            ifcGenericProfile.Position.RefDirection = model.Instances.New <IfcDirection>();
            ifcGenericProfile.Position.RefDirection.SetXY(genericProfilehndz.OrientationInPlane.X, genericProfilehndz.OrientationInPlane.Y);
            ifcGenericProfile.Position.Location = model.Instances.New <IfcCartesianPoint>();
            ifcGenericProfile.Position.Location.SetXY(0, 0);
            return(ifcGenericProfile);
        }
Пример #15
0
        public static devDept.Eyeshot.Entities.Region getRegionFromIfcProfileDef(IfcProfileDef ipd, ViewportLayout viewportLayout1)
        {
            devDept.Eyeshot.Entities.Region region = null;

            if (ipd is IfcCircleProfileDef)
            {
                IfcCircleProfileDef crProfDef = (IfcCircleProfileDef)ipd;

                region = new CircularRegion(crProfDef.Radius);
            }
            else if (ipd is IfcIShapeProfileDef) // IfcIShapeProfileDef and all derived from
            {
                IfcIShapeProfileDef shProfDef = (IfcIShapeProfileDef)ipd;
                double     halfWidth          = shProfDef.OverallWidth / 2;
                double     halfDepth          = shProfDef.OverallDepth / 2;
                LinearPath lp = new LinearPath(Plane.XY,
                                               new Point2D(-halfWidth, -halfDepth),
                                               new Point2D(halfWidth, -halfDepth),
                                               new Point2D(halfWidth, -halfDepth + shProfDef.FlangeThickness),
                                               new Point2D(shProfDef.WebThickness / 2, -halfDepth + shProfDef.FlangeThickness),
                                               new Point2D(shProfDef.WebThickness / 2, +halfDepth - shProfDef.FlangeThickness),
                                               new Point2D(halfWidth, +halfDepth - shProfDef.FlangeThickness),
                                               new Point2D(halfWidth, halfDepth),
                                               new Point2D(-halfWidth, halfDepth),
                                               new Point2D(-halfWidth, halfDepth - shProfDef.FlangeThickness),
                                               new Point2D(-shProfDef.WebThickness / 2, halfDepth - shProfDef.FlangeThickness),
                                               new Point2D(-shProfDef.WebThickness / 2, -halfDepth + shProfDef.FlangeThickness),
                                               new Point2D(-halfWidth, -halfDepth + shProfDef.FlangeThickness),
                                               new Point2D(-halfWidth, -halfDepth)
                                               );

                region = new devDept.Eyeshot.Entities.Region(lp);
            }
            else if (ipd is IfcRectangleProfileDef)
            {
                IfcRectangleProfileDef recProfDef = (IfcRectangleProfileDef)ipd;

                region = new RectangularRegion(recProfDef.XDim, recProfDef.YDim, true);
            }
            else if (ipd is IfcArbitraryClosedProfileDef)
            {
                IfcArbitraryClosedProfileDef arProfDef = (IfcArbitraryClosedProfileDef)ipd;

                ICurve cc = getICurveFromIfcCurve(arProfDef.OuterCurve);

                if (cc != null)
                {
                    //foreach(Entity xx in cc.CurveList)
                    //    viewportLayout1.Entities.Add((Entity)xx.Clone(), 1);

                    //viewportLayout1.Entities.Add((Entity)cc.Clone(), 2);

                    region = new devDept.Eyeshot.Entities.Region(cc);
                }
            }
            else
            {
                if (!debug.Contains("IfcProfileDef not supported: " + ipd.KeyWord))
                {
                    debug += "IfcProfileDef not supported: " + ipd.KeyWord + "\n";
                }
            }
            if (ipd is IfcParameterizedProfileDef)
            {
                IfcParameterizedProfileDef parProfDef = (IfcParameterizedProfileDef)ipd;

                if (parProfDef.Position != null && region != null)
                {
                    Plane plane = getPlaneFromPosition(parProfDef.Position);

                    Align3D algn = new Align3D(Plane.XY, plane);

                    region.TransformBy(algn);

                    //region.Translate(parProfDef.Position.Location.Coordinates.Item1, parProfDef.Position.Location.Coordinates.Item2, parProfDef.Position.Location.Coordinates.Item3);
                }
            }
            return(region);
        }
Пример #16
0
        public static double GetPerimeter(this IfcProfileDef Profile, bool addPerimetersOfVoids = true)
        {
            // Inheritance tree of IfcProfileDef:
            //
            //- IfcArbitraryClosedProfileDef
            //  - IfcArbitraryProfileDefWithVoids
            //- IfcArbitraryOpenProfileDef
            //  - IfcCenterLineProfileDef
            //- IfcParameterizedProfileDef  (abstract)
            //  - IfcIShapeProfileDef
            //    - IfcAsymmetricIShapeProfileDef
            //  - IfcCircleProfileDef
            //    - IfcCircleHollowProfileDef
            //  - IfcCraneRailAShapeProfileDef (Throw)
            //  - IfcCraneRailFShapeProfileDef (Throw)
            //  - IfcCShapeProfileDef
            //  - IfcEllipseProfileDef
            //  - IfcLShapeProfileDef (Throw)
            //  - IfcRectangleProfileDef
            //    - IfcRectangleHollowProfileDef
            //    - IfcRoundedRectangleProfileDef
            //  - IfcTrapeziumProfileDef
            //  - IfcTShapeProfileDef (Throw)
            //  - IfcUShapeProfileDef (Throw)
            //  - IfcZShapeProfileDef (Throw)
            //- IfcCompositeProfileDef
            if (Profile is IfcArbitraryProfileDefWithVoids)
            {
                throw new NotImplementedException("IfcArbitraryProfileDefWithVoids Perimeter is not implemented");
            }
            else if (Profile is IfcArbitraryClosedProfileDef)
            {
                throw new NotImplementedException("IfcArbitraryClosedProfileDef Perimeter is not implemented");
            }
            else if (Profile is IfcRoundedRectangleProfileDef)
            {
                IfcRoundedRectangleProfileDef p = Profile as IfcRoundedRectangleProfileDef;
                return(RoundedRecPerimeter(p.XDim, p.YDim, p.RoundingRadius));
            }
            else if (Profile is IfcRectangleHollowProfileDef)
            {
                IfcRectangleHollowProfileDef p = Profile as IfcRectangleHollowProfileDef;

                // outer 2P
                double outerFillet = 0;
                if (p.OuterFilletRadius.HasValue)
                {
                    outerFillet = p.OuterFilletRadius.Value;
                }
                double outer = RoundedRecPerimeter(p.XDim, p.YDim, outerFillet);

                if (!addPerimetersOfVoids)
                {
                    return(outer);
                }
                // inner 2P
                double innerFillet = 0;
                if (p.InnerFilletRadius.HasValue)
                {
                    innerFillet = p.InnerFilletRadius.Value;
                }
                double inner = RoundedRecPerimeter(p.XDim - 2 * p.WallThickness, p.YDim - 2 * p.WallThickness, innerFillet);

                // value
                return(outer + inner);
            }
            else if (Profile is IfcRectangleProfileDef)
            {
                IfcRectangleProfileDef p = Profile as IfcRectangleProfileDef;
                return(2 * (p.XDim + p.YDim));
            }
            else if (Profile is IfcCircleHollowProfileDef)
            {
                IfcCircleHollowProfileDef p = Profile as IfcCircleHollowProfileDef;
                double outer = 2 * Math.PI * p.Radius;
                if (!addPerimetersOfVoids)
                {
                    return(outer);
                }

                double inner = 2 * Math.PI * (p.Radius - p.WallThickness);

                return(outer - inner);
            }
            else if (Profile is IfcCircleProfileDef)
            {
                IfcCircleProfileDef p = Profile as IfcCircleProfileDef;
                return(2 * Math.PI * p.Radius);
            }
            else if (Profile is IfcCraneRailAShapeProfileDef)
            {
                // geometry is not clear
                throw new NotImplementedException("IfcCraneRailAShapeProfileDef Perimeter is not implemented");
            }
            else if (Profile is IfcCraneRailFShapeProfileDef)
            {
                // geometry is not clear
                throw new NotImplementedException("IfcCraneRailFShapeProfileDef Perimeter is not implemented");
            }
            else if (Profile is IfcCShapeProfileDef)
            {
                IfcCShapeProfileDef p = Profile as IfcCShapeProfileDef;

                double raIn = 0;
                if (p.InternalFilletRadius.HasValue)
                {
                    raIn = p.InternalFilletRadius.Value;
                }
                double raOut = raIn + p.WallThickness;

                return
                    (2 * Math.PI * raIn +        // internal fillet
                     2 * Math.PI * raOut +       // external fillet
                     4 * (p.Girth - raOut) +     // girt extension
                     2 * p.WallThickness +       // girt closures
                     4 * (p.Width - 2 * raOut) + // top and bottom connections
                     2 * (p.Depth - 2 * raOut)); // left connections
            }
            else if (Profile is IfcEllipseProfileDef)
            {
                IfcEllipseProfileDef p = Profile as IfcEllipseProfileDef;
                // http://www.mathsisfun.com/geometry/ellipse-perimeter.html
                // Ramanujan  approx 3
                double h = Math.Pow((p.SemiAxis1 - p.SemiAxis2), 2) / Math.Pow((p.SemiAxis1 + p.SemiAxis2), 2);
                return
                    (Math.PI * (p.SemiAxis1 + p.SemiAxis2) * (1 + 3 * h / (10 + Math.Sqrt(4 - 3 * h))));
            }
            else if (Profile is IfcLShapeProfileDef)
            {
                // geometry is not clear
                throw new NotImplementedException("IfcLShapeProfileDef Perimeter is not implemented");
            }
            else if (Profile is IfcTrapeziumProfileDef)
            {
                IfcTrapeziumProfileDef p = Profile as IfcTrapeziumProfileDef;
                double diag1             = pita(p.YDim, p.TopXOffset);
                double diag2             = pita(p.YDim, p.BottomXDim - p.TopXOffset - p.TopXDim);
                return(p.BottomXDim + p.TopXDim + diag1 + diag2);
            }
            else if (Profile is IfcTShapeProfileDef)
            {
                // geometry is not clear
                throw new NotImplementedException("IfcTShapeProfileDef Perimeter is not implemented");
            }
            else if (Profile is IfcUShapeProfileDef)
            {
                // geometry is not clear
                throw new NotImplementedException("IfcUShapeProfileDef Perimeter is not implemented");
            }
            else if (Profile is IfcZShapeProfileDef)
            {
                // geometry is not clear
                throw new NotImplementedException("IfcZShapeProfileDef Perimeter is not implemented");
            }
            else if (Profile is IfcAsymmetricIShapeProfileDef) // needs to be tested before IfcIShapeProfileDef
            {
                throw new NotImplementedException("IfcAsymmetricIShapeProfileDef Perimeter is not implemented");
                // IfcAsymmetricIShapeProfileDef p = Profile as IfcAsymmetricIShapeProfileDef;
            }
            else if (Profile is IfcIShapeProfileDef)
            {
                throw new NotImplementedException("IfcAsymmetricIShapeProfileDef Perimeter is not implemented");
                // IfcIShapeProfileDef p = Profile as IfcIShapeProfileDef;
            }
            else if (Profile is IfcArbitraryOpenProfileDef)
            {
                return(0);
            }
            return(double.NaN);
        }
Пример #17
0
        /// <summary>
        /// This creates a wall and it's geometry, many geometric representations are possible and extruded rectangular footprint is chosen as this is commonly used for standard case walls
        /// </summary>
        /// <param name="model"></param>
        /// <param name="length">Length of the rectangular footprint</param>
        /// <param name="width">Width of the rectangular footprint (width of the wall)</param>
        /// <param name="height">Height to extrude the wall, extrusion is vertical</param>
        /// <returns></returns>
        private IfcWallStandardCase CreateWall(XbimModel model, double length, double width, double height)
        {
            //
            //begin a transaction
            using (XbimReadWriteTransaction txn = model.BeginTransaction("Create Wall"))
            {
                IfcWallStandardCase wall = model.Instances.New <IfcWallStandardCase>();
                wall.Name = "A Standard rectangular wall";

                // required parameters for IfcWall
                wall.OwnerHistory.OwningUser        = model.DefaultOwningUser;
                wall.OwnerHistory.OwningApplication = model.DefaultOwningApplication;

                //represent wall as a rectangular profile
                IfcRectangleProfileDef rectProf = model.Instances.New <IfcRectangleProfileDef>();
                rectProf.ProfileType = IfcProfileTypeEnum.AREA;
                rectProf.XDim        = width;
                rectProf.YDim        = length;

                IfcCartesianPoint insertPoint = model.Instances.New <IfcCartesianPoint>();
                insertPoint.SetXY(0, 400); //insert at arbitrary position
                rectProf.Position          = model.Instances.New <IfcAxis2Placement2D>();
                rectProf.Position.Location = insertPoint;

                //model as a swept area solid
                IfcExtrudedAreaSolid body = model.Instances.New <IfcExtrudedAreaSolid>();
                body.Depth             = height;
                body.SweptArea         = rectProf;
                body.ExtrudedDirection = model.Instances.New <IfcDirection>();
                body.ExtrudedDirection.SetXYZ(0, 0, 1);

                //parameters to insert the geometry in the model
                IfcCartesianPoint origin = model.Instances.New <IfcCartesianPoint>();
                origin.SetXYZ(0, 0, 0);
                body.Position          = model.Instances.New <IfcAxis2Placement3D>();
                body.Position.Location = origin;

                //Create a Definition shape to hold the geometry
                IfcShapeRepresentation shape = model.Instances.New <IfcShapeRepresentation>();
                shape.ContextOfItems           = model.IfcProject.ModelContext();
                shape.RepresentationType       = "SweptSolid";
                shape.RepresentationIdentifier = "Body";
                shape.Items.Add_Reversible(body);

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

                //now place the wall into the model
                IfcLocalPlacement   lp   = model.Instances.New <IfcLocalPlacement>();
                IfcAxis2Placement3D ax3d = model.Instances.New <IfcAxis2Placement3D>();
                ax3d.Location     = origin;
                ax3d.RefDirection = model.Instances.New <IfcDirection>();
                ax3d.RefDirection.SetXYZ(0, 1, 0);
                ax3d.Axis = model.Instances.New <IfcDirection>();
                ax3d.Axis.SetXYZ(0, 0, 1);
                lp.RelativePlacement = ax3d;
                wall.ObjectPlacement = lp;


                // Where Clause: The IfcWallStandard relies on the provision of an IfcMaterialLayerSetUsage
                IfcMaterialLayerSetUsage ifcMaterialLayerSetUsage = model.Instances.New <IfcMaterialLayerSetUsage>();
                IfcMaterialLayerSet      ifcMaterialLayerSet      = model.Instances.New <IfcMaterialLayerSet>();
                IfcMaterialLayer         ifcMaterialLayer         = model.Instances.New <IfcMaterialLayer>();
                ifcMaterialLayer.LayerThickness = 10;
                ifcMaterialLayerSet.MaterialLayers.Add_Reversible(ifcMaterialLayer);
                ifcMaterialLayerSetUsage.ForLayerSet             = ifcMaterialLayerSet;
                ifcMaterialLayerSetUsage.LayerSetDirection       = IfcLayerSetDirectionEnum.AXIS2;
                ifcMaterialLayerSetUsage.DirectionSense          = IfcDirectionSenseEnum.NEGATIVE;
                ifcMaterialLayerSetUsage.OffsetFromReferenceLine = 150;

                // Add material to wall
                IfcMaterial material = model.Instances.New <IfcMaterial>();
                material.Name = "some material";
                IfcRelAssociatesMaterial ifcRelAssociatesMaterial = model.Instances.New <IfcRelAssociatesMaterial>();
                ifcRelAssociatesMaterial.RelatingMaterial = material;
                ifcRelAssociatesMaterial.RelatedObjects.Add_Reversible(wall);

                ifcRelAssociatesMaterial.RelatingMaterial = ifcMaterialLayerSetUsage;

                // IfcPresentationLayerAssignment is required for CAD presentation in IfcWall or IfcWallStandardCase
                IfcPresentationLayerAssignment ifcPresentationLayerAssignment = model.Instances.New <IfcPresentationLayerAssignment>();
                ifcPresentationLayerAssignment.Name = "some ifcPresentationLayerAssignment";
                ifcPresentationLayerAssignment.AssignedItems.Add(shape);


                // linear segment as IfcPolyline with two points is required for IfcWall
                IfcPolyline       ifcPolyline = model.Instances.New <IfcPolyline>();
                IfcCartesianPoint startPoint  = model.Instances.New <IfcCartesianPoint>();
                startPoint.SetXY(0, 0);
                IfcCartesianPoint endPoint = model.Instances.New <IfcCartesianPoint>();
                endPoint.SetXY(4000, 0);
                ifcPolyline.Points.Add_Reversible(startPoint);
                ifcPolyline.Points.Add_Reversible(endPoint);

                IfcShapeRepresentation shape2d = model.Instances.New <IfcShapeRepresentation>();
                shape2d.ContextOfItems           = model.IfcProject.ModelContext();
                shape2d.RepresentationIdentifier = "Axis";
                shape2d.RepresentationType       = "Curve2D";
                shape2d.Items.Add_Reversible(ifcPolyline);
                rep.Representations.Add_Reversible(shape2d);


                //validate write any errors to the console and commit if ok, otherwise abort

                if (model.Validate(txn.Modified(), Console.Out) == 0)
                {
                    txn.Commit();
                    return(wall);
                }
            }
            return(null);
        }
Пример #18
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";
        }
Пример #19
0
        internal static void GenerateData(STPModelData md, IfcBuilding building, bool assembly)
        {
            IfcDocumentReference     documentReference  = new IfcDocumentReference(md, "", "MyReinforcementCode", "MyCodeISO3766", "", null);
            IfcRelAssociatesDocument associatesDocument = new IfcRelAssociatesDocument(md.Project, documentReference);

            associatesDocument.GlobalId = "1R7R97$uLAAv4wci$KGwn8";
            IfcMaterial    material = new IfcMaterial(md, "ReinforcingSteel", "", "");
            List <Point3d> points   = new List <Point3d>()
            {
                new Point3d(-69.0, 0.0, -122.0), new Point3d(-69.0, 0.0, -79.0), new Point3d(-54.9411254969541, 0.0, -45.0588745030455), new Point3d(-21.0, 0.0, -31.0), new Point3d(21.0, 0.0, -31.0), new Point3d(54.9411254969541, 0.0, -45.0588745030455), new Point3d(69.0, 0.0, -78.9999999999999), new Point3d(69.0, 0.00000000000000089, -321.0), new Point3d(54.9939785957165, 1.21791490472034, -354.941125496954), new Point3d(21.1804517666074, 4.15822158551252, -369.0), new Point3d(-20.6616529376114, 7.79666547283599, -369.0), new Point3d(-54.4751797667207, 10.7369721536282, -354.941125496954), new Point3d(-68.4812011710042, 11.9548870583485, -321.0), new Point3d(-69.0, 12.0, -79.0), new Point3d(-54.9411254969541, 12.0, -45.0588745030455), new Point3d(-21.0, 12.0, -31.0), new Point3d(21.0, 12.0, -31.0), new Point3d(54.9411254969541, 12.0, -45.0588745030455), new Point3d(69.0, 12.0, -78.9999999999999), new Point3d(69.0, 12.0, -122.0),
            };
            PolyCurve pc = new PolyCurve();

            pc.Append(new Line(points[0], points[1]));
            pc.Append(new Arc(points[1], points[2], points[3]));
            pc.Append(new Line(points[3], points[4]));
            pc.Append(new Arc(points[4], points[5], points[6]));
            pc.Append(new Line(points[6], points[7]));
            pc.Append(new Arc(points[7], points[8], points[9]));
            pc.Append(new Line(points[9], points[10]));
            pc.Append(new Arc(points[10], points[11], points[12]));
            pc.Append(new Line(points[12], points[13]));
            pc.Append(new Arc(points[13], points[14], points[15]));
            pc.Append(new Line(points[15], points[16]));
            pc.Append(new Arc(points[16], points[17], points[18]));
            pc.Append(new Line(points[18], points[19]));
            IfcBoundedCurve directrix = IfcBoundedCurve.ConvertCurve(md, pc);

            double                barDiameter = 12, area = Math.PI * Math.Pow(barDiameter, 2) / 4;
            IfcSweptDiskSolid     sweptDiskSolid     = new IfcSweptDiskSolid(directrix, barDiameter / 2.0, 0);
            IfcRepresentationMap  representationMap  = new IfcRepresentationMap(sweptDiskSolid);
            string                shapeCode          = ""; //Todo
            IfcReinforcingBarType reinforcingBarType = new IfcReinforcingBarType(md, new IfcElemTypeParams("0jMRtfHYXE7u4s_CQ2uVE9", "12 Diameter Ligature", "", "", ""), material, representationMap, null, IfcReinforcingBarTypeEnum.LIGATURE, barDiameter, area, 1150, IfcReinforcingBarSurfaceEnum.TEXTURED, shapeCode, null);

            reinforcingBarType.ObjectTypeOf.GlobalId        = "1iAfl2ERbFmwi7uniy1H7j";
            reinforcingBarType.Material.Associates.GlobalId = "3gfVO40P5EfQyKZ_bF0R$6";
            if (assembly)
            {
                IfcMaterial            concrete            = new IfcMaterial(md, "Concrete", "", "Concrete");
                string                 name                = "400x200RC";
                IfcRectangleProfileDef rectangleProfileDef = new IfcRectangleProfileDef(md, IfcProfileTypeEnum.AREA, name, null, 400, 200);
                IfcMaterialProfile     materialProfile     = new IfcMaterialProfile(md, name, "", concrete, rectangleProfileDef, 0, "");

                IfcBeamType beamType = new IfcBeamType(md, new IfcElemTypeParams("3bdpqVuWTCbxJ2S3ODYv6q", name, "", "", ""), materialProfile, null, IfcBeamTypeEnum.BEAM);
                beamType.ObjectTypeOf.GlobalId        = "2oaQVVf79BrwRouvtRuQVg";
                beamType.Material.Associates.GlobalId = "2ZEgyI2v184hwa$_diRqS9";
                IfcBeamStandardCase beamStandardCase = new IfcBeamStandardCase(building, new IfcElemParams("1yjQ2DwLnCC8k3i3X6D_ut", "", "", "", ""), beamType, new Line(0, 0, 0, 0, 5000, 0), Vector3d.ZAxis, IfcCardinalPointReference.TOPMID, null);
                beamStandardCase.Material.Associates.GlobalId = "3DWeleqqjEG9KshbOZXUdY";
                IfcElementAssembly elementAssembly = new IfcElementAssembly(beamStandardCase, new IfcElemParams("0Q1tCJWdj4kOkZUg7rkf2h", "", "", "", ""), IfcAssemblyPlaceEnum.FACTORY, IfcElementAssemblyTypeEnum.REINFORCEMENT_UNIT);
                List <string>      ids             = new List <string>()
                {
                    "0ohBfsArr3ruXYxacT4yl5", "3YrK7RbE122fNRsP5djFAe", "0wxAc63nj5AezFhfks7wLL", "0bsov2wZL6tRRZmKy4vuUU", "3qrgfIBb92ZegJTle7jou3", "16m6R3JeT83fJPCze2yU$a", "2SGIIYjSbCuu3HVwoLt1yh", "0PsLby6eL8_hVEt4QwK0lZ", "1325VJou5AngWp1djcV0hL", "20zj_$BcH74xRgR4bDrLNb", "3M4SfEMtHEJukgZR4hw$eV", "23BYnIaOLBZPVTrKVEDJiy", "2XulRByDL8ugyo4Uqv9rJr", "2xvQMSga96XOT3VeCS6ZsK", "2gUE6_w3j77f8YJGz_2RMl", "0J0dRL4tT93REAabfASDom", "048RJ151b81PqODsTMD4EA", "3hXx9Kb6b5bvjgr9pwvpz0", "0FmUHg8ZX0ZfY$0f5nkM2l", "2_zvpwRdvAuRiTlHXX$Qp8", "1mhkXHKfX6PxdS2vZn17wX", "0CeIQzUqP5qOOeAjMtH2OX", "3shtoAQL5BAhvwA_1Ph$lC", "22j4RNKqD2IBRDGig5eaCF", "3Wvu6qGJH4ChhTV3pl9CGh", "37Qrf07Iz3tRMbSxEA4ynH", "2gelqZ1Wv8BvCy6TstVGkd", "1Q21dHc_X7eRppCHrT69Vb", "0e6Wc08NLD59ueqCAK1gxp", "3xdMOSZMj3cBOV_QTbXZha", "1r_U9JTkHDWwkv_nfWFHVe", "29I7_S2fT3WRD4zPH4YjmD", "0$ciATTaP17PJMHQD0$N3Y", "1irBeCCUf82wdGg7qTPCbW"
                };
                int jcounter = 0;
                for (int icounter = 25; icounter < 5000; icounter += 150)
                {
                    IfcElemParams ep = new IfcElemParams(ids[jcounter++], "", "", "", "");
                    reinforcingBarType.GenerateMappedItemElement(elementAssembly, new Plane(new Point3d(0, icounter, 0), Vector3d.XAxis, Vector3d.YAxis), ep);
                }
                elementAssembly.IsDecomposedBy[0].GlobalId = "1WdB196Kb72f_pKgj5rklU";
            }
            else
            {
                reinforcingBarType.GenerateMappedItemElement(building, Plane.WorldXY, new IfcElemParams("0WUveBtSTDbunNjDLsuRn$", "", "", "", ""));
            }
        }
Пример #20
0
        /// <summary>
        /// You can give the name of the TestCase -> to build only them
        /// </summary>
        /// <param name="args">Testcases to expoert</param>
        /// <help> Testcases: Spatial_simple\n
        /// Railway_spatial\n Spatial_01\nPlacement_Local"\nGeomRepresentation_01\n
        /// \nGeomRepresentation_02\nGeomRepresentation_03\nGeomRepresentation_04
        /// \nLocalPlacement_01\nLinearPlacement_02
        ///
        /// </help>
        static void Main(string[] args)
        {
            //Var declaration

            string folder       = "Unittest";
            var    testcasename = new List <string>();

            testcasename.Add("Spatial_simple");
            testcasename.Add("Railway_spatial");
            testcasename.Add("Spatial_01");
            testcasename.Add("Placement_Local");
            testcasename.Add("GeomRepresentation_01");
            testcasename.Add("GeomRepresentation_02");
            testcasename.Add("GeomRepresentation_03");
            testcasename.Add("GeomRepresentation_04");
            //testcasename.Add("GeomRepresentation_05");
            testcasename.Add("LocalPlacement_01");
            testcasename.Add("LinearPlacement_02");
            System.IO.Directory.CreateDirectory(".\\" + folder);


            //Help handling + single selection
            if (args.Length != 0)
            {
                //Help handling
                if (args.First().Equals("-?"))
                {
                    foreach (var i in testcasename)
                    {
                        Console.WriteLine(i);
                    }
                    return;
                }

                //Select only selected ones
                testcasename = new List <string>();
                foreach (var i in args)
                {
                    testcasename.Add(i);
                }
            }


            foreach (var proname in testcasename)
            {
                var db = new DatabaseIfc(ModelView.Ifc4NotAssigned);
                db.Factory.Options.GenerateOwnerHistory = false;

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

                new IfcRelAggregates(project, new List <IfcObjectDefinition>()
                {
                    site
                })
                {
                    Guid = new Guid("5e1fd0e5-b005-fe11-501e-5caff01dc1ad")
                };
                //Some placements
                IfcAxis2Placement3D placement1       = new IfcAxis2Placement3D(new IfcCartesianPoint(db, 2, 5, 1));
                IfcLocalPlacement   objectPlacement1 = new IfcLocalPlacement(site.ObjectPlacement, placement1);
                IfcAxis2Placement3D placement2       = new IfcAxis2Placement3D(new IfcCartesianPoint(db, 10, 5, 1));
                IfcLocalPlacement   objectPlacement2 = new IfcLocalPlacement(site.ObjectPlacement, placement2);
                IfcAxis2Placement3D placement3       = new IfcAxis2Placement3D(new IfcCartesianPoint(db, 15, 3, 6));
                IfcLocalPlacement   objectPlacement3 = new IfcLocalPlacement(site.ObjectPlacement, placement3);
                IfcAxis2Placement3D placement4       = new IfcAxis2Placement3D(new IfcCartesianPoint(db, 5, 8, 3));
                IfcLocalPlacement   objectPlacement4 = new IfcLocalPlacement(site.ObjectPlacement, placement4);
                IfcAxis2Placement3D originaxis2place = new IfcAxis2Placement3D(db.Factory.Origin);
                IfcLocalPlacement   origionobjplace  = new IfcLocalPlacement(site.ObjectPlacement, originaxis2place);


                //Select the Testcases and fill them into the container
                switch (proname)
                {
                case "Spatial_simple":
                    //initial File
                    IfcBuilding building1 = new IfcBuilding(db, "building1")
                    {
                        Guid = new Guid("fbc7f4b2-177d-4875-88bb-d3b44115bb42")
                    };
                    building1.ObjectPlacement = objectPlacement1;


                    IfcBuilding building2 = new IfcBuilding(db, "building2")
                    {
                        Guid = new Guid("fbc7f4b2-177d-4875-88bb-d3b441151337")
                    };
                    building2.ObjectPlacement = objectPlacement2;

                    //Write inital File
                    db.WriteFile(".\\" + folder + "\\Initial_" + proname + ".ifc");
                    db.WriteXmlFile(".\\" + folder + "\\Initial_" + proname + ".ifcxml");

                    //continue with the updated version


                    IfcBuilding building3 = new IfcBuilding(db, "building3")
                    {
                        Guid            = new Guid("fbc7f4b2-177d-4875-88bb-d3b441153531"),
                        ObjectPlacement = objectPlacement3
                    };
                    break;

                case "Railway_spatial":
                    //initial
                    IfcSpatialZone spazone1 = new IfcSpatialZone(db, "Spatialzone1")
                    {
                        Guid            = new Guid("42c7f4b2-177d-4875-88bb-d3b441153531"),
                        ObjectPlacement = objectPlacement1
                    };

                    IfcSpatialZone spazone2 = new IfcSpatialZone(db, "Spatialzone2")
                    {
                        Guid            = new Guid("42c7f4b2-1337-4875-88bb-d3b441153531"),
                        ObjectPlacement = objectPlacement2
                    };
                    db.WriteFile(".\\" + folder + "\\Initial_" + proname + ".ifc");
                    db.WriteXmlFile(".\\" + folder + "\\Initial_" + proname + ".ifcxml");

                    //Update
                    IfcSpatialZone spazone3 = new IfcSpatialZone(db, "Spatialzone3")
                    {
                        Guid            = new Guid("42c7f4b2-1337-4422-88bb-d3b441153531"),
                        ObjectPlacement = objectPlacement3
                    };
                    IfcSpatialZone spazone4 = new IfcSpatialZone(db, "Spatialzone4")
                    {
                        Guid            = new Guid("42c7f4b2-1337-4875-4242-d3b441153531"),
                        ObjectPlacement = objectPlacement4
                    };

                    break;

                case "Spatial_01":
                    //creating building and add parts to it
                    building1 = new IfcBuilding(db, "building1")
                    {
                        Guid            = new Guid("fbc7f4b2-177d-4875-88bb-d3b44115bb42"),
                        ObjectPlacement = objectPlacement1
                    };

                    IfcBuildingStorey buildingsto1 = new IfcBuildingStorey(building1, "Level1", 0)
                    {
                        Guid            = new Guid("42c74222-1337-4875-4242-d3b441153531"),
                        ObjectPlacement = objectPlacement2
                    };

                    building1.IsDecomposedBy.First().Guid = new Guid("42abcd22-1337-4875-4242-abcd41153531");

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

                    IfcWall wall = new IfcWall(buildingsto1, objectPlacement3, shape1)
                    {
                        Guid = new Guid("42aa4222-1337-aaaa-4242-d3aa41153531"),
                        Name = "Wall1"
                    };
                    wall.ContainedInStructure.Guid = new Guid("42c74222-1337-4875-4242-d3b44abcd531");


                    db.WriteFile(".\\" + folder + "\\Initial_" + proname + ".ifc");
                    db.WriteXmlFile(".\\" + folder + "\\Initial_" + proname + ".ifcxml");

                    //update
                    IfcBuildingStorey buildingsto2 = new IfcBuildingStorey(building1, "Level2", 0)
                    {
                        Guid            = new Guid("42c74222-1337-4875-4242-bbbb41153531"),
                        ObjectPlacement = objectPlacement4
                    };
                    // Reassign Wall to Storey2
                    wall.ContainedInStructure.RelatingStructure = buildingsto2;

                    break;

                case "Placement_Local":
                    //Initial set
                    profile1           = new IfcRectangleProfileDef(db, "rectangleProfileDef", 4, 6);
                    extrudedAreaSolid1 = new IfcExtrudedAreaSolid(profile1, 1.35);
                    shape1             = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid1));

                    //Wall at origin
                    IfcWall wall2 = new IfcWall(site, origionobjplace, shape1)
                    {
                        Guid = new Guid("42aa4222-1337-aaaa-4242-d3aa41153531"),
                        Name = "Wall1"
                    };
                    wall2.ContainedInStructure.Guid = new Guid("42cab222-1337-4875-4242-d3b44abcd531");

                    db.WriteFile(".\\" + folder + "\\Initial_" + proname + ".ifc");
                    db.WriteXmlFile(".\\" + folder + "\\Initial_" + proname + ".ifcxml");

                    //Update
                    IfcAxis2Placement3D wallaxisplace = new IfcAxis2Placement3D(new IfcCartesianPoint(db, 2, 3, 0));
                    wall2.ObjectPlacement = new IfcLocalPlacement(site.ObjectPlacement, wallaxisplace);


                    break;

                case "GeomRepresentation_01":
                    //init
                    profile1           = new IfcRectangleProfileDef(db, "rectangleProfileDef", 4, 6);
                    extrudedAreaSolid1 = new IfcExtrudedAreaSolid(profile1, 1.35);
                    shape1             = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid1));

                    IfcRectangleProfileDef    profile2           = new IfcRectangleProfileDef(db, "rectangleProfileDef", 4, 6);
                    IfcExtrudedAreaSolid      extrudedAreaSolid2 = new IfcExtrudedAreaSolid(profile2, 1.35);
                    IfcProductDefinitionShape shape2             = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid2));


                    var proxy1 = new IfcBuildingElementProxy(site, objectPlacement1, shape1)
                    {
                        Name = "Cuboid1",
                        Guid = new Guid("fbc7f4b2-177d-4875-88bb-d3abed15bbaa")
                    };
                    proxy1.ContainedInStructure.Guid = new Guid("000ab222-1337-4875-4242-d3b44abcd531");

                    var proxy2 = new IfcBuildingElementProxy(site, objectPlacement2, shape2)
                    {
                        Name = "Cuboid2",
                        Guid = new Guid("f8e196cb-c7d9-4d53-9885-0f687706abcd")
                    };
                    proxy2.ContainedInStructure.Guid = new Guid("42cab222-1337-4875-4242-00004abcd531");


                    db.WriteFile(".\\" + folder + "\\Initial_" + proname + ".ifc");
                    db.WriteXmlFile(".\\" + folder + "\\Initial_" + proname + ".ifcxml");
                    //Update


                    proxy2.Representation = shape1;
                    shape2.Dispose(true);     //Remove orphaned entries


                    break;

                case "GeomRepresentation_02":
                    //init
                    profile1           = new IfcRectangleProfileDef(db, "rectangleProfileDef", 4, 6);
                    extrudedAreaSolid1 = new IfcExtrudedAreaSolid(profile1, 1.35);
                    shape1             = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid1));

                    profile2           = new IfcRectangleProfileDef(db, "rectangleProfileDef", 4, 6);
                    extrudedAreaSolid2 = new IfcExtrudedAreaSolid(profile2, 1.35);
                    shape2             = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid2));

                    proxy1 = new IfcBuildingElementProxy(site, objectPlacement1, shape1)
                    {
                        Name = "Cuboid1",
                        Guid = new Guid("fbcba4b2-1c7d-4875-88bb-d3abed15bbaa")
                    };
                    proxy1.ContainedInStructure.Guid = new Guid("000ab222-1337-4875-4242-d3b00abcd531");
                    proxy2 = new IfcBuildingElementProxy(site, objectPlacement2, shape2)
                    {
                        Name = "Cuboid2",
                        Guid = new Guid("f821963b-c7d9-4d53-9885-0f87cd6abcda")
                    };
                    proxy1.ContainedInStructure.Guid = new Guid("000ab222-1337-4875-4242-d3414abcd531");
                    db.WriteFile(".\\" + folder + "\\Initial_" + proname + ".ifc");
                    db.WriteXmlFile(".\\" + folder + "\\Initial_" + proname + ".ifcxml");

                    //Update
                    extrudedAreaSolid2.Depth = 3;
                    break;

                case "GeomRepresentation_03":
                    //init
                    profile1           = new IfcRectangleProfileDef(db, "rectangleProfileDef", 4, 6);
                    extrudedAreaSolid1 = new IfcExtrudedAreaSolid(profile1, 1.35);
                    shape1             = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid1));

                    proxy1 = new IfcBuildingElementProxy(site, objectPlacement1, shape1)
                    {
                        Name = "Cuboid_extrudedArea",
                        Guid = new Guid("fbcba4b2-1c7d-0000-88bb-d3abed15bbaa")
                    };
                    proxy1.ContainedInStructure.Guid = new Guid("00011222-1337-4875-4242-d1114abcd531");
                    db.WriteFile(".\\" + folder + "\\Initial_" + proname + ".ifc");
                    db.WriteXmlFile(".\\" + folder + "\\Initial_" + proname + ".ifcxml");

                    //Update
                    profile1.Dispose(false);     // Remove profile
                    var profile3 = new IfcCircleProfileDef(db, "CylinderProfileDef", 4);
                    extrudedAreaSolid1.SweptArea = profile3;
                    proxy1.Name = "Cylinder_extrudedArea";



                    break;

                case "GeomRepresentation_04":
                    //init
                    profile1           = new IfcRectangleProfileDef(db, "rectangleProfileDef", 4, 6);
                    extrudedAreaSolid1 = new IfcExtrudedAreaSolid(profile1, 1.35);
                    shape1             = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid1));

                    proxy1 = new IfcBuildingElementProxy(site, objectPlacement1, shape1)
                    {
                        Name = "Cuboid_extrudedArea",
                        Guid = new Guid("fbcba4b2-1c7d-0000-88bb-d3abed15bbaa")
                    };
                    proxy1.ContainedInStructure.Guid = new Guid("00011222-1337-4875-4242-d1114abcd531");

                    db.WriteFile(".\\" + folder + "\\Initial_" + proname + ".ifc");
                    db.WriteXmlFile(".\\" + folder + "\\Initial_" + proname + ".ifcxml");

                    //Update

                    var points = new List <IfcCartesianPoint>();
                    points.Add(new IfcCartesianPoint(db, -2, -3, 0));
                    points.Add(new IfcCartesianPoint(db, -2, 3, 0));
                    points.Add(new IfcCartesianPoint(db, 2, 3, 0));
                    points.Add(new IfcCartesianPoint(db, 2, -3, 0));
                    points.Add(new IfcCartesianPoint(db, -2, -3, 1.35));
                    points.Add(new IfcCartesianPoint(db, -2, 3, 1.35));
                    points.Add(new IfcCartesianPoint(db, 2, 3, 1.35));
                    points.Add(new IfcCartesianPoint(db, 2, -3, 1.35));

                    var polyloop = new List <IfcPolyLoop>();
                    polyloop.Add(new IfcPolyLoop(points[0], points[1], points[2], points[3]));
                    polyloop.Add(new IfcPolyLoop(points[0], points[4], points[5], points[1]));
                    polyloop.Add(new IfcPolyLoop(points[0], points[4], points[7], points[3]));
                    polyloop.Add(new IfcPolyLoop(points[4], points[5], points[6], points[7]));
                    polyloop.Add(new IfcPolyLoop(points[1], points[5], points[6], points[2]));
                    polyloop.Add(new IfcPolyLoop(points[3], points[7], points[6], points[2]));

                    var faceouter = new List <IfcFaceOuterBound>();
                    foreach (var i in polyloop)
                    {
                        faceouter.Add(new IfcFaceOuterBound(i, true));
                    }

                    var face = new List <IfcFace>();
                    foreach (var j in faceouter)
                    {
                        face.Add(new IfcFace(j));
                    }

                    var closedshell = new IfcClosedShell(face);
                    var brep        = new IfcFacetedBrep(closedshell);

                    shape2 = new IfcProductDefinitionShape(new IfcShapeRepresentation(brep));
                    proxy1.Representation = shape2;
                    break;

                case "GeomRepresentation_05":
                    var points1 = new List <IfcCartesianPoint>();
                    points1.Add(new IfcCartesianPoint(db, -2, -3, 0));
                    points1.Add(new IfcCartesianPoint(db, -2, 3, 0));
                    points1.Add(new IfcCartesianPoint(db, 2, 3, 0));
                    points1.Add(new IfcCartesianPoint(db, 2, -3, 0));
                    var points2 = new List <IfcCartesianPoint>();
                    points2.Add(new IfcCartesianPoint(db, -2, -3, 1.35));
                    points2.Add(new IfcCartesianPoint(db, -2, 3, 1.35));
                    points2.Add(new IfcCartesianPoint(db, 2, 3, 1.35));
                    points2.Add(new IfcCartesianPoint(db, 2, -3, 1.35));

                    polyloop = new List <IfcPolyLoop>();
                    polyloop.Add(new IfcPolyLoop(points1));
                    polyloop.Add(new IfcPolyLoop(points2));


                    break;


                case "LocalPlacement_01":
                    //init
                    profile1           = new IfcRectangleProfileDef(db, "rectangleProfileDef", 4, 6);
                    extrudedAreaSolid1 = new IfcExtrudedAreaSolid(profile1, 1.35);
                    shape1             = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid1));

                    profile2           = new IfcRectangleProfileDef(db, "rectangleProfileDef", 4, 6);
                    extrudedAreaSolid2 = new IfcExtrudedAreaSolid(profile2, 1.35);
                    shape2             = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid2));

                    proxy1 = new IfcBuildingElementProxy(site, objectPlacement1, shape1)
                    {
                        Name = "Cuboid1",
                        Guid = new Guid("fbcba4b2-1c7d-4815-88bb-d3abed15bbaa")
                    };
                    proxy1.ContainedInStructure.Guid = new Guid("000ab222-1337-4875-4242-d3b00abcd531");
                    proxy2 = new IfcBuildingElementProxy(site, objectPlacement2, shape2)
                    {
                        Name = "Cuboid2",
                        Guid = new Guid("f821963b-c7d9-4d53-9825-0f87cd6abcda")
                    };
                    proxy1.ContainedInStructure.Guid = new Guid("000ab242-1337-4875-4242-d3414abcd531");
                    db.WriteFile(".\\" + folder + "\\Initial_" + proname + ".ifc");
                    db.WriteXmlFile(".\\" + folder + "\\Initial_" + proname + ".ifcxml");

                    //update
                    var point1 = new IfcCartesianPoint(db, 2, 2, 2);
                    placement1.Location = point1;


                    break;

                case "LinearPlacement_02":

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

                    profile2           = new IfcRectangleProfileDef(db, "rectangleProfileDef", 4, 6);
                    extrudedAreaSolid2 = new IfcExtrudedAreaSolid(profile2, 1.35);
                    shape2             = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid2));


                    IfcLine line1 = new IfcLine(new IfcCartesianPoint(db, 1, 1, 1)
                                                , new IfcVector(new IfcDirection(db, 1, 1), 20));

                    IfcLine line2 = new IfcLine(new IfcCartesianPoint(db, 1, -1, -1)
                                                , new IfcVector(new IfcDirection(db, -1, 1), 20));

                    var alignment1 = new IfcAlignment(site, line1)
                    {
                        Name = "Alignment1",
                        Guid = new Guid("fbcba4b2-1cdd-48d5-88bb-d3aced15bbaa")
                    };
                    var alignment2 = new IfcAlignment(site, line2)
                    {
                        Name = "Alignment2",
                        Guid = new Guid("f111a4b2-1c7d-4815-88bb-d3aced15bbaa")
                    };

                    var distn1 = new IfcPointByDistanceExpression(4, line1);
                    var distn2 = new IfcPointByDistanceExpression(2, line2);

                    //Deprecated but should be right for IFC4
                    var linearplace1 = new IfcLinearPlacement(line1, distn1)
                    {
                        Orientation = new IfcOrientationExpression(new IfcDirection(db, 0.5, 0.24),
                                                                   new IfcDirection(db, -0.24, 0.5))
                    };
                    var linearplace2 = new IfcLinearPlacement(line2, distn2)
                    {
                        Orientation = new IfcOrientationExpression(new IfcDirection(db, 0.75, 0.24),
                                                                   new IfcDirection(db, -0.24, 0.66))
                    };

                    proxy1 = new IfcBuildingElementProxy(site, linearplace1, shape1)
                    {
                        Name = "Cuboid1",
                        Guid = new Guid("fbcba4b2-1c7d-4815-88bb-d3aced15bbaa")
                    };
                    proxy1.ContainedInStructure.Guid = new Guid("000cc222-1337-4875-4242-d3b00abcd531");
                    proxy2 = new IfcBuildingElementProxy(site, linearplace2, shape2)
                    {
                        Name = "Cuboid2",
                        Guid = new Guid("f821963b-c7d9-4d53-98a5-0f8ccd6abcda")
                    };
                    proxy1.ContainedInStructure.Guid = new Guid("000ccc42-1337-4875-4242-d3414abcd531");
                    db.WriteFile(".\\" + folder + "\\Initial_" + proname + ".ifc");
                    db.WriteXmlFile(".\\" + folder + "\\Initial_" + proname + ".ifcxml");

                    //Update

                    IfcLine line3 = new IfcLine(new IfcCartesianPoint(db, 0, 1, 0)
                                                , new IfcVector(new IfcDirection(db, 0, 5, 2), 15));
                    var distn3 = new IfcPointByDistanceExpression(4, line3);

                    linearplace1.PlacementMeasuredAlong = line3;
                    linearplace1.Distance = distn3;


                    break;


                default:
                    //exit
                    return;
                }

                db.WriteFile(".\\" + folder + "\\Update_" + proname + ".ifc");
                db.WriteXmlFile(".\\" + folder + "\\Update_" + proname + ".ifcxml");
            }
        }
Пример #21
0
        internal static void GenerateInstance(IfcBuilding building, bool assembly)
        {
            DatabaseIfc          db = building.Database;
            IfcDocumentReference documentReference = new IfcDocumentReference(db)
            {
                Name = "MyReinforcementCode", Identification = "MyCodeISO3766"
            };
            IfcRelAssociatesDocument associatesDocument = new IfcRelAssociatesDocument(db.Project, documentReference)
            {
                GlobalId = "1R7R97$uLAAv4wci$KGwn8"
            };
            IfcMaterial material = new IfcMaterial(db, "ReinforcingSteel");
            List <Tuple <double, double, double> > points = new List <Tuple <double, double, double> >()
            {
                new Tuple <double, double, double>(-69.0, 0.0, -122.0), new Tuple <double, double, double>(-69.0, 0.0, -79.0), new Tuple <double, double, double>(-54.9411254969541, 0.0, -45.0588745030455), new Tuple <double, double, double>(-21.0, 0.0, -31.0), new Tuple <double, double, double>(21.0, 0.0, -31.0), new Tuple <double, double, double>(54.9411254969541, 0.0, -45.0588745030455), new Tuple <double, double, double>(69.0, 0.0, -78.9999999999999), new Tuple <double, double, double>(69.0, 0.00000000000000089, -321.0), new Tuple <double, double, double>(54.9939785957165, 1.21791490472034, -354.941125496954), new Tuple <double, double, double>(21.1804517666074, 4.15822158551252, -369.0), new Tuple <double, double, double>(-20.6616529376114, 7.79666547283599, -369.0), new Tuple <double, double, double>(-54.4751797667207, 10.7369721536282, -354.941125496954), new Tuple <double, double, double>(-68.4812011710042, 11.9548870583485, -321.0), new Tuple <double, double, double>(-69.0, 12.0, -79.0), new Tuple <double, double, double>(-54.9411254969541, 12.0, -45.0588745030455), new Tuple <double, double, double>(-21.0, 12.0, -31.0), new Tuple <double, double, double>(21.0, 12.0, -31.0), new Tuple <double, double, double>(54.9411254969541, 12.0, -45.0588745030455), new Tuple <double, double, double>(69.0, 12.0, -78.9999999999999), new Tuple <double, double, double>(69.0, 12.0, -122.0),
            };
            IfcBoundedCurve directrix = null;

            if (db.Release == ReleaseVersion.IFC2x3)
            {
                directrix = new IfcPolyline(db, points);
            }
            else
            {
                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, 7));
                segments.Add(new IfcLineIndex(7, 8));
                segments.Add(new IfcArcIndex(8, 9, 10));
                segments.Add(new IfcLineIndex(10, 11));
                segments.Add(new IfcArcIndex(11, 12, 13));
                segments.Add(new IfcLineIndex(13, 14));
                segments.Add(new IfcArcIndex(14, 15, 16));
                segments.Add(new IfcLineIndex(16, 17));
                segments.Add(new IfcArcIndex(17, 18, 19));
                segments.Add(new IfcLineIndex(19, 20));
                directrix = new IfcIndexedPolyCurve(new IfcCartesianPointList3D(db, points), segments);
            }
            double                barDiameter = 12, area = Math.PI * Math.Pow(barDiameter, 2) / 4;
            IfcSweptDiskSolid     sweptDiskSolid     = new IfcSweptDiskSolid(directrix, barDiameter / 2.0);
            IfcRepresentationMap  representationMap  = new IfcRepresentationMap(sweptDiskSolid);
            string                shapeCode          = ""; //Todo
            IfcReinforcingBarType reinforcingBarType = new IfcReinforcingBarType(db, "12 Diameter Ligature", IfcReinforcingBarTypeEnum.LIGATURE, barDiameter, area, 1150, IfcReinforcingBarSurfaceEnum.TEXTURED, shapeCode, null)
            {
                GlobalId = "0jMRtfHYXE7u4s_CQ2uVE9", MaterialSelect = material
            };

            reinforcingBarType.RepresentationMaps.Add(representationMap);
            db.Context.AddDeclared(reinforcingBarType);
            if (assembly)
            {
                IfcMaterial concrete = new IfcMaterial(db, "Concrete")
                {
                    Category = "Concrete"
                };
                string name = "400x200RC";
                IfcRectangleProfileDef rectangleProfileDef = new IfcRectangleProfileDef(db, name, 200, 400);
                IfcMaterialProfile     materialProfile     = new IfcMaterialProfile(name, concrete, rectangleProfileDef);

                IfcBeamType beamType = new IfcBeamType(name, materialProfile, IfcBeamTypeEnum.BEAM);
                db.Context.AddDeclared(beamType);
                IfcMaterialProfileSet materialProfileSet = beamType.MaterialSelect as IfcMaterialProfileSet;
                IfcBeam beam = new IfcBeam(building, new IfcLocalPlacement(building.Placement, new IfcAxis2Placement3D(new IfcCartesianPoint(db, 0, 0, 0))), null)
                {
                    Description = "Reinforced Beam"
                };
                IfcBeamStandardCase beamStandardCase = new IfcBeamStandardCase(beam, new IfcMaterialProfileSetUsage(materialProfileSet, IfcCardinalPointReference.TOPMID), new IfcAxis2Placement3D(new IfcCartesianPoint(db, 0, 0, 0), new IfcDirection(db, 0, 1, 0), new IfcDirection(db, -1, 0, 0)), 5000)
                {
                    GlobalId = "1yjQ2DwLnCC8k3i3X6D_ut", RelatingType = beamType
                };
                IfcElementAssembly elementAssembly = new IfcElementAssembly(beam, IfcAssemblyPlaceEnum.FACTORY, IfcElementAssemblyTypeEnum.REINFORCEMENT_UNIT);
                List <string>      ids             = new List <string>()
                {
                    "0ohBfsArr3ruXYxacT4yl5", "3YrK7RbE122fNRsP5djFAe", "0wxAc63nj5AezFhfks7wLL", "0bsov2wZL6tRRZmKy4vuUU", "3qrgfIBb92ZegJTle7jou3", "16m6R3JeT83fJPCze2yU$a", "2SGIIYjSbCuu3HVwoLt1yh", "0PsLby6eL8_hVEt4QwK0lZ", "1325VJou5AngWp1djcV0hL", "20zj_$BcH74xRgR4bDrLNb", "3M4SfEMtHEJukgZR4hw$eV", "23BYnIaOLBZPVTrKVEDJiy", "2XulRByDL8ugyo4Uqv9rJr", "2xvQMSga96XOT3VeCS6ZsK", "2gUE6_w3j77f8YJGz_2RMl", "0J0dRL4tT93REAabfASDom", "048RJ151b81PqODsTMD4EA", "3hXx9Kb6b5bvjgr9pwvpz0", "0FmUHg8ZX0ZfY$0f5nkM2l", "2_zvpwRdvAuRiTlHXX$Qp8", "1mhkXHKfX6PxdS2vZn17wX", "0CeIQzUqP5qOOeAjMtH2OX", "3shtoAQL5BAhvwA_1Ph$lC", "22j4RNKqD2IBRDGig5eaCF", "3Wvu6qGJH4ChhTV3pl9CGh", "37Qrf07Iz3tRMbSxEA4ynH", "2gelqZ1Wv8BvCy6TstVGkd", "1Q21dHc_X7eRppCHrT69Vb", "0e6Wc08NLD59ueqCAK1gxp", "3xdMOSZMj3cBOV_QTbXZha", "1r_U9JTkHDWwkv_nfWFHVe", "29I7_S2fT3WRD4zPH4YjmD", "0$ciATTaP17PJMHQD0$N3Y", "1irBeCCUf82wdGg7qTPCbW"
                };
                int jcounter = 0;
                for (int icounter = 25; icounter < 5000; icounter += 150)
                {
                    IfcElement element = reinforcingBarType.GenerateMappedItemElement(elementAssembly, new IfcCartesianTransformationOperator3D(db)
                    {
                        LocalOrigin = new IfcCartesianPoint(db, 0, icounter, 0)
                    });
                    //Unique ids assigned to generate constant IfcScript  sample files, remove otherwise
                    element.GlobalId = ids[jcounter++];
                }

                //Unique ids assigned to generate constant IfcScript  sample files, remove otherwise
                beam.GlobalId     = "1_KSmTR8T8bO37iRs24GkM";
                beamType.GlobalId = "3bdpqVuWTCbxJ2S3ODYv6q";
                beamType.ObjectTypeOf.GlobalId = "2oaQVVf79BrwRouvtRuQVg";
                beamType.MaterialSelect.Associates.GlobalId         = "2ZEgyI2v184hwa$_diRqS9";
                beamStandardCase.MaterialSelect.Associates.GlobalId = "3DWeleqqjEG9KshbOZXUdY";
                elementAssembly.GlobalId = "0Q1tCJWdj4kOkZUg7rkf2h";
                elementAssembly.IsDecomposedBy[0].GlobalId = "1WdB196Kb72f_pKgj5rklU";
                beam.IsDecomposedBy[0].GlobalId            = "1b1SnKocD0WRevlg8Aqhj5";
            }
            else
            {
                IfcElement element = reinforcingBarType.GenerateMappedItemElement(building, new IfcCartesianTransformationOperator3D(db));

                //Unique ids assigned to generate constant IfcScript  sample files, remove otherwise
                element.GlobalId = "0WUveBtSTDbunNjDLsuRn$";
            }

            //Unique ids assigned to generate constant IfcScript  sample files, remove otherwise

            reinforcingBarType.ObjectTypeOf.GlobalId = "1iAfl2ERbFmwi7uniy1H7j";
            reinforcingBarType.MaterialSelect.Associates.GlobalId = "3gfVO40P5EfQyKZ_bF0R$6";
        }
Пример #22
0
        private static IfcBeam CreatePurlin(XbimModel model, HndzPurlin genericProducthndz)
        {
            using (XbimReadWriteTransaction txn = model.BeginTransaction("Create Purlin"))
            {
                IfcBeam beam = model.Instances.New <IfcBeam>();
                IfcExtrudedAreaSolid body = model.Instances.New <IfcExtrudedAreaSolid>();
                body.Depth = genericProducthndz.ExtrusionLine.RhinoLine.Length;

                IfcBeamType elementType = model.Instances.New <IfcBeamType>();
                elementType.PredefinedType = IfcBeamTypeEnum.USERDEFINED;

                IfcMaterial material = model.Instances.New <IfcMaterial>();
                material.Name = "STEEL";
                beam.SetMaterial(material);
                IfcCartesianPoint insertPoint = model.Instances.New <IfcCartesianPoint>();

                insertPoint.SetXY(genericProducthndz.ExtrusionLine.baseNode.Point.X, genericProducthndz.ExtrusionLine.baseNode.Point.Y); //insert at arbitrary position//****************Need Revision

                if (genericProducthndz.Profile is HndzRectangularProfile)
                {
                    HndzRectangularProfile recProfile = genericProducthndz.Profile as HndzRectangularProfile;

                    #region Type & Material &Tags

                    string typeText = "HANDAZ-Column-Rectangular " + (int)recProfile.Rectangle.Width + " x "
                                      + (int)recProfile.Rectangle.Height + " mm";

                    elementType.Tag  = typeText;
                    elementType.Name = typeText;
                    IfcLabel columnLabel = new IfcLabel(typeText);
                    elementType.ElementType          = columnLabel;
                    elementType.ApplicableOccurrence = columnLabel;



                    beam.Tag         = typeText;
                    beam.Name        = typeText;
                    beam.Description = typeText;
                    beam.SetDefiningType(elementType, model);

                    #endregion

                    //represent column as a rectangular profile
                    IfcRectangleProfileDef MyPurlinPofile = model.Instances.New <IfcRectangleProfileDef>();
                    MyPurlinPofile.ProfileType           = IfcProfileTypeEnum.AREA;
                    MyPurlinPofile.XDim                  = recProfile.Rectangle.Height;
                    MyPurlinPofile.YDim                  = recProfile.Rectangle.Width;
                    MyPurlinPofile.Position              = model.Instances.New <IfcAxis2Placement2D>();
                    MyPurlinPofile.Position.RefDirection = model.Instances.New <IfcDirection>();
                    MyPurlinPofile.Position.RefDirection.SetXY(recProfile.OrientationInPlane.X, recProfile.OrientationInPlane.Y);
                    //MyColumnPofile.Position.Location = insertPoint;

                    //model as a swept area solid
                    body.SweptArea = MyPurlinPofile;
                }
                if (genericProducthndz.Profile is HndzISectionProfile)
                {
                    HndzISectionProfile Iprofile = genericProducthndz.Profile as HndzISectionProfile;

                    #region Type & Material &Tags

                    string typeText = "HANDAZ-Purlin-I beam (flange " + Iprofile.I_Section.b_f + " x " + Iprofile.I_Section.t_fTop + " and web "
                                      + Iprofile.I_Section.d + " x " + Iprofile.I_Section.t_w + " mm";


                    elementType.Tag  = typeText;
                    elementType.Name = typeText;
                    IfcLabel columnLabel = new IfcLabel(typeText);
                    elementType.ElementType          = columnLabel;
                    elementType.ApplicableOccurrence = columnLabel;



                    beam.Tag         = typeText;
                    beam.Name        = typeText;
                    beam.Description = typeText;
                    beam.SetDefiningType(elementType, model);

                    #endregion
                    // IfcPolyline pl = model.Instances.New<IfcPolyline>();

                    //List<Point3d> tempPoints= Iprofile.ConvertItoPoints();
                    // foreach (Point3d point in tempPoints)
                    // {
                    //     IfcCartesianPoint tempPoint = model.Instances.New<IfcCartesianPoint>();
                    //     tempPoint.SetXYZ(point.X, point.Y, point.Z);
                    //     pl.Points.Add(tempPoint);
                    // }

                    IfcIShapeProfileDef MyPurlinPofile = model.Instances.New <IfcIShapeProfileDef>();
                    MyPurlinPofile.FlangeThickness = Iprofile.I_Section.tf;
                    MyPurlinPofile.WebThickness    = Iprofile.I_Section.t_w;
                    MyPurlinPofile.OverallWidth    = Iprofile.I_Section.b_f;
                    MyPurlinPofile.OverallDepth    = Iprofile.I_Section.d;
                    MyPurlinPofile.FilletRadius    = 10;

                    MyPurlinPofile.Position = model.Instances.New <IfcAxis2Placement2D>();
                    MyPurlinPofile.Position.RefDirection = model.Instances.New <IfcDirection>();
                    MyPurlinPofile.Position.RefDirection.SetXY(Iprofile.OrientationInPlane.X, Iprofile.OrientationInPlane.Y);
                    //MyColumnPofile.Position.Location = insertPoint;

                    //model as a swept area solid
                    body.SweptArea = MyPurlinPofile;
                }
                if (genericProducthndz.Profile is HndzCSectionProfile)
                {
                    HndzCSectionProfile Cprofile = genericProducthndz.Profile as HndzCSectionProfile;

                    #region Type & Material &Tags

                    string typeText = "HANDAZ-Purlin-C-Chanel (flange " + Cprofile.C_Section.b_f + " x " + Cprofile.C_Section.t_f + " and web "
                                      + Cprofile.C_Section.d + " x " + Cprofile.C_Section.t_w + " mm";


                    elementType.Tag  = typeText;
                    elementType.Name = typeText;
                    IfcLabel columnLabel = new IfcLabel(typeText);
                    elementType.ElementType          = columnLabel;
                    elementType.ApplicableOccurrence = columnLabel;


                    beam.Tag         = typeText;
                    beam.Name        = typeText;
                    beam.Description = typeText;
                    beam.SetDefiningType(elementType, model);

                    #endregion

                    IfcCShapeProfileDef MyPurlinPofile = model.Instances.New <IfcCShapeProfileDef>();
                    MyPurlinPofile.WallThickness = Cprofile.C_Section.t_f;
                    //MyColumnPofile.WebThickness = Iprofile.C_Section.t_w; //ToDo:purlin web and flange thickness are the same!!!!
                    MyPurlinPofile.Width = Cprofile.C_Section.b_f;
                    MyPurlinPofile.Depth = Cprofile.C_Section.d;
                    MyPurlinPofile.InternalFilletRadius = 10;

                    MyPurlinPofile.Position = model.Instances.New <IfcAxis2Placement2D>();
                    MyPurlinPofile.Position.RefDirection = model.Instances.New <IfcDirection>();
                    MyPurlinPofile.Position.RefDirection.SetXY(Cprofile.OrientationInPlane.X, Cprofile.OrientationInPlane.Y);


                    //model as a swept area solid
                    body.SweptArea = MyPurlinPofile;
                }
                body.ExtrudedDirection = model.Instances.New <IfcDirection>();
                body.ExtrudedDirection.SetXYZ(0, 0, 1);
                //body.ExtrudedDirection.SetXYZ(Hndzcol.ExtrusionLine.RhinoLine.Direction.X, Hndzcol.ExtrusionLine.RhinoLine.Direction.Y, Hndzcol.ExtrusionLine.RhinoLine.Direction.Z);


                //parameters to insert the geometry in the model
                IfcCartesianPoint origin = model.Instances.New <IfcCartesianPoint>();
                origin.SetXYZ(genericProducthndz.ExtrusionLine.baseNode.Point.X, genericProducthndz.ExtrusionLine.baseNode.Point.Y, genericProducthndz.ExtrusionLine.baseNode.Point.Z);

                body.Position = model.Instances.New <IfcAxis2Placement3D>();
                //body.Position.Location = origin;

                body.Position.RefDirection = model.Instances.New <IfcDirection>();
                body.Position.RefDirection.SetXYZ(1, 0, 0);

                //Create a Definition shape to hold the geometry
                IfcShapeRepresentation shape = model.Instances.New <IfcShapeRepresentation>();
                shape.ContextOfItems           = model.IfcProject.ModelContext();
                shape.RepresentationType       = "SweptSolid";
                shape.RepresentationIdentifier = "Body";
                shape.Items.Add(body);

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

                beam.Representation = rep;

                //now place the column into the model
                IfcLocalPlacement   lp   = model.Instances.New <IfcLocalPlacement>();
                IfcAxis2Placement3D ax3d = model.Instances.New <IfcAxis2Placement3D>();
                ax3d.Location = origin;

                Vector3d perpendicularVector = new Vector3d(genericProducthndz.Profile.OrientationInPlane.X, genericProducthndz.Profile.OrientationInPlane.Y, 0);

                Plane extrusionPlane;
                bool  aa = genericProducthndz.ExtrusionLine.RhinoLine.TryGetPlane(out extrusionPlane);
                if (aa)
                {
                    perpendicularVector = extrusionPlane.ZAxis;
                }



                ax3d.RefDirection = model.Instances.New <IfcDirection>();
                ax3d.RefDirection.SetXYZ(perpendicularVector.X, perpendicularVector.Y, perpendicularVector.Z);
                ax3d.Axis = model.Instances.New <IfcDirection>();
                ax3d.Axis.SetXYZ(genericProducthndz.ExtrusionLine.RhinoLine.Direction.X, genericProducthndz.ExtrusionLine.RhinoLine.Direction.Y, genericProducthndz.ExtrusionLine.RhinoLine.Direction.Z);

                lp.RelativePlacement = ax3d;
                beam.ObjectPlacement = lp;

                #region Owner Data
                beam.OwnerHistory.OwningUser        = model.DefaultOwningUser;
                beam.OwnerHistory.OwningApplication = model.DefaultOwningApplication;
                #endregion

                //validate write any errors to the console and commit if OK, otherwise abort
                string temp = Path.GetTempPath();
                //if (model.Validate(txn.Modified(), File.CreateText("E:\\Column" + column.GlobalId + "Errors.txt")) == 0)
                // if (model.Validate(txn.Modified(), File.CreateText(temp + "Column" + column.GlobalId + "Errors.txt")) == 0)
                if (model.Validate(txn.Modified(), Console.Out) == 0)
                {
                    txn.Commit();
                    return(beam);
                }

                return(null);
            }
        }
        /// <summary>
        /// Add a Bounding Box extrusion onto the ifcProduct
        /// </summary>
        /// <param name="row">COBieCoordinateRow holding the data for one corner</param>
        /// <param name="rowNext">COBieCoordinateRow holding the data for the other corner</param>
        /// <param name="placementRelToIfcProduct">Product which is parent of ifcProduct passed product to add extrusion onto</param>
        /// <param name="ifcProduct">IfcProduct to add the extrusion onto</param>
        private void AddExtrudedRectangle(COBieCoordinateRow row, COBieCoordinateRow rowNext, IfcProduct ifcProduct, IfcProduct placementRelToIfcProduct)
        {
            if (ifcProduct != null)
            {
                COBieCoordinateRow lowerLeftRow, upperRightRow;
                if (row.Category.ToLower() == "box-lowerleft")
                {
                    lowerLeftRow  = row;
                    upperRightRow = rowNext;
                }
                else
                {
                    lowerLeftRow  = rowNext;
                    upperRightRow = row;
                }
                IfcLocalPlacement objectPlacement = CalcObjectPlacement(lowerLeftRow, placementRelToIfcProduct);
                if (objectPlacement != null)
                {
                    //set the object placement for the space
                    ifcProduct.ObjectPlacement = objectPlacement;

                    //get matrix to the space placement
                    XbimMatrix3D matrix3D = ConvertMatrix3D(objectPlacement);
                    //invert matrix so we can convert row points back to the object space
                    matrix3D.Invert();
                    //lets get the points from the two rows
                    XbimPoint3D lowpt, highpt;
                    if ((GetPointFromRow(upperRightRow, out highpt)) &&
                        (GetPointFromRow(lowerLeftRow, out lowpt))
                        )
                    {
                        //transform the points back to object space
                        lowpt  = matrix3D.Transform(lowpt);
                        highpt = matrix3D.Transform(highpt);
                        //in object space so we can use Rect3D as this will be aligned with coordinates systems X and Y
                        XbimRect3D bBox = new XbimRect3D();
                        bBox.Location = lowpt;
                        bBox.Union(highpt);
                        if ((double.NaN.CompareTo(bBox.SizeX) != 0) && (double.NaN.CompareTo(bBox.SizeY) != 0))
                        {
                            XbimPoint3D ctrPt = new XbimPoint3D(bBox.X + (bBox.SizeX / 2.0), bBox.Y + (bBox.SizeY / 2.0), bBox.Z + (bBox.SizeZ / 2.0));

                            //Create IfcRectangleProfileDef
                            IfcCartesianPoint      IfcCartesianPointCtr   = Model.Instances.New <IfcCartesianPoint>(cp => { cp.X = ctrPt.X; cp.Y = ctrPt.Y; cp.Z = 0.0; }); //centre point of 2D box
                            IfcDirection           IfcDirectionXDir       = Model.Instances.New <IfcDirection>(d => { d.X = 1.0; d.Y = 0; d.Z = 0.0; });                    //default to X direction
                            IfcAxis2Placement2D    ifcAxis2Placement2DCtr = Model.Instances.New <IfcAxis2Placement2D>(a2p => { a2p.Location = IfcCartesianPointCtr; a2p.RefDirection = IfcDirectionXDir; });
                            IfcRectangleProfileDef ifcRectangleProfileDef = Model.Instances.New <IfcRectangleProfileDef>(rpd => { rpd.ProfileType = IfcProfileTypeEnum.AREA; rpd.ProfileName = row.RowName; rpd.Position = ifcAxis2Placement2DCtr; rpd.XDim = bBox.SizeX; rpd.YDim = bBox.SizeY; });

                            //Create IfcExtrudedAreaSolid
                            IfcDirection         IfcDirectionAxis            = Model.Instances.New <IfcDirection>(d => { d.X = 0.0; d.Y = 0; d.Z = 1.0; });            //default to Z direction
                            IfcDirection         IfcDirectionRefDir          = Model.Instances.New <IfcDirection>(d => { d.X = 1.0; d.Y = 0; d.Z = 0.0; });            //default to X direction
                            IfcCartesianPoint    IfcCartesianPointPosition   = Model.Instances.New <IfcCartesianPoint>(cp => { cp.X = 0.0; cp.Y = 0.0; cp.Z = 0.0; }); //centre point of 2D box
                            IfcAxis2Placement3D  ifcAxis2Placement3DPosition = Model.Instances.New <IfcAxis2Placement3D>(a2p3D => { a2p3D.Location = IfcCartesianPointPosition; a2p3D.Axis = IfcDirectionAxis; a2p3D.RefDirection = IfcDirectionRefDir; });
                            IfcDirection         IfcDirectionExtDir          = Model.Instances.New <IfcDirection>(d => { d.X = 0.0; d.Y = 0; d.Z = 1.0; });            //default to Z direction
                            IfcExtrudedAreaSolid ifcExtrudedAreaSolid        = Model.Instances.New <IfcExtrudedAreaSolid>(eas => { eas.SweptArea = ifcRectangleProfileDef; eas.Position = ifcAxis2Placement3DPosition; eas.ExtrudedDirection = IfcDirectionExtDir; eas.Depth = bBox.SizeZ; });
                            var project = Model.FederatedInstances.OfType <IfcProject>().FirstOrDefault();
                            //Create IfcShapeRepresentation
                            IfcShapeRepresentation ifcShapeRepresentation = Model.Instances.New <IfcShapeRepresentation>(sr =>
                            {
                                sr.ContextOfItems           = project.ModelContext;
                                sr.RepresentationIdentifier = "Body"; sr.RepresentationType = "SweptSolid";
                            });
                            ifcShapeRepresentation.Items.Add(ifcExtrudedAreaSolid);

                            //create IfcProductDefinitionShape
                            IfcProductDefinitionShape ifcProductDefinitionShape = Model.Instances.New <IfcProductDefinitionShape>(pds => { pds.Name = row.Name; pds.Description = row.SheetName; });
                            ifcProductDefinitionShape.Representations.Add(ifcShapeRepresentation);

                            //Link to the IfcProduct
                            ifcProduct.Representation = ifcProductDefinitionShape;
                        }
                        else
                        {
#if DEBUG
                            Console.WriteLine("Failed to calculate box size for {0}", row.Name);
#endif
                        }
                    }
                }
                else
                {
#if DEBUG
                    Console.WriteLine("Failed to add Object placement for {0}", row.Name);
#endif
                }
            }
        }
Пример #24
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);
            }
        }
Пример #25
0
        private IfcFooting CreateIfcFooting(IfcStore model, FootingBase cadFooting)
        {
            //cadFooting.Length *= 1000;
            //cadFooting.Width *= 1000;

            //cadFooting.CenterPt.X *= 1000;
            //cadFooting.CenterPt.Y *= 1000;
            //cadFooting.PtLengthDir.X *= 1000;
            //cadFooting.PtLengthDir.Y *= 1000;
            //
            double length = cadFooting.Length;
            double width  = cadFooting.Width;

            //begin a transaction
            using (var trans = model.BeginTransaction("Create Footing"))
            {
                IfcFooting footingToCreate = model.Instances.New <IfcFooting>();
                footingToCreate.Name = " Foundation - Footing:UC305x305x97: " + random.Next(1000, 10000);

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

                //Profile Insertion Point
                rectProf.ProfileInsertionPointSet(model, 0, 0);


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

                IfcExtrudedAreaSolid body = IFCHelper.ProfileSweptSolidCreate(model, cadFooting.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 wall
                IfcProductDefinitionShape prDefShape = model.Instances.New <IfcProductDefinitionShape>();
                prDefShape.Representations.Add(shape);
                footingToCreate.Representation = prDefShape;

                //Create Local axes system and assign it to the wall

                IfcCartesianPoint location3D = model.Instances.New <IfcCartesianPoint>();
                location3D.SetXYZ(cadFooting.CenterPt.X, cadFooting.CenterPt.Y, cadFooting.CenterPt.Z);

                var uvFootingLongDir = MathHelper.UnitVectorFromPt1ToPt2(cadFooting.CenterPt, cadFooting.PtLengthDir);

                IfcDirection localXDir = model.Instances.New <IfcDirection>();
                localXDir.SetXYZ(uvFootingLongDir.X, uvFootingLongDir.Y, uvFootingLongDir.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
                IfcLocalPlacement lp = IFCHelper.LocalPlacemetCreate(model, ax3D);
                footingToCreate.ObjectPlacement = lp;


                trans.Commit();
                return(footingToCreate);
            }
        }
Пример #26
0
        /// <summary>
        /// This creates a wall and it's geometry, many geometric representations are possible and extruded rectangular footprint is chosen as this is commonly used for standard case walls
        /// </summary>
        /// <param name="model"></param>
        /// <param name="length">Length of the rectangular footprint</param>
        /// <param name="width">Width of the rectangular footprint (width of the wall)</param>
        /// <param name="height">Height to extrude the wall, extrusion is vertical</param>
        /// <returns></returns>
        private IfcWallStandardCase CreateIfcWall(IfcStore model, Wall cadWall, double height)
        {
            //cadWall.Thickness *= 1000;
            //cadWall.StPt.X *= 1000;
            //cadWall.StPt.Y*= 1000;
            //cadWall.EndPt.X *= 1000;
            //cadWall.EndPt.Y *= 1000;

            //dimensions of the new IFC Wall we want to create
            double length = Math.Abs(cadWall.EndPt.X - cadWall.StPt.X) > 0 ? Math.Abs(cadWall.EndPt.X - cadWall.StPt.X)  : Math.Abs(cadWall.EndPt.Y - cadWall.StPt.Y);
            double width  = cadWall.Thickness;

            //begin a transaction
            using (var trans = model.BeginTransaction("Create Wall"))
            {
                IfcWallStandardCase wallToCreate = model.Instances.New <IfcWallStandardCase>();
                wallToCreate.Name = " Wall - Wall: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);

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


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

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

                //Create a Definition shape to hold the geometry of the wall 3D body
                IfcShapeRepresentation shape = IFCHelper.ShapeRepresentationCreate(model, "SweptSolid", "Body");
                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);
                wallToCreate.Representation = prDefShape;

                //Create Local axes system and assign it to the wall
                var midPt = MathHelper.MidPoint3D(cadWall.StPt, cadWall.EndPt);

                IfcCartesianPoint location3D = model.Instances.New <IfcCartesianPoint>();
                location3D.SetXYZ(midPt.X, midPt.Y, midPt.Z);

                var uvWallLongDir = MathHelper.UnitVectorFromPt1ToPt2(cadWall.StPt, cadWall.EndPt);

                IfcDirection localXDir = model.Instances.New <IfcDirection>();
                localXDir.SetXYZ(uvWallLongDir.X, uvWallLongDir.Y, uvWallLongDir.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
                IfcLocalPlacement lp = IFCHelper.LocalPlacemetCreate(model, ax3D);

                wallToCreate.ObjectPlacement = lp;


                // IfcPresentationLayerAssignment is required for CAD presentation in IfcWall or IfcWallStandardCase
                var ifcPresentationLayerAssignment = model.Instances.New <IfcPresentationLayerAssignment>();
                ifcPresentationLayerAssignment.Name = "some ifcPresentationLayerAssignment";
                ifcPresentationLayerAssignment.AssignedItems.Add(shape);

                trans.Commit();
                return(wallToCreate);
            }
        }
Пример #27
0
        public static double GetArea(this IfcProfileDef Profile)
        {
            // Inheritance tree of IfcProfileDef:
            //
            //- IfcArbitraryClosedProfileDef (Throw)
            //  - IfcArbitraryProfileDefWithVoids (Throw)
            //- IfcArbitraryOpenProfileDef (x)
            //  - IfcCenterLineProfileDef (x)
            //- IfcParameterizedProfileDef  (abstract)
            //  - IfcIShapeProfileDef (x)
            //    - IfcAsymmetricIShapeProfileDef (x)
            //  - IfcCircleProfileDef (x)
            //    - IfcCircleHollowProfileDef (x)
            //  - IfcCraneRailAShapeProfileDef (Throw)
            //  - IfcCraneRailFShapeProfileDef (Throw)
            //  - IfcCShapeProfileDef (x)
            //  - IfcEllipseProfileDef (x)
            //  - IfcLShapeProfileDef (Throw)
            //  - IfcRectangleProfileDef (x)
            //    - IfcRectangleHollowProfileDef (x)
            //    - IfcRoundedRectangleProfileDef (x)
            //  - IfcTrapeziumProfileDef (x)
            //  - IfcTShapeProfileDef (Throw)
            //  - IfcUShapeProfileDef (Throw)
            //  - IfcZShapeProfileDef (Throw)
            //- IfcCompositeProfileDef
            if (Profile is IfcArbitraryProfileDefWithVoids)
            {
                throw new NotImplementedException("IfcArbitraryProfileDefWithVoids Area is not implemented");
            }
            else if (Profile is IfcArbitraryClosedProfileDef)
            {
                throw new NotImplementedException("IfcArbitraryClosedProfileDef Area is not implemented");
            }
            else if (Profile is IfcRoundedRectangleProfileDef)
            {
                IfcRoundedRectangleProfileDef p = Profile as IfcRoundedRectangleProfileDef;
                return((p.XDim * p.YDim) - (4 * ConcaveRightAngleFilletArea(p.RoundingRadius)));
            }
            else if (Profile is IfcRectangleHollowProfileDef)
            {
                IfcRectangleHollowProfileDef p = Profile as IfcRectangleHollowProfileDef;

                // outer area
                double outerFillet = 0;
                if (p.OuterFilletRadius.HasValue)
                {
                    outerFillet = p.OuterFilletRadius.Value;
                }
                double outer = (p.XDim * p.YDim) - (4 * ConcaveRightAngleFilletArea(outerFillet));
                // inner area
                double innerFillet = 0;
                if (p.InnerFilletRadius.HasValue)
                {
                    innerFillet = p.InnerFilletRadius.Value;
                }
                double inner = ((p.XDim - 2 * p.WallThickness) * (p.YDim - 2 * p.WallThickness))
                               - (4 * ConcaveRightAngleFilletArea(innerFillet));

                return(outer - inner);
            }
            else if (Profile is IfcRectangleProfileDef)
            {
                IfcRectangleProfileDef p = Profile as IfcRectangleProfileDef;
                return(p.XDim * p.YDim);
            }
            else if (Profile is IfcCircleHollowProfileDef)
            {
                IfcCircleHollowProfileDef p = Profile as IfcCircleHollowProfileDef;
                double outer = Math.PI * Math.Pow(p.Radius, 2);
                double inner = Math.PI * Math.Pow(p.Radius - p.WallThickness, 2);
                return(outer - inner);
            }
            else if (Profile is IfcCircleProfileDef)
            {
                IfcCircleProfileDef p = Profile as IfcCircleProfileDef;
                return(Math.PI * Math.Pow(p.Radius, 2));
            }
            else if (Profile is IfcCraneRailAShapeProfileDef)
            {
                // geometry is not clear
                throw new NotImplementedException("IfcCraneRailAShapeProfileDef Area is not implemented");
            }
            else if (Profile is IfcCraneRailFShapeProfileDef)
            {
                // geometry is not clear
                throw new NotImplementedException("IfcCraneRailFShapeProfileDef Area is not implemented");
            }
            else if (Profile is IfcCShapeProfileDef)
            {
                IfcCShapeProfileDef p = Profile as IfcCShapeProfileDef;

                // inner area
                double innerFillet = 0;
                if (p.InternalFilletRadius.HasValue)
                {
                    innerFillet = p.InternalFilletRadius.Value;
                }
                double inner = ((p.Width - 2 * p.WallThickness) * (p.Depth - 2 * p.WallThickness))
                               - (4 * ConcaveRightAngleFilletArea(innerFillet));

                // outer area
                double outerFillet = innerFillet + p.WallThickness;
                double outer       = (p.Width * p.Depth) - (4 * ConcaveRightAngleFilletArea(outerFillet));

                double girthSideVoid = (p.Depth - 2 * p.Girth) * p.WallThickness;

                //     closed loop area - missing part between girths
                return((outer - inner) - girthSideVoid);
            }
            else if (Profile is IfcEllipseProfileDef)
            {
                IfcEllipseProfileDef p = Profile as IfcEllipseProfileDef;
                return(Math.PI * p.SemiAxis1 * p.SemiAxis2);
            }
            else if (Profile is IfcLShapeProfileDef)
            {
                // geometry is not clear
                throw new NotImplementedException("IfcLShapeProfileDef Area is not implemented");
            }
            else if (Profile is IfcTrapeziumProfileDef)
            {
                IfcTrapeziumProfileDef p = Profile as IfcTrapeziumProfileDef;
                return((p.BottomXDim + p.TopXDim) * p.YDim / 2);
            }
            else if (Profile is IfcTShapeProfileDef)
            {
                // geometry is not clear
                throw new NotImplementedException("IfcTShapeProfileDef Area is not implemented");
            }
            else if (Profile is IfcUShapeProfileDef)
            {
                // geometry is not clear
                throw new NotImplementedException("IfcUShapeProfileDef Area is not implemented");
            }
            else if (Profile is IfcZShapeProfileDef)
            {
                // geometry is not clear
                throw new NotImplementedException("IfcZShapeProfileDef Area is not implemented");
            }
            else if (Profile is IfcAsymmetricIShapeProfileDef) // needs to be tested before IfcIShapeProfileDef
            {
                IfcAsymmetricIShapeProfileDef p = Profile as IfcAsymmetricIShapeProfileDef;
                // bottom flange
                double bottomflange = p.OverallWidth * p.FlangeThickness;
                // bottom flange
                double TopFlangeThickness = p.FlangeThickness; // if not specified differently
                if (p.TopFlangeThickness.HasValue)
                {
                    TopFlangeThickness = p.TopFlangeThickness.Value;
                }
                double topFlange = p.TopFlangeWidth * TopFlangeThickness;
                // core
                double core = (p.OverallDepth - p.FlangeThickness - TopFlangeThickness) * p.WebThickness;

                double bottomfillets = 0;
                double topFillets    = 0;
                if (p.FilletRadius.HasValue)
                {
                    bottomfillets = 2 * ConcaveRightAngleFilletArea(p.FilletRadius.Value);
                    topFillets    = bottomfillets;
                }
                if (p.TopFlangeFilletRadius.HasValue)
                {
                    topFillets = 2 * ConcaveRightAngleFilletArea(p.TopFlangeFilletRadius.Value);
                }
                return(bottomflange + topFlange + core + bottomfillets + topFillets);
            }
            else if (Profile is IfcIShapeProfileDef)
            {
                IfcIShapeProfileDef p = Profile as IfcIShapeProfileDef;
                double flanges        = p.OverallWidth * p.FlangeThickness * 2; // top and bottom flanges
                double core           = (p.OverallDepth - (p.FlangeThickness * 2)) * p.WebThickness;
                double fillets        = 0;
                if (p.FilletRadius.HasValue && p.FilletRadius.Value > 0)
                {
                    fillets = 4 * ConcaveRightAngleFilletArea(p.FilletRadius.Value);
                }
                return(flanges + core + fillets);
            }
            else if (Profile is IfcArbitraryOpenProfileDef)
            {
                return(0);
            }
            return(double.NaN);
        }
Пример #28
0
        internal static DatabaseIfc Generate(ModelView mvd, string path)
        {
            DatabaseIfc db = new DatabaseIfc(true, mvd);
            //IfcGeometricRepresentationContext
            //IfcCartesianPoint
            //IfcAxis2Placement3D
            //IfcDirection
            //IfcAxis2Placement2D
            //IfcSIUnit
            //IfcLocalPlacement
            IfcSite site = new IfcSite(db, "TestSite");
            //IfcPerson  NOT RV
            //IfcOrganization  NOT RV
            //IfcPersonAndOrganization  NOT RV
            //IfcOwnerHistory  NOT RV
            //fcApplication NOT RV
            //                     IfcProjectLibrary NOT RV Can't have multiple context
            IfcProject project = new IfcProject(site, "TestProject", IfcUnitAssignment.Length.Millimetre)
            {
            };
            //IfcUnitAssignment
            //IfcRelAggregates
            IfcBuilding building = new IfcBuilding(site, "TestBuilding")
            {
            };
            IfcBuildingStorey buildingStorey = new IfcBuildingStorey(building, "TestBuildingStorey", 200);
            IfcSpace          space          = new IfcSpace(buildingStorey, null)
            {
                Name = "TestSpace"
            };

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

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

            IfcLocalPlacement storeyLocalPlacement = buildingStorey.ObjectPlacement as IfcLocalPlacement;

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

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

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

            IfcBeamType beamType = new IfcBeamType(db, "TestBeamType", IfcBeamTypeEnum.BEAM);

            beamType.MaterialSelect = materialProfileSet;

            int beamXPosition = 1000, beamYposition = 0, beamXSpacing = 1000;
            int columnXPosition = -1000, columnYposition = 0, columnYSpacing = 1000;
            IfcCartesianPoint cartesianPoint = new IfcCartesianPoint(db, beamXPosition += beamXSpacing, beamYposition, 0);
            IfcBeam           beam           = createBeam(buildingStorey, arbitraryClosedProfileDef, cartesianPoint, "16KYUrH45BNwdHw8Y$ia8f");

            beam.setRelatingType(beamType);
            //IfcRelDefinesByType

            IfcProfileDef columnProfile = arbitraryClosedProfileDef;

            if (mvd != ModelView.Ifc4Reference)
            {
                columnProfile = new IfcIShapeProfileDef(db, "IShapeProfileDef", 500, 300, 15, 20)
                {
                    FilletRadius = 10
                }
            }
            ;

            IfcColumnType columnType = new IfcColumnType(db, "TestColumnType", IfcColumnTypeEnum.COLUMN);

            cartesianPoint = new IfcCartesianPoint(db, columnXPosition, columnYposition += columnYSpacing, 0);
            //IfcGeometricRepresentationSubContext
            IfcColumn column = createColumn(buildingStorey, columnProfile, cartesianPoint, "2jS8dBukzApveBm5m9QrBf");

            column.setRelatingType(columnType);

            if (mvd != ModelView.Ifc4Reference)
            {
                IfcCircleProfileDef circleProfileDef = circleProfileDef = new IfcCircleProfileDef(db, "TestCircleProfile", 350);
                cartesianPoint = new IfcCartesianPoint(db, columnXPosition, columnYposition += columnYSpacing, 0);
                createColumn(buildingStorey, circleProfileDef, cartesianPoint, "");

                IfcRectangleProfileDef rectangleProfileDef = new IfcRectangleProfileDef(db, "TestRectangle", 400, 600);
                cartesianPoint = new IfcCartesianPoint(db, beamXPosition += beamXSpacing, beamYposition, 0);
                createBeam(buildingStorey, rectangleProfileDef, cartesianPoint, "");

                IfcRectangleHollowProfileDef rectangleHollowProfileDef = new IfcRectangleHollowProfileDef(db, "TestRectangleHollow", 400, 600, 12);
                cartesianPoint = new IfcCartesianPoint(db, beamXPosition += beamXSpacing, beamYposition, 0);
                createBeam(buildingStorey, rectangleHollowProfileDef, cartesianPoint, "");
            }

            IfcProfileDef memberProfile = arbitraryClosedProfileDef;

            if (mvd != ModelView.Ifc4Reference)
            {
                memberProfile = new IfcCircleHollowProfileDef(db, "TestCircleHollowProfile", 75, 9);
            }
            cartesianPoint = new IfcCartesianPoint(db, -1000, -1000, 0);
            IfcProductDefinitionShape productDefinitionShape = new IfcProductDefinitionShape(new IfcShapeRepresentation(new IfcExtrudedAreaSolid(memberProfile, 2000)));
            IfcMember member = new IfcMember(buildingStorey, createLocalPlacement(buildingStorey, cartesianPoint, db.Factory.YAxisNegative), productDefinitionShape);

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

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