Exemple #1
0
 public static Bar SetBarInsertionPoint(this Bar bar, BarInsertionPointLocation insertionPoint = BarInsertionPointLocation.Centroid, bool modifyStiffness = true)
 {
     return((Bar)bar.AddFragment(new BarInsertionPoint()
     {
         InsertionPoint = insertionPoint, ModifyStiffness = modifyStiffness
     }, true));
 }
Exemple #2
0
 public static Bar SetBarInsertionPoint(this Bar bar, BarInsertionPointLocation barInsertionPoint = BarInsertionPointLocation.Centroid)
 {
     return(bar.SetBarInsertionPoint(barInsertionPoint, true));
 }
Exemple #3
0
        /***************************************************/
        /**** Private Methods                           ****/
        /***************************************************/

        private List <Bar> ReadBars(List <string> ids = null)
        {
            List <Bar> bhomBars = new List <Bar>();
            Dictionary <string, Node>             bhomNodes    = ReadNodes().ToDictionary(x => GetAdapterId <string>(x));
            Dictionary <string, ISectionProperty> bhomSections = ReadSectionProperties().ToDictionary(x => GetAdapterId <string>(x));

            int nameCount = 0;

            string[] nameArr = { };
            m_model.FrameObj.GetNameList(ref nameCount, ref nameArr);

            ids = FilterIds(ids, nameArr);

            foreach (string id in ids)
            {
                SAP2000Id sap2000id = new SAP2000Id();
                sap2000id.Id = id;

                try
                {
                    Bar    bhomBar = new Bar();
                    string startId = "";
                    string endId   = "";
                    m_model.FrameObj.GetPoints(id, ref startId, ref endId);

                    bhomBar.StartNode = bhomNodes[startId];
                    bhomBar.EndNode   = bhomNodes[endId];

                    bool[]   restraintStart = new bool[6];
                    double[] springStart    = new double[6];
                    bool[]   restraintEnd   = new bool[6];
                    double[] springEnd      = new double[6];

                    m_model.FrameObj.GetReleases(id, ref restraintStart, ref restraintEnd, ref springStart, ref springEnd);
                    bhomBar.Release = Adapter.SAP2000.Convert.GetBarRelease(restraintStart, springStart, restraintEnd, springEnd);

                    //bhomBar.Release.StartRelease = Adapter.SAP2000.Convert.GetConstraint6DOF(restraintStart, springStart);
                    //bhomBar.Release.EndRelease = Adapter.SAP2000.Convert.GetConstraint6DOF(restraintEnd, springEnd);

                    string propertyName = "";
                    string sAuto        = ""; //This is the name of the auto select list assigned to the frame object, if any.

                    if (m_model.FrameObj.GetSection(id, ref propertyName, ref sAuto) == 0)
                    {
                        ISectionProperty bhProp = new ExplicitSection();
                        bhomSections.TryGetValue(propertyName, out bhProp);
                        bhomBar.SectionProperty = bhProp;
                    }

                    double angle    = 0;
                    bool   advanced = false;

                    if (m_model.FrameObj.GetLocalAxes(id, ref angle, ref advanced) == 0)
                    {
                        if (advanced)
                        {
                            Engine.Base.Compute.RecordWarning("Advanced local axes are not yet supported by this toolkit. Bar " + id + " has been created with orientation angle = 0");
                            angle = 0;
                        }
                        bhomBar.OrientationAngle = angle * System.Math.PI / 180;
                    }
                    else
                    {
                        Engine.Base.Compute.RecordWarning("Could not get local axes for bar " + id + ". Orientation angle is 0 by default");
                    }

                    // Get the groups the bar is assigned to
                    string   guid       = null;
                    int      numGroups  = 0;
                    string[] groupNames = new string[0];
                    if (m_model.FrameObj.GetGroupAssign(id, ref numGroups, ref groupNames) == 0)
                    {
                        foreach (string grpName in groupNames)
                        {
                            bhomBar.Tags.Add(grpName);
                        }
                    }

                    if (m_model.FrameObj.GetGUID(id, ref guid) == 0)
                    {
                        sap2000id.PersistentId = guid;
                    }

                    bhomBar.SetAdapterId(sap2000id);

                    /***************************************************/
                    /* SAP Fragments                                   */
                    /***************************************************/

                    // Automesh

                    bool   autoMesh          = false;
                    bool   autoMeshAtPoints  = false;
                    bool   autoMeshAtLines   = false;
                    int    numSegs           = 0;
                    double autoMeshMaxLength = 0.0;

                    m_model.FrameObj.GetAutoMesh(id, ref autoMesh, ref autoMeshAtPoints, ref autoMeshAtLines, ref numSegs, ref autoMeshMaxLength);
                    if (autoMesh)
                    {
                        bhomBar = bhomBar.SetBarAutoMesh(autoMesh, autoMeshAtPoints, autoMeshAtLines, numSegs, autoMeshMaxLength);
                    }

                    // Design Procedure

                    int designProcedure = (int)BarDesignProcedureType.NoDesign;

                    if (m_model.FrameObj.GetDesignProcedure(id, ref designProcedure) == 0)
                    {
                        BarDesignProcedureType designProcedureType = (BarDesignProcedureType)designProcedure;
                        bhomBar = bhomBar.SetBarDesignProcedure(designProcedureType);
                    }

                    // Insertion Point Offset
                    // Need to add more information to capture coordinate system?? GetCoordSys method and transform local csys
                    int  insertionPoint  = (int)BarInsertionPointLocation.Centroid;
                    bool mirror          = false;
                    bool modifyStiffness = false;

                    double[] offset1 = new double[3];
                    double[] offset2 = new double[3];
                    string   cSys    = "";

                    if (m_model.FrameObj.GetInsertionPoint(id, ref insertionPoint, ref mirror, ref modifyStiffness, ref offset1, ref offset2, ref cSys) == 0)
                    {
                        BarInsertionPointLocation barInsertionPoint = (BarInsertionPointLocation)insertionPoint;
                        bhomBar = bhomBar.SetBarInsertionPoint(barInsertionPoint, modifyStiffness);
                    }
                    bhomBars.Add(bhomBar);
                }

                catch
                {
                    ReadElementError("Bar", id.ToString());
                }
            }
            return(bhomBars);
        }