public static string getCurrentEtabsForceUnit(cSapModel mySapModel)
        {
            etabsPresentUnits LU = new etabsPresentUnits(mySapModel);
            string            un = "null";

            switch (LU.forceUnits)
            {
            case eForce.N:
                un = "N";
                break;

            case eForce.tonf:
                un = "ton";
                break;

            case eForce.kN:
                un = "KN";
                break;

            case eForce.lb:
                un = "lb";
                break;

            case eForce.kgf:
                un = "kg";
                break;

            case eForce.kip:
                un = "kip";
                break;
            }
            return(un);
        }
        public static string getCurrentEtabsLengthUnit(cSapModel mySapModel)
        {
            etabsPresentUnits LU = new etabsPresentUnits(mySapModel);
            string            un = "null";

            switch (LU.lengthUnits)
            {
            case eLength.cm:
                un = "cm";
                break;

            case eLength.ft:
                un = "ft";
                break;

            case eLength.inch:
                un = "in";
                break;

            case eLength.m:
                un = "m";
                break;

            case eLength.micron:
                un = "micron";
                break;

            case eLength.mm:
                un = "mm";
                break;
            }
            return(un);
        }
 public SapMaterial(cSapModel _mySapObjectModel, string _matName, eMatType _matType, matColor _materialColor = matColor.Default)
 {
     this.MySapObjectModel = _mySapObjectModel;
     this.matName          = _matName;
     this.matType          = _matType;
     this.materialColor    = _materialColor;
 }
Exemplo n.º 4
0
        public void Main(ref cSapModel SapModel, ref cPluginCallback ISapPlugin)
        {
            model          = SapModel;
            pluginCallback = ISapPlugin;
            AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(OnAssemblyResolve);
            try
            {
                cHelper helper      = new Helper();
                var     etabsObject = helper.GetObject("CSI.ETABS.API.ETABSObject");
                model = etabsObject.SapModel;
            }
            catch
            {
                ISapPlugin.Finish(0);
                return;
            }

            try
            {
                OpenOrFocusSpeckle(model);
                SelectionTimer = new Timer(2000)
                {
                    AutoReset = true, Enabled = true
                };
                SelectionTimer.Elapsed += SelectionTimer_Elapsed;
                SelectionTimer.Start();
            }

            catch (Exception e)
            {
                ISapPlugin.Finish(0);
                return;
            }
        }
Exemplo n.º 5
0
        public static void Get(ref cSapModel Model, string name, ref bool[] ireleases, ref bool[] jreleases)
        {
            double[] StartPFixityValues = new double[6];
            double[] EndPFixityVValues = new double[6];

            int ret = Model.FrameObj.GetReleases(name, ref ireleases, ref jreleases, ref StartPFixityValues, ref EndPFixityVValues);
        }
Exemplo n.º 6
0
 public static void SetGroupAssign_Cable(ref cSapModel Model, string GroupName, List <string> CableLabels)
 {
     foreach (var id in CableLabels)
     {
         long ret = Model.CableObj.SetGroupAssign(id, GroupName);
     }
 }
Exemplo n.º 7
0
        public void Main(ref cSapModel SapModel, ref cPluginCallback ISapPlugin)
        {
            Model.Etabs.EtabsData.Instance = new Model.Etabs.EtabsData(ref SapModel, ref ISapPlugin);
            MainWindow form = new MainWindow();

            form.Show();
        }
Exemplo n.º 8
0
        public static void CreateorUpdateJoint(ref cSapModel Model, Point pt, ref string Id, bool update, double SF)
        {
            if (!update) // create new Joint
            {
                string dummy = string.Empty;
                long   ret   = Model.PointObj.AddCartesian(pt.X * SF, pt.Y * SF, pt.Z * SF, ref dummy);
                Id  = dummy;
                ret = Model.PointObj.SetSpecialPoint(Id, true);
            }
            else
            {  // get coordinates and compare
                double jx  = 0;
                double jy  = 0;
                double jz  = 0;
                long   ret = Model.PointObj.GetCoordCartesian(Id, ref jx, ref jy, ref jz);

                if (pt.X != jx || pt.Y != jy || pt.Z != jz)
                {
                    string dummy = string.Empty;
                    ret = Model.PointObj.AddCartesian(pt.X, pt.Y, pt.Z, ref dummy);    // it will return existing if exits
                    if (dummy != Id)
                    {
                        ret = Model.EditPoint.ChangeCoordinates(Id, pt.X, pt.Y, pt.Z);  // this does the trick and delete the old one
                        ret = Model.PointObj.ChangeName(dummy, Id);
                    }
                }
            }
        }
Exemplo n.º 9
0
        // READ FROM SAPMODEL

        // to extract the Section Names on Specific Section Catalog
        public static void GetSectionsfromCatalog(ref cSapModel Model, string SC, ref string[] Names)
        {
            int number = 0;

            eFramePropType[] PropType = null;
            long             ret      = Model.PropFrame.GetPropFileNameList(SC, ref number, ref Names, ref PropType);
        }
Exemplo n.º 10
0
        public static void InitializeSapModel(ref SapObject mySAPObject, ref cSapModel mySapModel, string units)
        {
            long ret = 0;

            //TO DO: Grab open Instance if already open!!!

            //Create SAP2000 Object
            mySAPObject = new SAP2000v20.SapObject();

            // get enum from Units
            eUnits Units = (eUnits)Enum.Parse(typeof(eUnits), units);

            //Start Application
            mySAPObject.ApplicationStart(Units, true);

            //Create SapModel object
            mySapModel = mySAPObject.SapModel;

            //initialize the model
            ret = mySapModel.InitializeNewModel(Units);

            //create new blank model
            ret = mySapModel.File.NewBlank();

            //SET UP ... SET UP ... SET UP ... SET UP
            DefineMaterials(ref mySapModel);
        }
