コード例 #1
0
        static void Main(string[] args)
        {
            Console.WriteLine(" --- PointCloud 2 IfcBridge Model --- \n");


            // --- Model Setup ---

            // create new Ifc4x2 Model
            var toolkit = new ModelSetupService();

            var model = toolkit.CreateModel("PT2IFC_Prototype", "Esser", "Sebastian");

            // create Site
            toolkit.CreateIfcSite(ref model, "SampleSite");

            // create bridge
            toolkit.CreateIfcBridgeEntity(ref model, "PTBridge", "ToolChain PT > Enrichment > IFC4x2 Model");

            // create Bridge Parts
            toolkit.CreateIfcBridgePartEntities(ref model);

            // get all files in the geometry folder
            var path  = "geometryFiles/";
            var files = System.IO.Directory.GetFiles(path, "*.off").ToList();

            // init product service
            var productService = new ProductService();

            foreach (var file in files)
            {
                Console.WriteLine("add new product: " + file);
                // load geometry
                var offGeom = new OffGeometry(file);

                // add product to model
                productService.AddBuildingElement(ref model, offGeom, file, "IfcBuildingElementProxy", "local", "Superstructure");
            }

            Console.WriteLine("Save Model... \n");

            // set time stamp in file name
            var date     = DateTime.Now;
            var dateStr  = date.ToString("yy-MM-dd", CultureInfo.CreateSpecificCulture("en-US"));
            var timeStr  = date.ToString("hh-mm", CultureInfo.CreateSpecificCulture("de-DE"));
            var fileName = dateStr + "_" + timeStr + "_" + "PT2IFC_bridge_v01.ifc";

            Console.WriteLine("Filename is: " + fileName);

            // save model
            model.SaveAs(fileName);

            // modify header
            toolkit.ModifyHeader(fileName);

            Console.WriteLine("Finished. Press button to exit. \n");

            var input = Console.ReadKey();
        }
コード例 #2
0
        public static Dictionary <string, object> AddDirectShapeComponents(
            IfcStore model,
            XbimEditorCredentials credentials,
            List <Element> elements,
            string ifcElementType,
            string ifcSpatialStructure)
        {
            var counter = 0;

            // Note: no transaction is required -> will be opened in the toolkit function
            foreach (var element in elements)
            {
                // init transporter for each element geometry
                var transporter = new DirectShapeToIfc();

                // --- add geometry to transporter ---
                InsertShape(element, ref transporter);

                // --- add placement to transporter ---
                var location = element.Solids?.FirstOrDefault()?.Centroid();
                if (location != null)
                {
                    transporter.location.Position = new Point3D(location.X, location.Y, location.Z); // insert Revit coordinates into transporter
                }
                else
                {
                    transporter.location.Position = new Point3D(0, 0, 0);
                }

                // use IfcBridgeToolKit to generate a new IfcBuildingElement instance in the current model
                var productService = new ProductService();
                productService.AddBuildingElement(
                    ref model,                               // the Ifc Model
                    transporter,                             // the container for all geometry-related content
                    "BuildingElement " + counter.ToString(), // the bldElement's name
                    ifcElementType,                          // desired IfcBuildingElement subclass
                    "local",                                 // placement method
                    ifcSpatialStructure);                    // spatial structure element the component should belong to


                // increase counter
                counter++;
            }
            //  return model;
            return(new Dictionary <string, object>
            {
                { "IfcModel", model }
            });
        }