Beispiel #1
0
        public static string Description(this LinkConstraint constraint)
        {
            if (constraint == null)
            {
                return("null constraint");
            }

            string desc = constraint.XtoX ? "x" : "f";

            desc += constraint.YtoY ? "x" : "f";
            desc += constraint.ZtoZ ? "x" : "f";

            desc += constraint.XXtoXX ? "x" : "f";
            desc += constraint.YYtoYY ? "x" : "f";
            desc += constraint.ZZtoZZ ? "x" : "f";

            desc += constraint.XtoYY ? "x" : "f";
            desc += constraint.XtoZZ ? "x" : "f";

            desc += constraint.YtoXX ? "x" : "f";
            desc += constraint.YtoZZ ? "x" : "f";

            desc += constraint.ZtoXX ? "x" : "f";
            desc += constraint.ZtoYY ? "x" : "f";

            return(desc);
        }
Beispiel #2
0
        /***************************************************/

        private bool CreateObject(LinkConstraint bhLinkConstraint)
        {
            string name = bhLinkConstraint.Name;

            bool[] dof = new bool[6];

            for (int i = 0; i < 6; i++)
            {
                dof[i] = true;
            }

            bool[] fix = new bool[6];

            fix[0] = bhLinkConstraint.XtoX;
            fix[1] = bhLinkConstraint.ZtoZ;
            fix[2] = bhLinkConstraint.YtoY;
            fix[3] = bhLinkConstraint.XXtoXX;
            fix[4] = bhLinkConstraint.ZZtoZZ;
            fix[5] = bhLinkConstraint.YYtoYY;

            double[] stiff = new double[6];
            double[] damp  = new double[6];

            int ret = m_model.PropLink.SetLinear(name, ref dof, ref fix, ref stiff, ref damp, 0, 0);

            if (ret != 0)
            {
                CreateElementError("Link Constraint", name);
            }

            return(ret == 0);
        }
Beispiel #3
0
        /***************************************************/

        private bool CreateObject(RigidLink bhLink)
        {
            bool success = true;
            int  retA    = 0;
            int  retB    = 0;

            string name      = "";
            string givenName = "";
            string bhId      = bhLink.CustomData[AdapterId].ToString();

            name = bhId;

            LinkConstraint constraint = bhLink.Constraint;//not used yet
            Node           masterNode = bhLink.MasterNode;
            List <Node>    slaveNodes = bhLink.SlaveNodes;
            bool           multiSlave = slaveNodes.Count() == 1 ? false : true;

            //double XI = masterNode.Position.X;
            //double YI = masterNode.Position.Y;
            //double ZI = masterNode.Position.Z;

            for (int i = 0; i < slaveNodes.Count(); i++)
            {
                //double XJ = slaveNodes[i].Position.X * 1000;//multiply by 1000 to compensate for Etabs strangeness: yes, one end is divided by 1000 the other end is not!
                //double YJ = slaveNodes[i].Position.Y * 1000;
                //double ZJ = slaveNodes[i].Position.Z * 1000;

                name = multiSlave == true ? name + ":::" + i : name;

                //retA = model.LinkObj.AddByCoord(XI, YI, ZI, XJ, YJ, ZJ, ref givenName, false, "Default", name);
                retA = m_model.LinkObj.AddByPoint(masterNode.CustomData[AdapterId].ToString(), slaveNodes[i].CustomData[AdapterId].ToString(), ref givenName, false, constraint.Name, name);
            }

            return(success);
        }
Beispiel #4
0
        /***************************************************/

        private List <LinkConstraint> ReadLinkConstraints(List <string> ids = null)
        {
            List <LinkConstraint> propList = new List <LinkConstraint>();
            int nameCount = 0;

            string[] names = { };

            if (ids == null)
            {
                m_model.PropLink.GetNameList(ref nameCount, ref names);
                ids = names.ToList();
            }

            foreach (string id in ids)
            {
                eLinkPropType linkType = eLinkPropType.Linear;
                m_model.PropLink.GetTypeOAPI(id, ref linkType);
                LinkConstraint constr = Helper.LinkConstraint(id, linkType, m_model);
                if (constr != null)
                {
                    propList.Add(constr);
                }
                else
                {
                    Engine.Reflection.Compute.RecordError("Failed to read link constraint with id :" + id);
                }
            }
            return(propList);
        }