Exemplo n.º 11
0
        public List <string> GetModelComboNames()
        {
            List <string> ComboNames = null;

            model = ETABSConnection.GetModel();

            LoadCaseAndComboManager gm = new LoadCaseAndComboManager(model);

            try
            {
                ComboNames = gm.GetComboNames();
            }
            catch (Exception)
            {
                //todo throw exception
            }

            model = null;
            if (ComboNames != null)
            {
                return(ComboNames);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 12
0
 public static void SetGroupAssign_Shell(ref cSapModel Model, string GroupName, List <string> ShellLabels)
 {
     foreach (var id in ShellLabels)
     {
         long ret = Model.AreaObj.SetGroupAssign(id, GroupName);
     }
 }
Exemplo n.º 13
0
        /***************************************************/

        public static void SetMaterial(cSapModel model, IMaterialFragment material)
        {
            eMatType matType = eMatType.NoDesign;
            int      colour  = 0;
            string   guid    = "";
            string   notes   = "";
            string   name    = "";

            if (model.PropMaterial.GetMaterial(material.Name, ref matType, ref colour, ref notes, ref guid) != 0)
            {
                model.PropMaterial.AddMaterial(ref name, GetMaterialType(material), "", "", "");
                model.PropMaterial.ChangeName(name, material.Name);
                if (material is IIsotropic)
                {
                    IIsotropic isotropic = material as IIsotropic;
                    model.PropMaterial.SetMPIsotropic(material.Name, isotropic.YoungsModulus, isotropic.PoissonsRatio, isotropic.ThermalExpansionCoeff);
                }
                else if (material is IOrthotropic)
                {
                    IOrthotropic orthoTropic = material as IOrthotropic;
                    double[]     e           = orthoTropic.YoungsModulus.ToDoubleArray();
                    double[]     v           = orthoTropic.PoissonsRatio.ToDoubleArray();
                    double[]     a           = orthoTropic.ThermalExpansionCoeff.ToDoubleArray();
                    double[]     g           = orthoTropic.ShearModulus.ToDoubleArray();
                    model.PropMaterial.SetMPOrthotropic(material.Name, ref e, ref v, ref a, ref g);
                }
                model.PropMaterial.SetWeightAndMass(material.Name, 0, material.Density);
            }
        }
Exemplo n.º 14
0
        public static LoadCombination GetLoadCombination(cSapModel model, Dictionary <string, ICase> caseDict, string id)
        {
            LoadCombination combination = new LoadCombination();
            int             number;

            string[] nameNum = id.Split(new[] { ":::" }, StringSplitOptions.None);
            int.TryParse(nameNum[1], out number);
            combination.Number = number;
            combination.Name   = nameNum[0];

            string[] caseNames = null;
            double[] factors   = null;
            int      caseNum   = 0;

            eCNameType[] nameTypes = null;//<--TODO: maybe need to check if 1? (1=loadcombo)

            model.RespCombo.GetCaseList(id, ref caseNum, ref nameTypes, ref caseNames, ref factors);
            if (caseNames != null)
            {
                ICase currentCase;

                for (int i = 0; i < caseNames.Count(); i++)
                {
                    if (caseDict.TryGetValue(caseNames[i], out currentCase))
                    {
                        combination.LoadCases.Add(new Tuple <double, ICase>(factors[i], currentCase));
                    }
                }
            }
            return(combination);
        }
Exemplo n.º 15
0
        public static Loadcase GetLoadcase(cSapModel model, string id)
        {
            Loadcase bhLoadcase = new Loadcase();
            int      number;
            string   name = "NA";

            string[] nameNum = id.Split(new [] { ":::" }, StringSplitOptions.None);
            if (nameNum.Count() > 1)
            {
                name = nameNum[0];
                int.TryParse(nameNum[1], out number);
            }
            else
            {
                int.TryParse(id, out number);
            }
            bhLoadcase.Name   = name;
            bhLoadcase.Number = number;

            eLoadPatternType type = eLoadPatternType.Other;

            model.LoadPatterns.GetLoadType(id, ref type);
            bhLoadcase.Nature = GetLoadNature(type);

            return(bhLoadcase);
        }
Exemplo n.º 16
0
        public static void SetLoadCombination(cSapModel model, LoadCombination loadCombination)
        {
            //string combinationName = loadCombination.CustomData[AdapterId].ToString();
            string combinationName = CaseNameToCSI(loadCombination);

            model.RespCombo.Add(combinationName, 0);//0=case, 1=combo

            foreach (var factorCase in loadCombination.LoadCases)
            {
                double     factor    = factorCase.Item1;
                Type       lcType    = factorCase.Item2.GetType();
                string     lcName    = CaseNameToCSI(factorCase.Item2);// factorCase.Item2.Name;// Number.ToString();
                eCNameType cTypeName = eCNameType.LoadCase;

                if (lcType == typeof(Loadcase))
                {
                    cTypeName = eCNameType.LoadCase;
                }
                else if (lcType == typeof(LoadCombination))
                {
                    cTypeName = eCNameType.LoadCombo;
                }

                model.RespCombo.SetCaseList(combinationName, ref cTypeName, lcName, factor);
            }
        }
Exemplo n.º 17
0
 public EtabsLine(string Name, cSapModel EtabsModel, EtabsNode StartNode, EtabsNode EndNode)
 {
     this.Name       = Name;
     this.StartNode  = StartNode;
     this.EndNode    = EndNode;
     this.EtabsModel = EtabsModel;
 }
Exemplo n.º 18
0
        /***************************************************/
        private static List<string> CheckAndGetCases(cSapModel model, IList cases)
        {
            List<string> loadcaseIds = new List<string>();

            if (cases == null || cases.Count == 0)
            {
                int Count = 0;
                string[] case_names = null;
                string[] combo_names = null;
                model.LoadCases.GetNameList(ref Count, ref case_names);
                model.RespCombo.GetNameList(ref Count, ref combo_names);
                loadcaseIds = case_names.ToList();

                if(combo_names != null)
                    loadcaseIds.AddRange(combo_names);
            }
            else
            {
                for (int i = 0; i < cases.Count; i++)
                {
                    if (cases[i] is BH.oM.Structure.Loads.ICase)
                    {
                        string id = CaseNameToCSI(cases[i] as BH.oM.Structure.Loads.ICase);
                        loadcaseIds.Add(id);
                    }
                    else
                        loadcaseIds.Add(cases[i].ToString());
                }
            }

            return loadcaseIds;
        }
Exemplo n.º 19
0
 public static void SetGroupAssign_Frm(ref cSapModel Model, string GroupName, List <string> FrmLabels)
 {
     foreach (var id in FrmLabels)
     {
         long ret = Model.FrameObj.SetGroupAssign(id, GroupName);
     }
 }
Exemplo n.º 20
0
        public Form1(ref cSapModel SapModel, ref cPluginCallback Plugin)
        {
            _Plugin   = Plugin;
            _SapModel = SapModel;

            InitializeComponent();
        }
Exemplo n.º 21
0
        // Get Points has restraints Assigned
        public static void GetSupportedPts(ref cSapModel Model, ref List <string> PtIds)
        {
            Model.SelectObj.ClearSelection();
            //List<bool> dof = new List<bool>();
            //for (int i = 0; i < 6; i++)
            //{
            //    dof.Add(true);
            //}
            bool[] dof = { true, true, true, true, true, true };
            int    ret = Model.SelectObj.SupportedPoints(ref dof, "GLOBAL", false, true, false, false, false, false, false);          // Select the Points objects

            // Get selection
            int num = 0;

            int[]    types = null;
            string[] Names = null;
            Model.SelectObj.GetSelected(ref num, ref types, ref Names);

            // Type 1 = Point, 2 = Frame, 3 = Cable, 4= Tendon, 5 = Area, 6 = Solid, 7 = Link
            for (int i = 0; i < num; i++)
            {
                if (types[i] == 1)
                {
                    PtIds.Add(Names[i]);
                }
            }

            Model.SelectObj.ClearSelection();
        }
Exemplo n.º 22
0
        public static void GetShell(ref cSapModel Model, string areaid, ref Surface BaseS, double LSF, ref string PropName) //Length Scale Factor
        {
            long ret = 0;

            int NumOfPts = 0;

            string[] PtsNames = null;
            ret = Model.AreaObj.GetPoints(areaid, ref NumOfPts, ref PtsNames);

            List <Point>      dynPts = new List <Point>();
            List <IndexGroup> igs    = new List <IndexGroup>();

            for (int i = 0; i < PtsNames.Count(); i++)
            {
                double x = 0;
                double y = 0;
                double z = 0;

                ret = Model.PointObj.GetCoordCartesian(PtsNames[i], ref x, ref y, ref z);

                Point p = Point.ByCoordinates(x * LSF, y * LSF, z * LSF);
                dynPts.Add(p);
            }

            //Mesh.ByPointsFaceIndices()
            BaseS = Surface.ByPerimeterPoints(dynPts);

            // Get assigned Property Name
            ret = Model.AreaObj.GetProperty(areaid, ref PropName);
        }
Exemplo n.º 23
0
        private EtabsAreaObject EatParent(string name, cSapModel activeModel)
        {
            EtabsAreaObject area       = new EtabsAreaObject();
            int             pointCount = new Int32();

            string[] pointNames = null;
            activeModel.AreaObj.GetPoints(name, ref pointCount, ref pointNames);
            List <EtabsPoint> points = new List <EtabsPoint>();

            foreach (string pointName in pointNames)
            {
                double x = new double();
                double y = new double();
                double z = new double();
                activeModel.PointObj.GetCoordCartesian(pointName, ref x, ref y, ref z);
                EtabsPoint point = new EtabsPoint();
                point.X = x;
                point.Y = y;
                point.Z = z;
                points.Add(point);
            }
            area.Name   = name;
            area.Points = points;
            return(area);
        }
Exemplo n.º 24
0
 public static void SetGroupAssign_Joint(ref cSapModel Model, string GroupName, List <string> JointLabels)
 {
     foreach (var id in JointLabels)
     {
         long ret = Model.PointObj.SetGroupAssign(id, GroupName);
     }
 }
Exemplo n.º 25
0
        public static Dictionary <string, object> SAPModel(bool read)
        {
            if (read)
            {
                StructuralModel Model = new StructuralModel();

                cSapModel mySapModel = null;
                string    modelunits = string.Empty;

                // Open & instantiate SAP file
                Initialize.GrabOpenSAP(ref mySapModel, ref modelunits, "");

                StructuralModelFromSapFile(ref mySapModel, ref Model, modelunits);

                // Return outputs
                return(new Dictionary <string, object>
                {
                    { "StructuralModel", Model },
                    { "units", modelunits }
                });
            }
            else
            {
                throw new Exception("Set boolean True to read!");
            }
        }
Exemplo n.º 26
0
        public static Dictionary <string, object> SAPModel(string FilePath, bool read)
        {
            if (read)
            {
                StructuralModel Model = new StructuralModel();
                Model.StructuralElements = new List <Element>();
                cSapModel mySapModel = null;
                string    units      = string.Empty;
                // Open & instantiate SAP file
                Initialize.OpenSAPModel(FilePath, ref mySapModel, ref units);

                // Populate the model's elemets
                StructuralModelFromSapFile(ref mySapModel, ref Model, units);

                // Return outputs
                return(new Dictionary <string, object>
                {
                    { "StructuralModel", Model },
                    { "units", units }
                });
            }
            else
            {
                throw new Exception("Set boolean True to read!");
            }
        }
Exemplo n.º 27
0
        public static Polyline GetPanelPerimeter(cSapModel model, string id)
        {
            string[] pName      = null;
            int      pointCount = 0;
            double   pX1        = 0;
            double   pY1        = 0;
            double   pZ1        = 0;

            model.AreaObj.GetPoints(id, ref pointCount, ref pName);
            List <Point> pts = new List <Point>();

            for (int j = 0; j < pointCount; j++)
            {
                model.PointObj.GetCoordCartesian(pName[j], ref pX1, ref pY1, ref pZ1);
                pts.Add(new Point()
                {
                    X = pX1, Y = pY1, Z = pZ1
                });
            }
            pts.Add(pts[0]);

            Polyline pl = new Polyline()
            {
                ControlPoints = pts
            };

            return(pl);
        }
Exemplo n.º 28
0
        public static void Get(ref cSapModel Model, string name, ref bool[] ireleases, ref bool[] jreleases)
        {
            double[] StartPFixityValues = new double[6];
            double[] EndPFixityVValues  = new double[6];

            int ret = Model.FrameObj.GetReleases(name, ref ireleases, ref jreleases, ref StartPFixityValues, ref EndPFixityVValues);
        }
        /// <summary>
        /// We need a folder in etabs model folder named "speckle" and a file in it
        /// called "<ETABSModelName>.txt". This function create this file and folder if
        /// they doesn't exists and returns it, otherwise just returns the file path
        /// </summary>
        /// <param name="model"></param>
        private static void GetOrCreateSpeckleFilePath(cSapModel model)
        {
            string etabsModelfilePath = model.GetModelFilename(true);

            if (etabsModelfilePath == "")
            {
                // etabs model is probably not saved, so speckle shouldn't do much
                _speckleFilePath = null;
                return;
            }
            string etabsFileName     = Path.GetFileNameWithoutExtension(etabsModelfilePath);
            string etabsModelFolder  = Path.GetDirectoryName(etabsModelfilePath);
            string speckleFolderPath = Path.Combine(etabsModelFolder, "speckle");
            string speckleFilePath   = Path.Combine(etabsModelFolder, "speckle", $"{etabsFileName}.txt");

            try
            {
                if (!Directory.Exists(speckleFolderPath))
                {
                    Directory.CreateDirectory(speckleFolderPath);
                }
                if (!File.Exists(speckleFilePath))
                {
                    File.CreateText(speckleFilePath);
                }
                _speckleFilePath = speckleFilePath;
            }
            catch
            {
                _speckleFilePath = null;
                return;
            }
        }
Exemplo n.º 30
0
        public void ReadStructure_Frame()
        {
            // Launch SAP2000v20 and Open a blank model

            string filePath = @"C:\Users\eertugrul\Documents\GitHub\DynamoSAP\packages\DynamoSAP\extra\2a_Dome.sdb";
            //Create SAP2000 Object
            SapObject mySapObject = new SAP2000v20.SapObject();

            //Start Application
            mySapObject.ApplicationStart();
            //Create SapModel object
            cSapModel mySapModel = mySapObject.SapModel;

            mySapModel.InitializeNewModel();
            mySapModel.File.OpenFile(filePath);


            //Open and Run the sample file
            OpenAndRunDynamoDefinition(@".\Sample_2a_Read_Dome+DecomposeSapModel.dyn");

            // Test Logic is here --->
            string failreport = string.Empty;

            // Check Node Read SAp Model
            if (IsNodeInErrorOrWarningState("966718c2-c618-46b8-b631-c43a54c669ff"))
            {
                failreport = string.Format(failreport + "{0}{1}", Environment.NewLine, "The node called '" + "Read.SAPModel" + "' failed or threw a warning.");
            }

            // Check Node Structural Model Decompose
            if (IsNodeInErrorOrWarningState("36b32253-13f6-47ab-9bef-69b45c688c5b"))
            {
                failreport = string.Format(failreport + "{0}{1}", Environment.NewLine, "The node called '" + "StructuralModel.Decompose" + "' failed or threw a warning.");
            }

            // Check Node Frame Decompose
            if (IsNodeInErrorOrWarningState("b5e32685-6c44-443b-bc6c-c91a051cc541"))
            {
                failreport = string.Format(failreport + "{0}{1}", Environment.NewLine, "The node called '" + "Frame.Decompose" + "' failed or threw a warning.");
            }

            // Check Node SectionProp.Decompose
            if (IsNodeInErrorOrWarningState("6bdba7f9-4de1-475e-8868-815d93b99bf6"))
            {
                failreport = string.Format(failreport + "{0}{1}", Environment.NewLine, "The node called '" + "SectionProp.Decompose" + "' failed or threw a warning.");
            }

            // Set SAP instances to null;
            mySapObject.ApplicationExit(false);
            mySapObject = null;
            mySapModel  = null;

            if (!string.IsNullOrEmpty(failreport))
            {
                Assert.Fail(failreport);
            }

            //if we got here, nothing failed.
            Assert.Pass();
        }
Exemplo n.º 31
0
        public void ShellStructure()
        {
            // Launch SAP2000v20 and Open a blank model
            SapObject mySapObject = null;
            cSapModel mySapModel  = null;

            SAPConnection.Initialize.InitializeSapModel(ref mySapObject, ref mySapModel, "kip_ft_F");

            //Open and Run the sample file
            OpenAndRunDynamoDefinition(@".\Sample_1c_ShellStructure.dyn");

            // Test Logic is here --->
            string failreport = string.Empty;

            // Check dropdown Shell Types
            var ShellType = (Int64)GetPreviewValue("e0c739ee-8e95-4531-95b8-d5bb71501b6c");

            if (ShellType != 1)
            {
                failreport = string.Format(failreport + "{0}{1}", Environment.NewLine, "The node called '" + "Shell Types Dropdown" + "' returns wrong value !");
            }

            // Check Node ShellProp.Define
            if (IsNodeInErrorOrWarningState("c0f21c61-375a-42b8-a1f4-d94a43f1272b"))
            {
                failreport = string.Format(failreport + "{0}{1}", Environment.NewLine, "The node called '" + "ShellProp.Define" + "' failed or threw a warning.");
            }

            // Check Node Shell.FromSurface
            if (IsNodeInErrorOrWarningState("0c217e34-2531-4450-a066-f839b64b1a1e"))
            {
                failreport = string.Format(failreport + "{0}{1}", Environment.NewLine, "The node called '" + "Shell.FromSurface" + "' failed or threw a warning.");
            }

            // Check Node StructuralModel.Collector
            if (IsNodeInErrorOrWarningState("a6bc0f86-a159-4f79-934d-238323b65de8"))
            {
                failreport = string.Format(failreport + "{0}{1}", Environment.NewLine, "The node called '" + "StructuralModel.Collector" + "' failed or threw a warning.");
            }

            // Check Node Bake to SAP
            if (IsNodeInErrorOrWarningState("d86c67da-ff87-4c04-8976-c7a00a640518"))
            {
                failreport = string.Format(failreport + "{0}{1}", Environment.NewLine, "The node called '" + "Bake.toSAP" + "' failed or threw a warning.");
            }

            // Set SAP instances to null;
            mySapObject.ApplicationExit(false);
            mySapObject = null;
            mySapModel  = null;

            if (!string.IsNullOrEmpty(failreport))
            {
                Assert.Fail(failreport);
            }

            //if we got here, nothing failed.
            Assert.Pass();
        }
Exemplo n.º 32
0
        // SAP to Dynamo
        public static void Get( ref cSapModel Model, string PtId, ref Point Pt, ref bool[] restraints, double SF)
        {
            // Get restraints
            int ret = Model.PointObj.GetRestraint(PtId, ref restraints);
            double x= 0; double y= 0; double z= 0;

            // Get Point
            ret = Model.PointObj.GetCoordCartesian(PtId, ref x, ref y, ref z);
            Pt = Point.ByCoordinates(x*SF, y*SF, z*SF);
        }
Exemplo n.º 33
0
        public static void SapToDynamo(ref cSapModel Model, string SecName, ref string MatProp, ref string filename)
        {
            long ret = 0;
            eFramePropType PropType = new eFramePropType();
            ret = Model.PropFrame.GetType(SecName, ref PropType);

            string nameinfile = string.Empty; // If the section property was imported from a property file, this is the name of that file. If the section property was not imported, this item is blank.
            int color = 0;
            string notes = string.Empty;
            string Guid = string.Empty;
            double t2 = 0; double t3 = 0; double TW = 0; double TF = 0; double t2b = 0; double t3b = 0;

            if (PropType == eFramePropType.SECTION_RECTANGULAR)
            {
                ret = Model.PropFrame.GetRectangle(SecName, ref filename, ref MatProp, ref t3, ref t2, ref color, ref notes, ref Guid);
            }
            else if (PropType == eFramePropType.SECTION_PIPE)
            {
                ret = Model.PropFrame.GetPipe(SecName, ref filename, ref MatProp, ref t3, ref TW, ref color, ref notes, ref Guid);
            }
            else if (PropType == eFramePropType.SECTION_CIRCLE)
            {
                ret = Model.PropFrame.GetCircle(SecName, ref filename, ref MatProp, ref t3, ref color, ref notes, ref Guid);
            }
            else if (PropType == eFramePropType.SECTION_BOX)
            {
                ret = Model.PropFrame.GetTube(SecName, ref filename, ref MatProp, ref t3, ref t2, ref TF, ref TW, ref color, ref notes, ref Guid);
            }
            else if (PropType == eFramePropType.SECTION_I)
            {
                ret = Model.PropFrame.GetISection(SecName, ref filename, ref MatProp, ref t3, ref t2, ref TF, ref TW, ref t2b, ref t3b, ref color, ref notes, ref Guid);
            }
            else if (PropType == eFramePropType.SECTION_CHANNEL)
            {
                ret = Model.PropFrame.GetChannel(SecName, ref filename, ref MatProp, ref t3, ref t2, ref TF, ref TW, ref color, ref notes, ref Guid);
            }
            else if (PropType == eFramePropType.SECTION_T)
            {
                ret = Model.PropFrame.GetTee(SecName, ref filename, ref MatProp, ref t3, ref t2, ref TF, ref TW, ref color, ref notes, ref Guid);
            }
            else if (PropType == eFramePropType.SECTION_ANGLE)
            {
                ret = Model.PropFrame.GetAngle(SecName, ref filename, ref MatProp, ref t3, ref t2, ref TF, ref TW, ref color, ref notes, ref Guid);
            }
            else
            {
                ret = Model.PropFrame.GetNameInPropFile(SecName, ref nameinfile, ref filename, ref MatProp, ref PropType);
            }

            if (!String.IsNullOrEmpty(filename))
            {
                filename = Path.GetFileNameWithoutExtension(filename);
            }
        }
Exemplo n.º 34
0
        public static void Set(ref cSapModel Model, string name, bool[] ireleases, bool[] jreleases, ref string error)
        {
            //not sure how this works or if this approach even makes sense...

            double[] StartPFixityValues = new double[6];
            double[] EndPFixityVValues = new double[6];

            int ret = Model.FrameObj.SetReleases(name, ireleases, jreleases, StartPFixityValues, EndPFixityVValues,eItemType.Object);

            if (ret == 1) error=string.Format("Error setting the release for frame {0}. Try changing the conditions",name);
        }
Exemplo n.º 35
0
        // Get Points has restraints Assigned
        public static void GetSupportedPts(ref cSapModel Model, ref List<string> PtIds)
        {
            Model.SelectObj.ClearSelection();
            List<bool> dof = new List<bool>();
            for (int i = 0; i < 6; i++)
            {
                dof.Add(true);
            }
            int ret = Model.SelectObj.SupportedPoints(dof.ToArray(), "GLOBAL", false, true, false, false, false, false, false); // Select the Points objects

            // Get selection
            int num = 0;
            int[] types = null;
            string[] Names = null;
            Model.SelectObj.GetSelected(ref num, ref types, ref Names);

            // Type 1 = Point, 2 = Frame, 3 = Cable, 4= Tendon, 5 = Area, 6 = Solid, 7 = Link
            for (int i = 0; i < num; i++)
            {
                if (types[i] == 1) PtIds.Add(Names[i]);
            }

            Model.SelectObj.ClearSelection();
        }
Exemplo n.º 36
0
        public static void CreateorUpdateArea(ref cSapModel Model, Mesh m, ref string Id, bool update, double SF, ref string error)
        {
            int counter = 0;
            if (!update) // Create new one
            {
                List<string> ProfilePts = new List<string>();

                long ret = 0;
                foreach (var v in m.VertexPositions)
                {
                    string dummy = null;
                    ret = Model.PointObj.AddCartesian(v.X * SF, v.Y * SF, v.Z * SF, ref dummy);

                    ProfilePts.Add(dummy);
                }

                string[] names = ProfilePts.ToArray();
                string dummyarea = string.Empty;
                ret = Model.AreaObj.AddByPoint(ProfilePts.Count(), ref names, ref dummyarea);
                if (ret == 1) counter++;
                Id = dummyarea;

            }
            else
            {

                // Existing
                int eNumberofPts = 0;
                string[] ePtNames = null;
                long ret = Model.AreaObj.GetPoints(Id, ref eNumberofPts, ref ePtNames);

                // Compare the number of points
                if (eNumberofPts == m.VertexPositions.Count())
                {
                    for (int i = 0; i < eNumberofPts; i++)
                    {
                        ret = Model.EditPoint.ChangeCoordinates_1(ePtNames[i], m.VertexPositions[i].X * SF, m.VertexPositions[i].Y * SF, m.VertexPositions[i].Z * SF);
                        if (ret == 1) counter++;
                    }
                }
                else if (eNumberofPts > m.VertexPositions.Count()) // remove Points
                {
                    for (int i = 0; i < eNumberofPts; i++)
                    {
                        if (i < m.VertexPositions.Count())
                        {
                            ret = Model.EditPoint.ChangeCoordinates_1(ePtNames[i], m.VertexPositions[i].X * SF, m.VertexPositions[i].Y * SF, m.VertexPositions[i].Z * SF);
                            if (ret == 1) counter++;
                        }
                        else
                        {
                            ret = Model.SelectObj.ClearSelection();
                            ret = Model.AreaObj.SetSelected(Id, true);
                            ret = Model.PointObj.SetSelected(ePtNames[i], true);
                            ret = Model.EditArea.PointRemove();
                            if (ret == 1) counter++;
                        }
                    }
                }
                else if (eNumberofPts < m.VertexPositions.Count()) // add points
                {
                    for (int i = 0; i < m.VertexPositions.Count(); i++)
                    {
                        if (i < eNumberofPts)
                        {
                            ret = Model.EditPoint.ChangeCoordinates_1(ePtNames[i], m.VertexPositions[i].X * SF, m.VertexPositions[i].Y * SF, m.VertexPositions[i].Z * SF);
                            if (ret == 1) counter++;
                        }
                        else
                        {
                            // add point to latest edge
                            ret = Model.SelectObj.ClearSelection();
                            int a = i - 1;
                            ret = Model.AreaObj.SetSelectedEdge(Id, a, true);

                            ret = Model.EditArea.PointAdd();

                            // the repeat the first step so # of name and has updated
                            int tempnumb = 0;
                            string[] TempPtNames = null;
                            ret = Model.AreaObj.GetPoints(Id, ref tempnumb, ref TempPtNames);
                            ret = Model.EditPoint.ChangeCoordinates_1(TempPtNames[i], m.VertexPositions[i].X * SF, m.VertexPositions[i].Y * SF, m.VertexPositions[i].Z * SF);
                            if (ret == 1) counter++;
                        }
                    }

                }

            }

            if (counter > 0) error = string.Format("Error creating Mesh{0}", Id);
        }
Exemplo n.º 37
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="Model"></param>
 /// <param name="Label"></param>
 public static void DeleteJoint(ref cSapModel Model, string Label, ref string error)
 {
     Model.PointObj.SetSpecialPoint(Label, false);
     long ret = Model.PointObj.DeleteSpecialPoint(Label);
     if (ret == 1) error = string.Format("Error deleting joint {0}", Label);
 }
Exemplo n.º 38
0
 public static void SetSectionFrm(ref cSapModel mySapModel, string Name, string SectionProfile, ref string error)
 {
     long ret = mySapModel.FrameObj.SetSection(Name, SectionProfile);
     if (ret == 1) error = string.Format("Error setting section {0}",Name);
 }
Exemplo n.º 39
0
 public static void SetShellPropArea(ref cSapModel Model, string AreaId, string PropName, ref string error)
 {
     long ret = Model.AreaObj.SetProperty(AreaId, PropName);
     if (ret == 1) error = string.Format("Error setting the area property of shell {0}", AreaId);
 }
Exemplo n.º 40
0
        // Draw Frame Object return ID
        public static void CreateorUpdateFrm(ref cSapModel Model, double iX, double iY, double iZ, double jX, double jY, double jZ, ref string Id, bool update, ref string error)
        {
            if (!update)
            {
                //1. Create Frame
                string dummy = string.Empty;
                long ret = Model.FrameObj.AddByCoord(iX, iY, iZ, jX, jY, jZ, ref dummy);
                Id = dummy;
                if (ret == 1) error = string.Format("Error creating frame{0}", dummy);
            }
            else
            {
                // update location if coordinates have been changed
                string startPoint = string.Empty;
                string endPoint = string.Empty;
                long ret = Model.FrameObj.GetPoints(Id, ref startPoint, ref endPoint);
                //ret = Model.EditPoint.ChangeCoordinates(startPoint, iX, iY, iZ);
                //ret = Model.EditPoint.ChangeCoordinates(endPoint, jX, jY, jZ);

                string iPoint = string.Empty;
                string jPoint = string.Empty;

                // update start point
                double startX = 0;
                double startY= 0;
                double startZ = 0;
                ret = Model.PointObj.GetCoordCartesian(startPoint, ref startX, ref startY, ref startZ);
                if (iX != startX || iY!= startY || iZ != startZ)
                {
                    ret = Model.PointObj.AddCartesian(iX, iY, iZ, ref iPoint);
                }
                else // nothing change  at this end but pass the exsiting point name
                {
                    iPoint = startPoint;
                }

                // update end point
                double endX = 0;
                double endY = 0;
                double endZ = 0;
                ret = Model.PointObj.GetCoordCartesian(endPoint, ref endX, ref endY, ref endZ);
                if (jX != endX || jY != endY || jZ != endZ)
                {
                    ret = Model.PointObj.AddCartesian(jX, jY, jZ, ref jPoint);
                }
                else // nothing change at this end but pass the exsiting point name
                {
                    jPoint = endPoint;
                }

               // ret = Model.PointObj.AddCartesian(iX, iY, iZ, ref startPoint);
               //ret = Model.PointObj.AddCartesian(jX, jY, jZ, ref endPoint);
               // ret = Model.EditFrame.ChangeConnectivity(Id, startPoint, endPoint);
                if (iPoint != startPoint || jPoint != endPoint)
                {
                    ret = Model.EditFrame.ChangeConnectivity(Id, iPoint, jPoint);
                }

                if (ret == 1) error = string.Format("Error updating frame{0}", Id);

            }
        }
Exemplo n.º 41
0
        public static void GetLoadPatterns(ref cSapModel Model, ref string[] LoadPatternNames, ref string[] LoadPatternTypes, ref double[] LoadPatternMultipliers)
        {
            int number = 0;
            int ret = Model.LoadPatterns.GetNameList(ref number, ref LoadPatternNames);

            LoadPatternMultipliers = new double[number];
            LoadPatternTypes = new string[number];

            foreach (string lpname in LoadPatternNames)
            {
                double mult = 0;
                eLoadPatternType type = eLoadPatternType.LTYPE_DEAD;
                int pos = Array.IndexOf(LoadPatternNames, lpname);
                Model.LoadPatterns.GetLoadType(lpname, ref type);

                ret = Model.LoadPatterns.GetSelfWTMultiplier(lpname, ref mult);
                LoadPatternMultipliers[pos] = mult;
                //int typeInt = (int)type;
                LoadPatternTypes[pos] = type.ToString();
            }
        }
Exemplo n.º 42
0
 public static void ImportPropFrm(ref cSapModel mySapModel, string SectionName, string MatProp, string SecCatalog, ref string error)
 {
     long ret = mySapModel.PropFrame.ImportProp(SectionName, MatProp, SecCatalog, SectionName);
     if (ret == 1) error = string.Format("Error importing the section property {0}",SectionName);
 }
Exemplo n.º 43
0
        internal static void StructuralModelFromSapFile(ref cSapModel SapModel, ref StructuralModel model, string SapModelUnits)
        {
            model.StructuralElements = new List<Element>();
            model.ModelDefinitions = new List<Definition>();

            List<LoadPattern> TempLPatterns = new List<LoadPattern>();

            string error = string.Empty;
            if (SapModel != null)
            {

                // 1.a GET LOAD PATTERNS

                string[] LoadPatternNames = null;
                string[] LoadPatternTypes = null;
                double[] LoadPatternMultipliers = null;

                StructureMapper.GetLoadPatterns(ref SapModel, ref LoadPatternNames, ref LoadPatternTypes, ref LoadPatternMultipliers);
                if (LoadPatternNames != null)
                {
                    foreach (string lpname in LoadPatternNames)
                    {
                        int pos = Array.IndexOf(LoadPatternNames, lpname);
                        LoadPattern lp = new LoadPattern(lpname, LoadPatternTypes[pos], LoadPatternMultipliers[pos]);
                        model.ModelDefinitions.Add(lp);
                        TempLPatterns.Add(lp);
                    }
                }

                // 1.b GET LOAD CASES

                string[] LoadCasesNames = null;
                string[] LoadCasesTypes = null;
                double[] LoadCasesMultipliers = null;

                //With this method we only get the name and the type of each load case
                StructureMapper.GetLoadCases(ref SapModel, ref LoadCasesNames, ref LoadCasesMultipliers, ref LoadCasesTypes);
                if (LoadCasesNames != null)
                {
                    foreach (string lcname in LoadCasesNames)
                    {
                        int pos = Array.IndexOf(LoadCasesNames, lcname);

                        //create a new load
                        LoadCase lc = new LoadCase();
                        lc.name = lcname;
                        lc.type = LoadCasesTypes[pos];

                        model.ModelDefinitions.Add(lc);

                    }
                }

                //1.c GET LOAD COMBOS

                string[] LoadCombosNames = null;
                string[][] LoadCombosTypes = null;
                string[][] LoadCombosCases = null;
                string[][] LoadCombosDefinitions = null;
                double[][] LoadCombosMultipliers = null;

                StructureMapper.GetLoadCombos(ref SapModel, ref LoadCombosNames, ref LoadCombosTypes, ref LoadCombosCases, ref LoadCombosMultipliers, ref LoadCombosDefinitions);

                if (LoadCombosNames != null)
                {

                    foreach (string lcname in LoadCombosNames)
                    {
                        int pos = Array.IndexOf(LoadCombosNames, lcname);

                        List<Definition> LoadDefinitions = new List<Definition>();

                        foreach (string comboType in LoadCombosTypes[pos])
                        {
                            int pos2 = Array.IndexOf(LoadCombosTypes[pos], comboType);
                            Definition def = new Definition();
                            if (comboType == "LoadCase")
                            {
                                //find the existing Load Case
                                foreach (Definition d in model.ModelDefinitions)
                                {
                                    if (d.Type == Definitions.Type.LoadCase)
                                    {
                                        if (((LoadCase)d).name == LoadCombosDefinitions[pos][pos2])
                                        {
                                            def = d;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                def.Type = Definitions.Type.LoadCombo;
                                ((LoadCombo)def).name = comboType;
                            }

                            LoadDefinitions.Add(def);
                        }

                        //create a new load combo
                        LoadCombo loadcombo = new LoadCombo(lcname, LoadCombosTypes[pos][0], LoadDefinitions, LoadCombosMultipliers[pos].ToList());

                        model.ModelDefinitions.Add(loadcombo);

                    }
                }

                // 2. GET DYNAMO FRAMES ( get Loads and Releases that are assigned to that frame)
                //2.a GET LOADS that are Assigned to Frames

                Dictionary<int, string> DictFrm_PointLoads = new Dictionary<int, string>();
                Dictionary<int, string> DictFrm_DistLoads = new Dictionary<int, string>();

                //Get Point Loads
                string[] framesWithPointLoads = null;
                string[] PlPattern = null;
                int Pnumber = 0;
                int[] PmyType = null;
                string[] PCsys = null;
                int[] Pdir = null;
                double[] PRelDist = null;
                double[] PDist = null;
                double[] PVal = null;

                LoadMapper.GetPointLoads(ref SapModel, ref framesWithPointLoads, ref Pnumber, ref PlPattern, ref PmyType, ref PCsys, ref Pdir, ref PRelDist, ref PDist, ref PVal);
                if (framesWithPointLoads != null)
                {
                    for (int i = 0; i < framesWithPointLoads.Count(); i++)
                    {
                        DictFrm_PointLoads.Add(i, framesWithPointLoads[i]);
                    }
                }

                // Get Distributed Loads
                string[] framesWithDistributedLoads = null;
                string[] DlPattern = null;
                int Dnumber = 0;
                int[] DmyType = null;
                string[] DCsys = null;
                int[] Ddir = null;
                double[] DRD1 = null;
                double[] DRD2 = null;
                double[] DDist1 = null;
                double[] DDist2 = null;
                double[] DVal1 = null;
                double[] DVal2 = null;

                LoadMapper.GetDistributedLoads(ref SapModel, ref framesWithDistributedLoads, ref Dnumber, ref DlPattern, ref DmyType, ref DCsys, ref Ddir, ref DRD1, ref DRD2, ref DDist1, ref DDist2, ref DVal1, ref DVal2);
                if (framesWithDistributedLoads != null)
                {
                    for (int i = 0; i < framesWithDistributedLoads.Count(); i++)
                    {
                        DictFrm_DistLoads.Add(i, framesWithDistributedLoads[i]);
                    }
                }

                //2.b Get Frames

                // Calculate Length Scale Factor
                //Double SF = Utilities.UnitConversion("m", SapModelUnits); // Dynamo API Lenght Unit is 'meter'
                Double SF = 1;

                List<string> FrmIds = new List<string>();
                StructureMapper.GetSAPFrameList(ref SapModel,ref FrmIds);

                for (int i = 0; i < FrmIds.Count; i++)
                {
                    Point s = null;
                    Point e = null;
                    string matProp = "A992Fy50"; // default value
                    string secName = "W12X14"; // default value
                    string secCatalog = "AISC14"; // default value
                    string Just = "MiddleCenter"; // default value
                    double Rot = 0; // default value

                    StructureMapper.GetFrm(ref SapModel, FrmIds[i], ref s, ref e, ref matProp, ref secName, ref Just, ref Rot, ref secCatalog, SF);
                    SectionProp secProp = new SectionProp(secName, matProp, secCatalog);
                    Frame d_frm = new Frame(s, e, secProp, Just, Rot);
                    d_frm.Label = FrmIds[i];
                    model.StructuralElements.Add(d_frm);

                    //LOADS
                    // Frame might have multiple loads assigned to it...
                    d_frm.Loads = new List<Load>();

                    //Check if the frame has distributed loads
                    var outindexes = from obj in DictFrm_DistLoads
                                     where obj.Value == d_frm.Label
                                     select obj.Key;

                    foreach(int index in outindexes)
                    {
                       LoadPattern Dlp = null;
                       foreach (LoadPattern loadp in TempLPatterns)
                        {
                            if (loadp.name == DlPattern[index])
                            {
                                Dlp = loadp;
                                break;
                            }
                        }
                        if (Dlp != null)
                        {
                            // using relDist as true, and using the relative distance values DRD1 and DRD2
                            bool relDist = true;
                            Load l = new Load(Dlp, DmyType[index], Ddir[index], DRD1[index], DRD2[index], DVal1[index], DVal2[index], DCsys[index], relDist);
                            l.LoadType = "DistributedLoad";
                            d_frm.Loads.Add(l);
                        }
                    }

                    //Check if the frame has Point Loads
                    var outindexesO = from obj in DictFrm_PointLoads
                                      where obj.Value == d_frm.Label
                                      select obj.Key;

                    foreach (int index in outindexesO)
                    {
                        LoadPattern Plp = null;
                        foreach (LoadPattern loadp in TempLPatterns)
                        {
                            if (loadp.name == PlPattern[index])
                            {
                                Plp = loadp;
                                break;
                            }
                        }

                        if (Plp != null)
                        {
                            bool relativedist = true;
                            Load l = new Load(Plp, PmyType[index], Pdir[index], PRelDist[index], PVal[index], PCsys[index], relativedist);
                            l.LoadType = "PointLoad";
                            d_frm.Loads.Add(l);
                        }
                    }

                    //RELEASES
                    bool[] ii = new bool[6];
                    bool[] jj = new bool[6];
                    ReleaseMapper.Get(ref SapModel, FrmIds[i], ref ii, ref jj);

                    // Populate if return releases
                    if (ii.Contains(true) || jj.Contains(true))
                    {
                        d_frm.Releases = Release.Set(ii[0], jj[0]
                                                    , ii[1], jj[1]
                                                    , ii[2], jj[2]
                                                    , ii[3], jj[3]
                                                    , ii[4], jj[4]
                                                    , ii[5], jj[5]);
                    }
                }

                // 2.b Get Shells from SAP Model
                List<string> AreaIds = new List<string>();
                SAPConnection.StructureMapper.GetSAPAreaList(ref SapModel, ref AreaIds);

                for (int i = 0; i < AreaIds.Count; i++)
                {
                    Surface S = null;

                    string propName = string.Empty;
                    SAPConnection.StructureMapper.GetShell(ref SapModel, AreaIds[i], ref S, SF, ref propName);

                    int ShellType= 1;
                    bool DOF = true;
                    string MatProp = string.Empty;
                    double MatAngle = 0;
                    double Thickness = 0;
                    double Bending = 0;
                    SAPConnection.StructureMapper.GetShellProp(ref SapModel, propName, ref ShellType, ref DOF, ref MatProp, ref MatAngle, ref Thickness, ref Bending);
                    ShellProp sP = new ShellProp(propName, ShellType, DOF, MatProp, MatAngle, Thickness * SF, Bending);

                    Shell d_Shell = new Shell(S, sP);
                    d_Shell.Label = AreaIds[i];
                    model.StructuralElements.Add(d_Shell);
                }

                // 3. GET RESTRAINTS
                int CountRes = RestraintMapper.Count(ref SapModel);
                if (CountRes > 0)
                {

                    List<string> PtIds = new List<string>();
                    RestraintMapper.GetSupportedPts(ref SapModel, ref PtIds);

                    // Populate Dynamo Restraints
                    foreach (var PtId in PtIds)
                    {
                        Point Pti = null;
                        bool[] restraints = new bool[6];

                        RestraintMapper.Get(ref SapModel, PtId, ref Pti, ref restraints, SF);

                        Joint myj = new Joint(Pti);
                        myj.Label = PtId;

                        // Populate on Joint Restraints
                        Restraint support = Restraint.Define(restraints[0], restraints[1], restraints[2], restraints[3], restraints[4], restraints[5]);

                        myj.JointRestraint = support;

                        model.StructuralElements.Add(myj);
                    }
                }

            }
            else
            {
                throw new Exception("Make sure SAP Model is open!");
            }

            // Get Groups
            List<String> SapGroups = new List<string>();
            SAPConnection.GroupMapper.GetSAPGroupList(ref SapModel, ref SapGroups);

            int counter = 0;
            foreach (var g in SapGroups)
            {
                Group myG = new Group();
                myG.Name = g;
                myG.GroupElements = new List<Element>();

                // get assignments
                int[] types = null;
                string[] Labels = null;
                SAPConnection.GroupMapper.GetGroupAssignments(ref SapModel, g, ref types, ref Labels);

                if (Labels!=null && Labels.Count() > 0)
                {
                    for (int i = 0; i < Labels.Length; i++)
                    {
                        if (types[i] == 1) // Joint
                        {
                            try
                            {
                                var gel = (from el in model.StructuralElements
                                           where el.Label == Labels[i] && el.Type == Structure.Type.Joint
                                           select el).First();
                                if (gel != null)
                                {
                                    myG.GroupElements.Add(gel);
                                }

                            }
                            catch (Exception) { }

                        }
                        else if (types[i] == 2) // frame
                        {
                            try
                            {
                                var gel = (from el in model.StructuralElements
                                           where el.Type == Structure.Type.Frame && el.Label == Labels[i]
                                           select el).First();
                                if (gel != null)
                                {
                                    myG.GroupElements.Add(gel);
                                }

                            }
                            catch (Exception) { }
                        }
                        else if (types[i] == 3) // cable
                        {
                            //TODO: After cable object defined
                        }
                        else if (types[i] == 5) // shell
                        {
                            var gel = (from el in model.StructuralElements
                                       where el.Type == Structure.Type.Shell && el.Label == Labels[i]
                                       select el).First();
                            if (gel != null)
                            {
                                myG.GroupElements.Add(gel);
                            }
                        }

                    }
                }
                else
                {
                   counter++;
                }

                //Add to Model definitions
                model.ModelDefinitions.Add(myG);

            }
            if (counter == SapGroups.Count)
            {
                //throw new Exception("The group(s) have no members assigned");
            }
        }
Exemplo n.º 44
0
        //Length Scale Factor
        public static void GetShell(ref cSapModel Model, string areaid, ref Surface BaseS, double LSF, ref string PropName)
        {
            long ret = 0;

            int NumOfPts = 0;
            string[] PtsNames = null;
            ret = Model.AreaObj.GetPoints(areaid, ref NumOfPts, ref PtsNames);

            List<Point> dynPts = new List<Point>();
            List<IndexGroup> igs = new List<IndexGroup>();
            for (int i = 0; i < PtsNames.Count(); i++)
            {
                double x = 0;
                double y = 0;
                double z = 0;

                ret = Model.PointObj.GetCoordCartesian(PtsNames[i], ref x, ref y, ref z);

                Point p = Point.ByCoordinates(x * LSF, y * LSF, z * LSF);
                dynPts.Add(p);
            }

            //Mesh.ByPointsFaceIndices()
            BaseS = Surface.ByPerimeterPoints(dynPts);

            // Get assigned Property Name
            ret = Model.AreaObj.GetProperty(areaid, ref PropName);
        }
Exemplo n.º 45
0
        public static void GetShellProp(ref cSapModel Model, string PropName, ref int ShellType, ref bool DOF, ref string MatProp, ref double MatAngle, ref double Thickness, ref double Bending)
        {
            int type = 1;
            int color = 1;
            string notes = string.Empty;
            string guid = string.Empty;

            long ret = Model.PropArea.GetShell_1(PropName, ref ShellType, ref DOF, ref MatProp, ref MatAngle, ref Thickness, ref Bending, ref color, ref notes, ref guid);

            //ShellType = Enum.GetName(typeof(ShellType), type);
        }
Exemplo n.º 46
0
 // READ FROM SAPMODEL
 // to extract the Section Names on Specific Section Catalog
 public static void GetSectionsfromCatalog(ref cSapModel Model, string SC, ref string[] Names)
 {
     int number = 0;
     eFramePropType[] PropType = null;
     long ret = Model.PropFrame.GetPropFileNameList(SC, ref number, ref Names, ref PropType);
 }
Exemplo n.º 47
0
 public static void GetSAPJointList(ref cSapModel Model, ref List<string> myJointList)
 {
     string[] IDs = null;
     int NumbOfAreas = 0;
     long ret = Model.PointObj.GetNameList(ref NumbOfAreas, ref IDs);
     if (IDs != null)
     {
         myJointList = IDs.ToList();
     }
 }
Exemplo n.º 48
0
 // <GUID, Label>
 /// <summary>
 /// Harvesting the active SAP and creates dictionardy holds FramesGUID and Labels
 /// </summary>
 /// <param name="Model">Active SAP Model</param>
 /// <param name="myFrameList"> List of Labels of SAP Frames </param>
 public static void GetSAPFrameList(ref cSapModel Model, ref List<string> myFrameList)
 {
     string[] IDs = null;
     int NumbOfFrames = 0;
     long ret = Model.FrameObj.GetNameList(ref NumbOfFrames, ref IDs);
     if (IDs != null)
     {
         myFrameList = IDs.ToList();
     }
 }
Exemplo n.º 49
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="Model"></param>
 /// <param name="Label"></param>
 public static void DeleteFrm(ref cSapModel Model, string Label)
 {
     long ret = Model.FrameObj.Delete(Label);
 }
Exemplo n.º 50
0
 //Check if Section exists
 public static bool IsSectionExistsFrm(ref cSapModel mySapModel, string DSection, ref string error)
 {
     int number = 0;
     string[] SectionNames = null;
     long ret = mySapModel.PropFrame.GetNameList(ref number, ref SectionNames);
     if (ret == 1) error = "Error getting the  section property names";
     if (SectionNames != null && SectionNames.Contains(DSection))
     {
         return true;
     }
     return false;
 }
Exemplo n.º 51
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="Model"></param>
 /// <param name="Label"></param>
 public static void DeleteArea(ref cSapModel Model, string Label, ref string error)
 {
     long ret = Model.AreaObj.Delete(Label);
     if (ret == 1) error = string.Format("Error deleting shell {0}", Label);
 }
Exemplo n.º 52
0
        // DEFINE LOAD CASE IN SAP
        public static void AddLoadCase(ref cSapModel Model, string Name, int LoadCount, ref string[] LoadType, ref string[] LoadName, ref double[] SF, string LCType)
        {
            if (LCType == eLoadCaseType.CASE_LINEAR_STATIC.ToString())
            {
                int ret = Model.LoadCases.StaticLinear.SetCase(Name);
                ret = Model.LoadCases.StaticLinear.SetLoads(Name, LoadCount, ref LoadType, ref LoadName, ref SF);
            }
            else if (LCType == eLoadCaseType.CASE_NONLINEAR_STATIC.ToString())
            {
                int ret = Model.LoadCases.StaticNonlinear.SetCase(Name);
                ret = Model.LoadCases.StaticNonlinear.SetLoads(Name, LoadCount, ref LoadType, ref LoadName, ref SF);

                //if it is nonlinear STAGED, it is different:
                //ret = Model.LoadCases.StaticNonlinearStaged.SetCase(Name);
                //must implement stageData methods

            }
            else if (LCType == eLoadCaseType.CASE_MODAL.ToString())
            {
                //throw new Exception("Load Case Type not supported");

                //this needs more inputs
                //if SubType==1 (Eigen)
                //int ret = Model.LoadCases.ModalEigen.SetCase(Name);
                //ret = Model.LoadCases.ModalEigen.SetLoads(Name, LoadCount, ref Loadtype, ref LoadName, MyTargetPar, MyStaticCorrect);

                //if SubType==2 (Ritz)
                //int ret = Model.LoadCases.ModalRitz.SetCase(Name);
                //ret = SapModel.LoadCases.ModalRitz.SetLoads(Name, LoadCount, ref LoadType, ref LoadName, MyRitzMaxCyc, MyTargetPar);

            }
            else if (LCType == eLoadCaseType.CASE_RESPONSE_SPECTRUM.ToString())
            {
                throw new Exception("Load Case Type not supported");

                //int ret = Model.LoadCases.ResponseSpectrum.SetCase(Name);

                //this needs more inputs
                //ret = SapModel.LoadCases.ResponseSpectrum.SetLoads(Name, LoadCount, ref LoadName, MyFunc, ref SF, MyCSys, MyAng);

            }
            else if (LCType == eLoadCaseType.CASE_LINEAR_HISTORY.ToString())
            {
                throw new Exception("Load Case Type not supported");

                //int ret = Model.LoadCases.ModHistLinear.SetCase(Name);

                //this needs more inputs
                //ret = Model.LoadCases.ModHistLinear.SetLoads(Name, LoadCount, ref LoadType, ref LoadName, MyFunc, ref SF, MyTF, MyAT, MyCSys, MyAng);

                //this needs to pass the motion type, transient or periodic

            }
            else if (LCType == eLoadCaseType.CASE_NONLINEAR_HISTORY.ToString())
            {
                throw new Exception("Load Case Type not supported");

                //int ret = ret = Model.LoadCases.ModHistNonlinear.SetCase(Name);
                //this needs more inputs
                //ret = Model.LoadCases.ModHistNonlinear.SetLoads(Name, LoadCount, ref LoadType, ref LoadName, MyFunc, ref SF, MyTF, MyAT, MyCSys, MyAng)

            }
            else if (LCType == eLoadCaseType.CASE_LINEAR_DYNAMIC.ToString())
            {
                throw new Exception("Load Case Type not supported");

                //int ret = Model.LoadCases.DirHistLinear.SetCase(Name);
                //this needs more inputs
                //ret = Model.LoadCases.DirHistLinear.SetLoads(Name, LoadCount, ref LoadType, ref LoadName, MyFunc, ref SF, MyTF, MyAT, MyCSys, MyAng);
            }
            else if (LCType == eLoadCaseType.CASE_NONLINEAR_DYNAMIC.ToString())
            {
                int ret = Model.LoadCases.StaticNonlinear.SetCase(Name);
                ret = Model.LoadCases.StaticNonlinear.SetLoads(Name, LoadCount, ref LoadType, ref LoadName, ref SF);
            }
            else if (LCType == eLoadCaseType.CASE_MOVING_LOAD.ToString())
            {
                throw new Exception("Load Case Type not supported");
                //int ret = Model.LoadCases.Moving.SetCase(Name);

                //this needs more inputs
                //ret = Model.LoadCases.Moving.SetLoads(Name, LoadCount, MyMyClass, ref SF, MyMin, MyMax);

            }
            else if (LCType == eLoadCaseType.CASE_BUCKLING.ToString())
            {
                int ret = Model.LoadCases.Buckling.SetCase(Name);
                ret = Model.LoadCases.Buckling.SetLoads(Name, 2, ref LoadType, ref LoadName, ref SF);
            }
            else if (LCType == eLoadCaseType.CASE_STEADY_STATE.ToString())
            {
                throw new Exception("Load Case Type not supported");
               // int ret = Model.LoadCases.SteadyState.SetCase(Name);
                //this needs more inputs
                //ret = Model.LoadCases.SteadyState.SetLoads(Name, LoadCount, ref LoadType, ref LoadName, MyFunc, ref SF, MyPhaseAngle, MyCSys, MyAng);

            }
            else if (LCType == eLoadCaseType.CASE_POWER_SPECTRAL_DENSITY.ToString())
            {
                throw new Exception("Load Case Type not supported");
                //int ret = Model.LoadCases.PSD.SetCase(Name);
                //this needs more inputs
                //ret = Model.LoadCases.PSD.SetLoads(Name, LoadCount, ref LoadType, ref LoadName, MyFunc, ref SF, MyPhaseAngle, MyCSys, MyAng);
            }
            else if (LCType == eLoadCaseType.CASE_LINEAR_STATIC_MULTISTEP.ToString())
            {
                int ret = Model.LoadCases.StaticLinearMultistep.SetCase(Name);
                ret = Model.LoadCases.StaticLinearMultistep.SetLoads(Name, LoadCount, ref LoadType, ref LoadName, ref SF);
            }
            else if (LCType == eLoadCaseType.CASE_HYPERSTATIC.ToString())
            {
                int ret = Model.LoadCases.HyperStatic.SetCase(Name);

            }
        }
Exemplo n.º 53
0
        public static void CreateorUpdateJoint(ref cSapModel Model, Point pt, ref string Id, bool update, double SF)
        {
            if (!update) // create new Joint
            {
                string dummy = string.Empty;
                long ret = Model.PointObj.AddCartesian(pt.X * SF, pt.Y * SF, pt.Z * SF, ref dummy);
                Id = dummy;
                ret = Model.PointObj.SetSpecialPoint(Id, true);
            }
            else
            {  // get coordinates and compare
                double jx = 0;
                double jy = 0;
                double jz = 0;
                long ret = Model.PointObj.GetCoordCartesian(Id, ref jx, ref jy, ref jz);

                if (pt.X != jx || pt.Y != jy || pt.Z != jz)
                {
                    string dummy = string.Empty;
                    ret = Model.PointObj.AddCartesian(pt.X , pt.Y , pt.Z , ref dummy); // it will return existing if exits
                    if (dummy != Id)
                    {
                        ret = Model.EditPoint.ChangeCoordinates(Id, pt.X, pt.Y , pt.Z); // this does the trick and delete the old one
                        ret = Model.PointObj.ChangeName(dummy, Id);
                    }
                }
            }
        }
Exemplo n.º 54
0
        public static void GetLoadCases(ref cSapModel Model, ref string[] LoadCaseNames, ref double[] LoadCaseMultipliers, ref string[] LoadCaseTypes)
        {
            int NumberNames = 0;
            int ret = Model.LoadCases.GetNameList(ref NumberNames, ref LoadCaseNames);

            LoadCaseMultipliers = new double[NumberNames];
            LoadCaseTypes = new string[NumberNames];

            foreach (string lcname in LoadCaseNames)
            {

                //Parameters that we need to get
                //dummy eLoadCaseType
                eLoadCaseType cType = eLoadCaseType.CASE_LINEAR_STATIC;
                int subType = 0;

                int pos = Array.IndexOf(LoadCaseNames, lcname);

                //get the load case type
                ret = Model.LoadCases.GetType(lcname, ref cType, ref subType);
                LoadCaseTypes[pos] = cType.ToString();

            }
        }
Exemplo n.º 55
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="Model"></param>
 public static void RefreshView(ref cSapModel Model)
 {
     Model.View.RefreshView(0, false);
 }
Exemplo n.º 56
0
        public static void GetLoadCombos(ref cSapModel Model, ref string[] LoadComboNames, ref string[][] LoadComboTypes, ref string[][] LoadComboCase, ref double[][] Multipliers, ref string[][] LoadComboDefinitions)
        {
            int NumberNames = 0;
            int ret = Model.RespCombo.GetNameList(ref NumberNames, ref LoadComboNames);

            LoadComboTypes=new string[NumberNames][];
            LoadComboCase = new string[NumberNames][];
            Multipliers = new double[NumberNames][];
            LoadComboDefinitions = new string[NumberNames][];

            if (LoadComboNames != null)
            {
                foreach (string lc in LoadComboNames)
                {
                    int pos = Array.IndexOf(LoadComboNames, lc);

                    int numberItems = 0;
                    eCType[] cType = null;
                    string[] cName = null;
                    double[] sf = null;
                    ret = Model.RespCombo.GetCaseList(lc, ref numberItems, ref cType, ref cName, ref sf);

                    LoadComboTypes[pos] = new string[numberItems];
                    LoadComboCase[pos] = new string[numberItems];
                    Multipliers[pos] = new double[numberItems];
                    LoadComboDefinitions[pos] = new string[numberItems];
                    foreach (string cn in cName)
                    {
                        int pos2 = Array.IndexOf(cName, cn);
                        try
                        {
                            LoadComboTypes[pos][pos2] = cType[pos2].ToString();
                            LoadComboCase[pos][pos2] = cn;
                            Multipliers[pos][pos2] = sf[pos2];
                            LoadComboDefinitions[pos][pos2] = cName[pos2];

                        }
                        catch (Exception ex)
                        {

                            string t = ex.Message;
                        }
                    }
                }
            }
        }
Exemplo n.º 57
0
 public static bool ChangeNameSAPJoint(ref cSapModel Model, string Name, string NewName)
 {
     long ret = Model.PointObj.ChangeName(Name, NewName);
     if (ret == 0) { return true; } else { return false; }
 }
Exemplo n.º 58
0
 // Area  prop
 public static void SetPropArea(ref cSapModel Model, string PropName, int ShellType, bool DOF, string MatProp, double MatAngle, double Thickness, double Bending, ref string error)
 {
     //int type = (int)((ShellType)Enum.Parse(typeof(ShellType), ShellType));
     long ret = Model.PropArea.SetShell_1(PropName, ShellType, DOF, MatProp, MatAngle, Thickness, Bending);
     if (ret == 1) error = string.Format("Error setting the area property {0}", PropName);
 }
Exemplo n.º 59
0
 public static void DeleteUnconnectedPts(ref cSapModel Model)
 {
     // get name list
     List<string> PtList = new List<string>();
     GetSAPJointList(ref Model, ref PtList);
     foreach (var pt in PtList)
     {
         int Num = 0;
         int[] Otype = null;
         string[] OName = null;
         int[] refNum = null;
         Model.PointObj.GetConnectivity(pt, ref Num, ref Otype, ref OName, ref refNum);
         if (Num == 0)
         { // delete if not connected
             int ret = Model.PointObj.SetSpecialPoint(pt, false);
             ret = Model.EditPoint.ChangeCoordinates_1(pt, 0, 0, 0);  // this will merge them into one location at least !
             ret = Model.PointObj.DeleteSpecialPoint(pt);
         }
     }
 }
Exemplo n.º 60
0
        //Length Scale Factor
        public static void GetFrm(ref cSapModel Model, string frmId, ref Point i, ref Point j, ref string MatProp, ref string SecName, ref string Just, ref double Rot, ref string SecCatalog, double LSF)
        {
            long ret = 0;
            // Get Geometry
            // SAP Frame start and end point
            string StartPoint = string.Empty;
            string EndPoint = string.Empty;
            Double myStartX = 0;
            Double myStartY = 0;
            Double myStartZ = 0;
            Double myEndX = 0;
            Double myEndY = 0;
            Double myEndZ = 0;

            // getting start and end point
            ret = Model.FrameObj.GetPoints(frmId, ref StartPoint, ref EndPoint);
            //getting coordinates of starting point
            ret = Model.PointObj.GetCoordCartesian(StartPoint, ref myStartX, ref myStartY, ref myStartZ);
            //getting coordinates of ending point
            ret = Model.PointObj.GetCoordCartesian(EndPoint, ref myEndX, ref myEndY, ref myEndZ);

            i = Point.ByCoordinates(myStartX * LSF, myStartY * LSF, myStartZ * LSF);
            j = Point.ByCoordinates(myEndX * LSF, myEndY * LSF, myEndZ * LSF);

            // Section
            string SAuto = string.Empty;
            ret = Model.FrameObj.GetSection(frmId, ref SecName, ref SAuto);

            // MatProp
            MaterialMapper.SapToDynamo(ref Model, SecName, ref MatProp, ref SecCatalog);

            // Justification
            Just = JustificationMapper.SapToDynamoFrm(ref Model, frmId);

            // Rotation
            bool ifadvanced = false;
            ret = Model.FrameObj.GetLocalAxes(frmId, ref Rot, ref ifadvanced);
        }