示例#1
0
        public SapViewModel(UserInformation userInfo, string strType)
        {
            _userInformation = new UserInformation();
            _userInformation = userInfo;
            SapModel         = new SapModel();
            _pccsModel       = new PCCSModel();
            _sapBll          = new SapBll(_userInformation);
            this.selectChangeComboCommandPartNo = new DelegateCommand(this.SelectDataRowPart);
            this.selectChangeComboCommandRoh    = new DelegateCommand(this.SelectDataRowRoh);

            _bomEditCommand       = new DelegateCommand <DataRowView>(this.BomEdit);
            this._enterPartNumber = new DelegateCommand <string>(this.EnterPartNumber);
            _onRefreshCommand     = new DelegateCommand(this.Refresh);
            _onExportCommand      = new DelegateCommand(this.Export);
            _onCloseCommand       = new DelegateCommand(this.Close);
            _onSaveCommand        = new DelegateCommand(this.Save);
            _sapBll.GetPartNoDetails(SapModel);
            _sapBll.GetRohNoDetails(SapModel);
            SetdropDownItems();
            sapType = strType.ToUpper();
            switch (sapType)
            {
            case "FERT":
            {
                GrpMFertVisibility = Visibility.Visible;
                GrpKFertVisibility = Visibility.Collapsed;
                GrpYFertVisibility = Visibility.Collapsed;
            }
            break;
            }
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="sapModel"></param>
 /// <param name="section1"></param>
 /// <param name="section2"></param>
 /// <param name="populationSize"></param>
 public FactoryOptimizer(SapModel sapModel, SapSteelSection section1, SapSteelSection section2, int numberOfIterations, int populationSize, int eliteCount, RichTextBox reportingControl)
 {
     geneticRandom           = new Random();
     this.sapModel           = sapModel;
     this.section1           = section1;
     this.section2           = section2;
     this.reportingControl   = reportingControl;
     this.numberOfIterations = numberOfIterations;
     this.populationSize     = populationSize;
     this.eliteCount         = eliteCount;
 }
        public SapPoint AddXYZ(SapModel sapModel, double space, Direction dir)
        {
            switch (dir)
            {
            case Direction.X:
                this.x = space;
                break;

            case Direction.Y:
                this.Y = space;
                break;

            case Direction.Z:
                this.Z = space;
                break;
            }
            return(new SapPoint(sapModel.SapObjectModel, this.x, this.y, this.z));
        }
示例#4
0
        private void button1_Click(object sender, EventArgs e)
        {
            var currentText = button1.Text;

            button1.Text    = "Please Wait";
            button1.Enabled = false;
            SapModel model = new SapModel(@"SapModel", visible, "TestRun");

            model.Initialize(SapUnits.Ton_m_C);
            SapMaterial ST = new SapMaterial(model.SapObjectModel, "ST52/3", MaterialType.STEEL);

            ST.SetDefaultSteel();
            SapSteelSection  section1  = new SapSteelSection(model.SapObjectModel, ST, 1.3, 0.45, 0.04, 0.015, 0.04, 0.45, "ST1500x550");
            SapSteelSection  section2  = new SapSteelSection(model.SapObjectModel, ST, 0.7, 0.35, 0.04, 0.015, 0.04, 0.35, "ST800x500");
            FactoryOptimizer optimizer = new FactoryOptimizer(model, section1, section2, numberOfIterations, populationSize, eliteCount, richTextBox1);

            optimizer.Start();
            Process.Start(@"SapModel");
            button1.Text    = currentText;
            button1.Enabled = true;
        }
        private void analysisBtn_Click(object sender, RoutedEventArgs e)
        {
            //file Path and file Name
            string filePath = "C:\\CSiAPIexample";
            string fileName = "Model1";

            //Create Sap Model
            mySapModel = new SapModel(filePath, fileName);
            //initialize Model units KN, m, C:
            mySapModel.InitializeUnits(eUnits.kN_m_C);
            /*----------------------------------------------------------*/
            /*-----------------------Create Material-----------------------*/
            //Concrete
            SapMaterial concMat = new SapMaterial(mySapModel.MySapObjectModel, $"Fcu{fcutxtBox.Text}", eMatType.Concrete);

            concMat.SetNewMaterial($"Fcu{fcutxtBox.Text}", eMatType.Concrete);
            concMat.SetConcMat($"Fcu{fcutxtBox.Text}", Convert.ToDouble(fcutxtBox.Text));
            concMat.SetIsotropicProps($"Fcu{fcutxtBox.Text}", 220000, 0.20, 9.900E-06);
            concMat.SetWeight($"Fcu{fcutxtBox.Text}", 25);

            //Steel Rebar Material
            //SapMaterial rebarMat = new SapMaterial(mySapModel.MySapObjectModel, )

            /*----------------------------------------------------------*/

            //Creating Sections
            B = new SapRectSection(mySapModel.MySapObjectModel, $"B{Convert.ToDouble(btxtBox.Text)}X{Convert.ToDouble(ttxtBox.Text)}"
                                   , concMat, Convert.ToDouble(btxtBox.Text)
                                   , Convert.ToDouble(ttxtBox.Text), -1);
            B.SetRectSec();

            /*----------------------------------------------------------*/

            //Points

            points = new SapPoint[nSpans + 1];
            for (int i = 0; i < nSpans + 1; i++)
            {
                points[i] = new SapPoint(mySapModel.MySapObjectModel, comSpanValues[i], 0, 0);
            }
            /*----------------------------------------------------------*/

            //Beams in X-Direction:
            xbeams = new SapFrameElement[nSpans];
            for (int i = 0; i < nSpans; i++)
            {
                xbeams[i] = new SapFrameElement(mySapModel.MySapObjectModel, points[i], points[i + 1], B, $"{i + 1}", $"B{i + 1}");
            }
            /*----------------------------------------------------------*/

            //Initialize hinged joints
            for (int i = 0; i < nSpans + 1; i++)
            {
                points[i].SetRestraints(Restraints.Hinged);
            }

            //xBeamsComboBox.ItemsSource = xbeams;
            //xBeamsComboBox.SelectedIndex = 0;

            /*----------------------Load Patterns----------------------*/
            for (int i = 0; i < loadPatternName.Count; i++)
            {
                SapLoadPattern load = new SapLoadPattern(mySapModel.MySapObjectModel, patternType[i], loadPatternName[i]
                                                         , SelfWtMultiplier[i], true);

                loadPatterns.Add(load);
                load.AddLoadPattern();
            }
            /*----------------------Load Combinations----------------------*/
            for (int i = 0; i < Combinations.Count; i++)
            {
                mySapModel.MySapObjectModel.RespCombo.Add(Combinations[i], 0);

                mySapModel.MySapObjectModel.RespCombo.SetCaseList(Combinations[i], ref ec, loadCaseName[i]
                                                                  , loadFactorList[i]);
            }
            /*----------------------Adding Distributed Loads----------------------*/
            for (int i = 0; i < distLoadVals.Count; i++)
            {
                SapFrameElement item    = null;
                SapLoadPattern  loadPat = null;
                for (int j = 0; j < nSpans; j++)
                {
                    if (DistLoadFrameElement[i] == xbeams[j].Label)
                    {
                        item = xbeams[j];
                    }
                }
                for (int j = 0; j < loadPatterns.Count; j++)
                {
                    if (distLoadPattern[i] == loadPatterns[j].Name)
                    {
                        loadPat = loadPatterns[j];
                    }
                }
                SapFrameDistLoad distload = new SapFrameDistLoad(loadPat, 1, distLoadDirVal[i], 0, 1, distLoadVals[i], distLoadVals[i], true);
                distLoads.Add(distload);

                item.SetDistributedLoad(distload);
            }
            /*----------------------Adding Point Loads----------------------*/
            for (int i = 0; i < concLoadVals.Count; i++)
            {
                SapFrameElement item    = null;
                SapLoadPattern  loadPat = null;
                for (int j = 0; j < nSpans; j++)
                {
                    if (concLoadFrameElement[i] == xbeams[j].Label)
                    {
                        item = xbeams[j];
                    }
                }
                for (int j = 0; j < loadPatterns.Count; j++)
                {
                    if (concLoadPattern[i] == loadPatterns[j].Name)
                    {
                        loadPat = loadPatterns[j];
                    }
                }
                SapPointLoad D1 = new SapPointLoad(loadPat, concLoadVals[i], ConsoleApplication1.Type.Force, concLoadDirVal[i]);

                pointLoads.Add(D1);
                item.SetFramePointLoad(D1, relDistList[i]);
            }
        }