示例#1
0
 private void btn_GenerateIfc_Click(object sender, RoutedEventArgs e)
 {
     HndzSite     site     = new HndzSite();
     HndzBuilding building = new HndzBuilding();
     HndzStorey   storey   = new HndzStorey(building);
     //HndzProduct product = new HndzProduct(ref storey);
     HndzNode node1 = new HndzNode();
     HndzNode node4 = new HndzNode();
     HndzNode node5 = new HndzNode();
     HndzNode node2 = new HndzNode(2, 3, 5);
     HndzNode ss    = new HndzNode();
 }
示例#2
0
        static void Main(string[] args)
        {
            HndzProject  project  = new HndzProject();
            HndzBuilding building = new HndzBuilding(project);
            HndzStorey   storey   = new HndzStorey(building);

            HndzFrameSingleBay3D frame3D = new HndzFrameSingleBay3D(/*length*/ 24000, /*baySpacing*/ 6000, /*Width*/ 20000,
                                                                    5000, 2000, HndzLocationEnum.Cairo, HndzRoofSlopeEnum.From1To5, HndzRoofAccessibilityEnum.Inaccessible,
                                                                    HndzBuildingEnclosingEnum.PartiallyEnclosed, HndzImportanceFactorEnum.II, null, null, null, null, null, storey);
            bool isGenerated = ConvertToIFC.GenerateIFCProject(project, "E:\\test13June");

            if (isGenerated)
            {
                Console.WriteLine("      Succeed       ");
            }
            else
            {
                Console.WriteLine("      Failed        ");
            }
            Console.ReadKey();
        }