Beispiel #5
0
        /***************************************************/

        public static void ToSAP2000(this LinkConstraint linkConstraint, out bool[] dof, out bool[] fix, out double[] stiff, out double[] damp, out double dj2, out double dj3)
        {
            dof = new bool[6] {
                true, true, true, true, true, true
            };

            fix = new bool[6] {
                linkConstraint.XtoX,
                linkConstraint.YtoY,
                linkConstraint.ZtoZ,
                linkConstraint.XXtoXX,
                linkConstraint.YYtoYY,
                linkConstraint.ZZtoZZ
            };

            stiff = new double[6] {
                0, 0, 0, 0, 0, 0
            };

            damp = new double[6] {
                0, 0, 0, 0, 0, 0
            };

            dj2 = 0;

            dj3 = 0;
        }
Beispiel #6
0
        /***************************************************/

        private bool CreateObject(RigidLink bhLink)
        {
            bool success = true;

            List <string> linkIds = new List <string>();
            List <object> guids   = new List <object>();

            LinkConstraint constraint     = bhLink.Constraint;//not used yet
            Node           primaryNode    = bhLink.PrimaryNode;
            List <Node>    secondaryNodes = bhLink.SecondaryNodes;

            ETABSId multiId = new ETABSId();

            for (int i = 0; i < secondaryNodes.Count(); i++)
            {
                string name = "";
                string guid = null;

                m_model.LinkObj.AddByPoint(GetAdapterId <string>(primaryNode), GetAdapterId <string>(secondaryNodes[i]), ref name, false, constraint.DescriptionOrName());
                m_model.LinkObj.GetGUID(name, ref guid);

                linkIds.Add(name);
            }

            multiId.Id = linkIds;
            bhLink.SetAdapterId(multiId);

            return(success);
        }
Beispiel #7
0
        /***************************************************/

        public static LinkConstraint LinkConstraintZPlatePin(string name = "z-Plate Pin")
        {
            LinkConstraint constr = new LinkConstraint();

            constr.ZtoZ  = true;
            constr.ZtoXX = true;
            constr.ZtoYY = true;
            constr.Name  = name;
            return(constr);
        }
Beispiel #8
0
        public static LinkConstraint LinkConstraintXYPlanePin(string name = "xy-Plane Pin")
        {
            LinkConstraint constr = new LinkConstraint();

            constr.XtoX  = true;
            constr.XtoZZ = true;
            constr.YtoY  = true;
            constr.YtoZZ = true;
            constr.Name  = name;
            return(constr);
        }
        /***************************************************/
        /**** Public Methods                            ****/
        /***************************************************/

        public static LinkConstraint LinkConstraintYPlateZPlate(string name = "z-Plate")
        {
            LinkConstraint constr = new LinkConstraint();

            constr.ZtoZ   = true;
            constr.ZtoXX  = true;
            constr.ZtoYY  = true;
            constr.XXtoXX = true;
            constr.YYtoYY = true;
            constr.Name   = name;
            return(constr);
        }
Beispiel #10
0
        /***************************************************/

        public static LinkConstraint LinkConstraintXPlate(string name = "x-Plate")
        {
            LinkConstraint constr = new LinkConstraint();

            constr.XtoX   = true;
            constr.XtoYY  = true;
            constr.XtoZZ  = true;
            constr.YYtoYY = true;
            constr.ZZtoZZ = true;
            constr.Name   = name;
            return(constr);
        }
Beispiel #11
0
        public static LinkConstraint LinkConstraintPinned(string name = "Pinned")
        {
            bool[] fixities = new bool[12];

            for (int i = 0; i < 9; i++)
            {
                fixities[i] = true;
            }

            LinkConstraint constr = LinkConstraint(name, fixities.ToList());

            return(constr);
        }
