diff --git a/.github/workflows/sanity_checks_for_prs.yml b/.github/workflows/sanity_checks_for_prs.yml index 39c55cf..a7920c7 100644 --- a/.github/workflows/sanity_checks_for_prs.yml +++ b/.github/workflows/sanity_checks_for_prs.yml @@ -1,6 +1,7 @@ --- name: sanity checks # merge_group triggers happen in merge queues + # workflow_dispatch triggers happen when a user manually runs the workflow # pull_request triggers happen when a pull request is updated on: [merge_group, pull_request, workflow_dispatch] @@ -30,5 +31,6 @@ jobs: shell: bash id: Run_pre-commit # this makes sure we do not accidentally use hooks that need docker on the dev machines + env: DOCKER_HOST: docker_intentionally_disabled diff --git a/AdSec/.NET/ApiToExcel/ApiToExcel.cs b/AdSec/.NET/ApiToExcel/ApiToExcel.cs new file mode 100644 index 0000000..23caba9 --- /dev/null +++ b/AdSec/.NET/ApiToExcel/ApiToExcel.cs @@ -0,0 +1,70 @@ +//Importing the necessary packages +using System; +using System.IO; +using System.Linq; +using ClosedXML.Excel; //Open source library That can be used for reading and writing in the excel file +using Oasys.AdSec; +using OasysUnits; +using OasysUnits.Units; +using Oasys.Profiles; +using Oasys.AdSec.StandardMaterials; +using Oasys.AdSec.DesignCode; + +class Program +{ + static void Main() + { + try + { + //Getting the workbook from the excel file. + var workbook = new XLWorkbook("Path to your file.."); + + var worksheet = workbook.Worksheet("Sheet1"); + // Getting the load from the excel file + var load = worksheet.Range("A2:C" + worksheet.LastRowUsed().RowNumber()).Rows(); + // creating adsec object and defining section material + var sectionMaterial = Steel.EN1993.Edition_2005.S235; + var adSec = IAdSec.Create(EN1992.Part1_1.Edition_2004.NationalAnnex.GB.Edition_2014); + //Creating a secion + var diameter = new Length(80, LengthUnit.Inch); + var circleProfile = ICircleProfile.Create(diameter); + var section = ISection.Create(circleProfile, sectionMaterial); + //Analysing the section + var circleSectionAnalysis = adSec.Analyse(section); + // Starting from 2 as the 1st row is the heading + int x = 2; + for (int i = 2; i < load.Count(); i++) + { + // Getting the loads and coverting it + var force_x = new Force( + (double)worksheet.Cell("A" + i).Value, + ForceUnit.Kilonewton + ); + var moment_yy = new Moment( + (double)worksheet.Cell("B" + i).Value, + MomentUnit.KilonewtonMeter + ); + var moment_zz = new Moment( + (double)worksheet.Cell("C" + i).Value, + MomentUnit.KilonewtonMeter + ); + var circleLoad = ILoad.Create(force_x, moment_yy, moment_zz); + //Getting the strength results + var strengthResult = circleSectionAnalysis.Strength.Check(circleLoad); + var utilisation = Math.Round(strengthResult.LoadUtilisation.Percent, 1); + var ulsStatus = utilisation < 100 ? "Clear" : "Not Clear"; + worksheet.Cell("D" + i).Value = utilisation; + worksheet.Cell("E" + i).Value = ulsStatus; + } + workbook.Save(); + } + catch (FileNotFoundException) + { + Console.WriteLine("File not found"); + } + catch (Exception ex) + { + Console.WriteLine("An error occurred: " + ex.Message); + } + } +} diff --git a/AdSec/.NET/ApiToExcel/ApiToExcel.csproj b/AdSec/.NET/ApiToExcel/ApiToExcel.csproj new file mode 100644 index 0000000..91b464a --- /dev/null +++ b/AdSec/.NET/ApiToExcel/ApiToExcel.csproj @@ -0,0 +1,10 @@ + + + + Exe + net8.0 + enable + enable + + + diff --git a/AdSec/Python/ApiToExcel.py b/AdSec/Python/ApiToExcel.py new file mode 100644 index 0000000..4d92d1c --- /dev/null +++ b/AdSec/Python/ApiToExcel.py @@ -0,0 +1,46 @@ +# importing packages +import openpyxl as op # OPen source library that can be used for reading and writing into the excel files +from Oasys.AdSec import IAdSec, ILoad, ISection +from Oasys.AdSec.DesignCode import EN1992 +from Oasys.AdSec.StandardMaterials import Steel +from Oasys.Profiles import ICircleProfile +from OasysUnits import Force, Length, Moment +from OasysUnits.Units import ForceUnit, LengthUnit, MomentUnit + +# Reading Values from the excel file + +try: + workbook = op.load_workbook(filename=r"C:\Repo\oasys-api-samples\AdSec\Python\loads.xlsx") + sheet1 = workbook["Sheet1"] + load = [row for row in sheet1.iter_rows(min_row=2, max_col=3, values_only=True)] + # Defining the Section Material + section_material = Steel.EN1993.Edition_2005.S235 + + # Creating adsec object + adsec = IAdSec.Create(EN1992.Part1_1.Edition_2004.NationalAnnex.GB.Edition_2014) + + # Creating a Circular Section + diameter = Length(float(80), LengthUnit.Inch) + circle_profile = ICircleProfile.Create(diameter) + section = ISection.Create(circle_profile, section_material) + + # circular Section Analysis + circle_section_analyse = adsec.Analyse(section) + x = 2 + max_utilization = 100 + for row in load: + Force_x = Force(float(row[0]), ForceUnit.Kilonewton) + Moment_yy = Moment(float(row[1]), MomentUnit.KilonewtonMeter) + Moment_zz = Moment(float(row[2]), MomentUnit.KilonewtonMeter) + circle_load = ILoad.Create(Force_x, Moment_yy, Moment_zz) + strength_result = circle_section_analyse.Strength.Check(circle_load) + utilisation = round(strength_result.LoadUtilisation.Percent, 1) + uls_status = "Clear :)" if utilisation < max_utilization else "Not Clear :(" + sheet1["D" + str(x)] = utilisation + sheet1["E" + str(x)] = uls_status + x += 1 + workbook.save("loads.xlsx") +except FileNotFoundError: + print("file not found") +except Exception as e: + print("Error occured: ", e)