示例#3
0
        public static string GenerateIFC(HndzFrameSingleBay3D frame3D)
        {
            // create project
            HndzProject project = new HndzProject();

            project.Name                   = "Handaz Building";
            project.Description            = "Handaz Building Description";
            project.GlobalCoordinateSystem = HndzWCS.Egypt_Red_Belt;
            project.Owner                  = new Person("HANDAZ", "HANDAZ", "HANDAZ", "HANDAZ", "HANDAZ", "HANDAZ", "HANDAZ");

            //test stories
            HndzBuilding bui    = new HndzBuilding(project);
            HndzStorey   storey = new HndzStorey(bui, 0);


            if (frame3D == null)
            {
                frame3D = new HndzFrameSingleBay3D(24000, 6000, 20000, 6000, 2000, HndzLocationEnum.Cairo,
                                                   HndzRoofSlopeEnum.From1To10, HndzRoofAccessibilityEnum.Inaccessible, HndzBuildingEnclosingEnum.PartiallyEnclosed, HndzImportanceFactorEnum.II);
            }
            if (frame3D.BuildingStorey == null)
            {
                frame3D.BuildingStorey = storey;
            }
            XbimModel   model    = CreateandInitModel(frame3D.BuildingStorey.Building.Project);
            IfcBuilding building = CreateBuilding(model, frame3D.BuildingStorey.Building);

            List <IfcProduct> tt = new List <IfcProduct>();

            foreach (HndzFrameSingleBay2D frame2D in frame3D.Frames2D)
            {
                tt.Add(CreateColumn(model, frame2D.RightColumn));
                tt.Add(CreateColumn(model, frame2D.LeftColumn));
                tt.Add(CreateBeam(model, frame2D.RightBeam));
                tt.Add(CreateBeam(model, frame2D.LeftBeam));
            }
            foreach (HndzPurlin purlin in frame3D.Purlins)
            {
                tt.Add(CreateBeam(model, purlin));
            }

            List <List <IfcProduct> > temp = new List <List <IfcProduct> >();

            temp.Add(tt);

            CreateStorey(model, building, 4000, temp);
            string fileName = "Project" + frame3D.BuildingStorey.Building.Project.GlobalId;

            string filePath = IFCFileResources.wexbimPath + fileName;

            try
            {
                model.SaveAs(filePath, XbimStorageType.IFC);
                //model.SaveAs(filePath, XbimStorageType.XBIM);
                CreateWexBimFromIfc(model, filePath);
            }
            catch (Exception ex)
            {
            }
            return(fileName);
        }
        protected void btn_Submit_Click(object sender, EventArgs e)
        {
            lbl_ErrorBaySpacing.Visible = false;

            double baySpacing        = 0;
            bool   baySpacingIsValid = double.TryParse(txt_BaySpacing.Text, out baySpacing);


            double width  = Length.From(double.Parse(txt_LandWidth.Text), selectedUnit).Millimeters;
            double length = Length.From(double.Parse(txt_LandLength.Text), selectedUnit).Millimeters;

            baySpacing = Length.From(baySpacing, selectedUnit).Millimeters;
            double eaveHeight = Length.From(double.Parse(txt_EaveHeight.Text), selectedUnit).Millimeters;

            if (!baySpacingIsValid || baySpacing < 5000 || baySpacing > 10000)//ToDo:need Revision
            {
                lbl_ErrorBaySpacing.Visible = true;
                return;
            }


            HndzFrame3D       finalFrame = null;
            HndzFrameTypeEnum type;
            HndzBuilding      bui    = new HndzBuilding(project);
            HndzStorey        storey = new HndzStorey(bui, 0);

            if (Enum.TryParse(Request.QueryString["FrameType"], out type))
            {
                switch (type)
                {
                case HndzFrameTypeEnum.Undefined:
                    throw new NotImplementedException("Undefined Frame");
                    break;

                case HndzFrameTypeEnum.ClearSpan:
                    finalFrame = new HndzFrameSingleBay3D(length, baySpacing, width,
                                                          eaveHeight, 2000, (HndzLocationEnum)ddl_Location.SelectedIndex, (HndzRoofSlopeEnum)ddl_RoofSlope.SelectedIndex
                                                          , (HndzRoofAccessibilityEnum)ddl_RoofAccessability.SelectedIndex, HndzBuildingEnclosingEnum.PartiallyEnclosed,
                                                          HndzImportanceFactorEnum.II, null, null, null, null, null, storey);
                    break;

                case HndzFrameTypeEnum.SingleSlope:
                    finalFrame = new HndzFrameMonoSlope3D(length, baySpacing, width,
                                                          eaveHeight, 2000, (HndzLocationEnum)ddl_Location.SelectedIndex, (HndzRoofSlopeEnum)ddl_RoofSlope.SelectedIndex
                                                          , (HndzRoofAccessibilityEnum)ddl_RoofAccessability.SelectedIndex, HndzBuildingEnclosingEnum.PartiallyEnclosed,
                                                          HndzImportanceFactorEnum.II, null, null, null, null, null, storey);
                    break;

                case HndzFrameTypeEnum.MultiSpan1:
                    finalFrame = new HndzFrameMultiSpan13D(length, baySpacing, width,
                                                           eaveHeight, 2000, (HndzLocationEnum)ddl_Location.SelectedIndex, (HndzRoofSlopeEnum)ddl_RoofSlope.SelectedIndex
                                                           , (HndzRoofAccessibilityEnum)ddl_RoofAccessability.SelectedIndex, HndzBuildingEnclosingEnum.PartiallyEnclosed,
                                                           HndzImportanceFactorEnum.II, null, null, null, null, null, storey);
                    break;

                case HndzFrameTypeEnum.MultiSpan2:
                    finalFrame = new HndzFrameMultiSpan23D(length, baySpacing, width,
                                                           eaveHeight, 2000, (HndzLocationEnum)ddl_Location.SelectedIndex, (HndzRoofSlopeEnum)ddl_RoofSlope.SelectedIndex
                                                           , (HndzRoofAccessibilityEnum)ddl_RoofAccessability.SelectedIndex, HndzBuildingEnclosingEnum.PartiallyEnclosed,
                                                           HndzImportanceFactorEnum.II, null, null, null, null, null, storey);
                    break;

                case HndzFrameTypeEnum.MultiSpan3:
                    finalFrame = new HndzFrameMultiSpan33D(length, baySpacing, width,
                                                           eaveHeight, 2000, (HndzLocationEnum)ddl_Location.SelectedIndex, (HndzRoofSlopeEnum)ddl_RoofSlope.SelectedIndex
                                                           , (HndzRoofAccessibilityEnum)ddl_RoofAccessability.SelectedIndex, HndzBuildingEnclosingEnum.PartiallyEnclosed,
                                                           HndzImportanceFactorEnum.II, null, null, null, null, null, storey);
                    break;

                case HndzFrameTypeEnum.MultiGable:
                    finalFrame = new HndzFrameMultiGable3D(length, baySpacing, width,
                                                           eaveHeight, 2000, (HndzLocationEnum)ddl_Location.SelectedIndex, (HndzRoofSlopeEnum)ddl_RoofSlope.SelectedIndex
                                                           , (HndzRoofAccessibilityEnum)ddl_RoofAccessability.SelectedIndex, HndzBuildingEnclosingEnum.PartiallyEnclosed,
                                                           HndzImportanceFactorEnum.II, null, null, null, null, null, storey);
                    break;

                default:
                    break;
                }

                finalFrame.FramesCount = Convert.ToInt32(txt_FramesCount.Text);
                finalFrame.Type        = type;

                DataContractSerializer xmlser = new DataContractSerializer(finalFrame.GetType());
                string relativePath           = Resources.WebResources.XMLPath + string.Format("Frame No.{0}.xml", finalFrame.GlobalId.ToString());
                string absolutePath           = Server.MapPath(relativePath);
                using (XmlWriter xw = XmlWriter.Create(absolutePath))
                {
                    xmlser.WriteObject(xw, finalFrame);
                }

                HttpCookie cookName = null;
                if (Request.Cookies["Frame"] == null) //mafrod 3mro ma yd5l hna bs e7tyaty
                {
                    cookName = new HttpCookie("Frame");
                }
                else
                {
                    cookName = Response.Cookies["Frame"];
                }
                cookName.Value = absolutePath;
                Response.Cookies.Add(cookName);
            }
            else
            {
                #region IFC Creation
                //HttpCookie cookNameFile = null;
                //if (Request.Cookies["FileName"] == null)
                //{
                //    cookNameFile = new HttpCookie("FileName");
                //}
                //else
                //{
                //    cookNameFile = Response.Cookies["FileName"];
                //    #region Delete old files
                //    //string oldFileName = cookName.Value;
                //    //string oldFilePath = Resources.WebResources.wexbimPath + oldFileName;
                //    //oldFilePath = Server.MapPath(oldFilePath);

                //    //if ((File.Exists(oldFilePath + ".ifc")))
                //    //{
                //    //    File.Delete(oldFilePath + ".ifc");
                //    //}
                //    //if ((File.Exists(oldFilePath + ".wexbim")))
                //    //{
                //    //    File.Delete(oldFilePath + ".wexbim");
                //    //}
                //    #endregion
                //}


                //string fileName = "DesignedFrame" + Guid.NewGuid().ToString();
                //string filePath = Resources.WebResources.wexbimPath + fileName;
                //filePath = Server.MapPath(filePath);
                //try
                //{
                //    BIM.ConvertToIFC.GenerateIFCProject(project, filePath);
                //    cookNameFile.Value = fileName;
                //    Response.Cookies.Add(cookNameFile);
                //    Response.Redirect("/Pages/Designer/DesignWizard.aspx?FrameType=");//ToDo:goto Viewer and final results page isa
                //}
                //catch (Exception ex)
                //{
                //    IsInvalidModel = true;
                //    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "Alert", "$('btn_error').click();", true);//wrong
                //}
                #endregion
            }
            Session["FrameObject"] = finalFrame;
            Response.Redirect("/Pages/Designer/DesignWizard.aspx?FrameType=" + finalFrame.Type.ToString());
        }
        private void ConvertIntoFrame()
        {
            lbl_ErrorBaySpacing.Visible = false;

            double baySpacing        = 0;
            bool   baySpacingIsValid = double.TryParse(txt_BaySpacing.Text, out baySpacing);


            double width  = Length.From(double.Parse(txt_LandWidth.Text), selectedUnit).Millimeters;
            double length = Length.From(double.Parse(txt_LandLength.Text), selectedUnit).Millimeters;

            baySpacing = Length.From(baySpacing, selectedUnit).Millimeters;
            double eaveHeight = Length.From(double.Parse(txt_EaveHeight.Text), selectedUnit).Millimeters;

            if (!baySpacingIsValid || baySpacing < 5000 || baySpacing > 10000)//ToDo:need Revision
            {
                lbl_ErrorBaySpacing.Visible = true;
                return;
            }


            HndzFrame3D       finalFrame = null;
            HndzFrameTypeEnum type;
            HndzBuilding      bui    = new HndzBuilding(project);
            HndzStorey        storey = new HndzStorey(bui, 0);

            if (Enum.TryParse(Request.QueryString["FrameType"], out type))
            {
                switch (type)
                {
                case HndzFrameTypeEnum.Undefined:
                    throw new NotImplementedException("Undefined Frame");

                case HndzFrameTypeEnum.ClearSpan:
                    finalFrame = new HndzFrameSingleBay3D(length, baySpacing, width,
                                                          eaveHeight, 2000, (HndzLocationEnum)ddl_Location.SelectedIndex, (HndzRoofSlopeEnum)ddl_RoofSlope.SelectedIndex
                                                          , (HndzRoofAccessibilityEnum)ddl_RoofAccessability.SelectedIndex, HndzBuildingEnclosingEnum.PartiallyEnclosed,
                                                          HndzImportanceFactorEnum.II, null, null, null, null, null, storey);
                    break;

                case HndzFrameTypeEnum.SingleSlope:
                    finalFrame = new HndzFrameMonoSlope3D(length, baySpacing, width,
                                                          eaveHeight, 2000, (HndzLocationEnum)ddl_Location.SelectedIndex, (HndzRoofSlopeEnum)ddl_RoofSlope.SelectedIndex
                                                          , (HndzRoofAccessibilityEnum)ddl_RoofAccessability.SelectedIndex, HndzBuildingEnclosingEnum.PartiallyEnclosed,
                                                          HndzImportanceFactorEnum.II, null, null, null, null, null, storey);
                    break;

                case HndzFrameTypeEnum.MultiSpan1:
                    finalFrame = new HndzFrameMultiSpan13D(length, baySpacing, width,
                                                           eaveHeight, 2000, (HndzLocationEnum)ddl_Location.SelectedIndex, (HndzRoofSlopeEnum)ddl_RoofSlope.SelectedIndex
                                                           , (HndzRoofAccessibilityEnum)ddl_RoofAccessability.SelectedIndex, HndzBuildingEnclosingEnum.PartiallyEnclosed,
                                                           HndzImportanceFactorEnum.II, null, null, null, null, null, storey);
                    break;

                case HndzFrameTypeEnum.MultiSpan2:
                    finalFrame = new HndzFrameMultiSpan23D(length, baySpacing, width,
                                                           eaveHeight, 2000, (HndzLocationEnum)ddl_Location.SelectedIndex, (HndzRoofSlopeEnum)ddl_RoofSlope.SelectedIndex
                                                           , (HndzRoofAccessibilityEnum)ddl_RoofAccessability.SelectedIndex, HndzBuildingEnclosingEnum.PartiallyEnclosed,
                                                           HndzImportanceFactorEnum.II, null, null, null, null, null, storey);
                    break;

                case HndzFrameTypeEnum.MultiSpan3:
                    finalFrame = new HndzFrameMultiSpan33D(length, baySpacing, width,
                                                           eaveHeight, 2000, (HndzLocationEnum)ddl_Location.SelectedIndex, (HndzRoofSlopeEnum)ddl_RoofSlope.SelectedIndex
                                                           , (HndzRoofAccessibilityEnum)ddl_RoofAccessability.SelectedIndex, HndzBuildingEnclosingEnum.PartiallyEnclosed,
                                                           HndzImportanceFactorEnum.II, null, null, null, null, null, storey);
                    break;

                case HndzFrameTypeEnum.MultiGable:
                    finalFrame = new HndzFrameMultiGable3D(length, baySpacing, width,
                                                           eaveHeight, 2000, (HndzLocationEnum)ddl_Location.SelectedIndex, (HndzRoofSlopeEnum)ddl_RoofSlope.SelectedIndex
                                                           , (HndzRoofAccessibilityEnum)ddl_RoofAccessability.SelectedIndex, HndzBuildingEnclosingEnum.PartiallyEnclosed,
                                                           HndzImportanceFactorEnum.II, null, null, null, null, null, storey);
                    break;

                default:
                    break;
                }
                finalFrame.FramesCount = Convert.ToInt32(txt_FramesCount.Text);
                finalFrame.Type        = type;

                HttpCookie cookName = null;
                if (Request.Cookies["FileName"] == null)
                {
                    cookName = new HttpCookie("FileName");
                }
                else
                {
                    cookName = Response.Cookies["FileName"];
                }

                string fileName = Guid.NewGuid().ToString();
                string filePath = Resources.WebResources.wexbimPath + fileName;
                filePath = Server.MapPath(filePath);



                try
                {
                    bool isGenerated = BIM.ConvertToIFC.GenerateIFCProject(finalFrame.BuildingStorey.Building.Project, filePath);
                    cookName.Value = fileName;
                    Response.Cookies.Add(cookName);
                }
                catch (Exception)
                {
                    IsInvalidModel = true;
                    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "Alert", "$('btn_error').click();", true);//wrong
                }
                return;
            }
        }