Beispiel #12
0
        /***************************************************/
        /**** Private methods                           ****/
        /***************************************************/

        private bool CreateCollection(IEnumerable <RigidLink> links)
        {
            if (links.Count() > 0)
            {
                int linkIdNum             = 0;
                int lineIdNum             = 0;
                List <RigidLink> linkList = links.ToList();
                rf.Member[]      rfLinks  = new rf.Member[linkList.Count()];

                for (int i = 0; i < links.Count(); i++)
                {
                    linkIdNum = GetAdapterId <int>(linkList[i]);

                    //check for multiple secondary nodes
                    if (linkList[i].SecondaryNodes.Count > 1)
                    {
                        Engine.Base.Compute.RecordWarning("Multiple secondary nodes detected! Link no. " + linkIdNum + " was created using only the first secondary node!");
                    }


                    //create line
                    lineIdNum = modelData.GetLineCount() + 1;
                    rf.Line centreLine  = new rf.Line();
                    int     startNodeId = GetAdapterId <int>(linkList[i].PrimaryNode);
                    int     endNodeId   = GetAdapterId <int>(linkList[i].SecondaryNodes[0]);
                    centreLine.NodeList = String.Join(",", new int[] { startNodeId, endNodeId });
                    centreLine.Type     = rf.LineType.PolylineType;
                    modelData.SetLine(centreLine);

                    rf.Member rfLink = new rf.Member();
                    rfLink.No     = linkIdNum;
                    rfLink.LineNo = lineIdNum;
                    rfLink.Type   = rf.MemberType.Rigid;

                    LinkConstraint lc = linkList[0].Constraint;
                    if (lc != null)
                    {
                        if (lc.XtoX != true || lc.YtoY != true || lc.ZtoZ != true || lc.XXtoXX != true || lc.YYtoYY != true || lc.ZZtoZZ != true)
                        {
                            Engine.Base.Compute.RecordWarning("Hinges on RigidLinks are not supported. Member no. " + linkIdNum + " created as fixed!");
                        }
                    }

                    modelData.SetMember(rfLink);
                }

                //modelData.SetMembers(rfBars);
            }

            return(true);
        }
Beispiel #13
0
        /***************************************************/
        /**** Private Methods                           ****/
        /***************************************************/

        private List <LinkConstraint> ReadLinkConstraints(List <string> ids = null)
        {
            List <LinkConstraint> propList = new List <LinkConstraint>();

            int nameCount = 0;

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

            ids = FilterIds(ids, nameArr);

            foreach (string id in ids)
            {
                eLinkPropType linkType = eLinkPropType.Linear;
                m_model.PropLink.GetTypeOAPI(id, ref linkType);

                LinkConstraint constr = new LinkConstraint();

                SAP2000Id sap2000id = new SAP2000Id();
                sap2000id.Id = id;
                constr.SetAdapterId(sap2000id);

                switch (linkType)
                {
                case eLinkPropType.Linear:
                    constr = GetLinearLinkConstraint(id);
                    break;

                case eLinkPropType.Damper:
                case eLinkPropType.Gap:
                case eLinkPropType.Hook:
                case eLinkPropType.PlasticWen:
                case eLinkPropType.Isolator1:
                case eLinkPropType.Isolator2:
                case eLinkPropType.MultilinearElastic:
                case eLinkPropType.MultilinearPlastic:
                case eLinkPropType.Isolator3:
                default:
                    Engine.Base.Compute.RecordWarning($"Reading of LinkConstraint of type {linkType} not implemented. {id} will be returned as an empty LinkConstraint");
                    break;
                }

                propList.Add(constr);
            }
            return(propList);
        }
Beispiel #14
0
        /***************************************************/
        /**** Private Methods                            ****/
        /***************************************************/

        private bool CreateObject(LinkConstraint bhLinkConstraint)
        {
            string name = bhLinkConstraint.DescriptionOrName();

            bool[]   dof;
            bool[]   fix;
            double[] stiff;
            double[] damp;
            double   dj2;
            double   dj3;

            bhLinkConstraint.ToSAP2000(out dof, out fix, out stiff, out damp, out dj2, out dj3);

            if (m_model.PropLink.SetLinear(name, ref dof, ref fix, ref stiff, ref damp, dj2, dj3) != 0)
            {
                Engine.Base.Compute.RecordWarning($"SAP returned an error pushing LinkConstraint {name}. Check results.");
            }

            SetAdapterId(bhLinkConstraint, name);

            return(true);
        }
