//Add Point Load to elements on specific Pattern
        public static void AddPointLoads()
        {
            for (int i = 0; i < concLoadVals.Count; i++)
            {
                SapFrameElement item    = null;
                SapLoadPattern  loadPat = null;
                for (int j = 0; j < spanList.Count; 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], Desing.Core.Sap.Type.Force, concLoadDirVal[i]);

                pointLoads.Add(D1);
                item.SetFramePointLoad(D1, relDistList[i]);
            }
        }
        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]);
            }
        }