Beispiel #15
0
        /***************************************************/

        private LinkConstraint GetLinearLinkConstraint(string name)
        {
            bool[]   dof          = null;
            bool[]   fix          = null;
            double[] stiff        = null;
            double[] damp         = null;
            double   dj2          = 0; //Not sure what this is doing
            double   dj3          = 0; //Not sure what this is doing
            bool     stiffCoupled = false;
            bool     dampCoupled  = false;
            string   notes        = null;
            string   guid         = null;

            m_model.PropLink.GetLinear(name, ref dof, ref fix, ref stiff, ref damp, ref dj2, ref dj3, ref stiffCoupled, ref dampCoupled, ref notes, ref guid);

            LinkConstraint constraint = new LinkConstraint();

            constraint.Name = name;
            SetAdapterId(constraint, name);

            constraint.XtoX   = fix[0];
            constraint.ZtoZ   = fix[1];
            constraint.YtoY   = fix[2];
            constraint.XXtoXX = fix[3];
            constraint.YYtoYY = fix[4];
            constraint.ZZtoZZ = fix[5];

            if (stiff != null && stiff.Any(x => x != 0))
            {
                Engine.Base.Compute.RecordWarning("No stiffness read for link constraints");
            }

            if (damp != null && damp.Any(x => x != 0))
            {
                Engine.Base.Compute.RecordWarning("No damping read for link contraint");
            }

            return(constraint);
        }
Beispiel #16
0
 public static RigidLink RigidLink(Node masterNode, IEnumerable <Node> slaveNodes, LinkConstraint constraint = null, string name = "")
 {
     return(new RigidLink
     {
         Name = name,
         PrimaryNode = masterNode,
         SecondaryNodes = slaveNodes.ToList(),
         Constraint = constraint == null?LinkConstraintFixed() : constraint
     });
 }
Beispiel #17
0
        /***************************************************/
        /**** Private Methods                           ****/
        /***************************************************/

        private List <RigidLink> ReadRigidLink(List <string> ids = null)
        {
            List <RigidLink>                    linkList            = new List <RigidLink>();
            Dictionary <string, Node>           bhomNodes           = ReadNodes().ToDictionary(x => GetAdapterId <string>(x));
            Dictionary <string, LinkConstraint> bhomLinkConstraints = ReadLinkConstraints().ToDictionary(x => GetAdapterId <string>(x));


            //Read all links, filter by id at end, so that we can join multi-links.
            int nameCount = 0;

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



            foreach (string id in nameArr)
            {
                RigidLink newLink   = new RigidLink();
                SAP2000Id sap2000id = new SAP2000Id();
                string    guid      = null;

                sap2000id.Id = id;

                try
                {
                    string primaryId   = "";
                    string secondaryId = "";
                    string propName    = "";
                    m_model.LinkObj.GetPoints(id, ref primaryId, ref secondaryId);
                    newLink.PrimaryNode    = bhomNodes[primaryId];
                    newLink.SecondaryNodes = new List <Node> {
                        bhomNodes[secondaryId]
                    };

                    if (m_model.LinkObj.GetProperty(id, ref propName) == 0)
                    {
                        LinkConstraint bhProp = new LinkConstraint();
                        bhomLinkConstraints.TryGetValue(propName, out bhProp);
                        newLink.Constraint = bhProp; m_model.LinkObj.GetProperty(id, ref propName);
                    }
                    else
                    {
                        Engine.Base.Compute.RecordWarning("Could not get link property for RigidLink " + id + ".");
                    }

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

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

                    newLink.SetAdapterId(sap2000id);
                    linkList.Add(newLink);
                }

                catch
                {
                    ReadElementError("RigidLink", id.ToString());
                }
            }

            Dictionary <string, RigidLink> joinedLinks = BH.Engine.Adapters.SAP2000.Query.JoinRigidLink(linkList).ToDictionary(x => x.Name);

            ids = FilterIds(ids, joinedLinks.Keys);

            if (ids != null)
            {
                return(joinedLinks
                       .Where(x => ids.Contains(x.Key))
                       .Select(x => x.Value).ToList());
            }
            else
            {
                return(joinedLinks.Values.ToList());
            }
        }
Beispiel #18
0
        /***************************************************/
        /**** Public Methods                            ****/
        /***************************************************/

        public static RigidLink RigidLink(Node masterNode, IEnumerable <Node> slaveNodes, LinkConstraint constraint = null)
        {
            return(new RigidLink
            {
                MasterNode = masterNode,
                SlaveNodes = slaveNodes.ToList(),
                Constraint = constraint == null?LinkConstraintFixed() : constraint
            });
        }
Beispiel #19
0
 public static RigidLink RigidLink(Node masterNode, IEnumerable <Node> slaveNodes, LinkConstraint constraint = null)
 {
     return(Engine.Structure.Create.RigidLink(masterNode, slaveNodes, constraint, ""));
 }