Esempio n. 1
0
        /***************************************************/
        /**** Private Methods                            ****/
        /***************************************************/

        private bool CreateObject(IMaterialFragment material)
        {
            bool      success   = true;
            eMatType  matType   = material.GetMaterialType();
            string    bhName    = material.DescriptionOrName();
            int       color     = 0;
            string    guid      = null;
            string    notes     = "";
            string    name      = "";
            SAP2000Id sap2000id = new SAP2000Id();

            if (m_model.PropMaterial.AddMaterial(ref name, matType, "United States", bhName, bhName, guid) == 0) //try to get the material from a dataset
            {
                sap2000id.Id = name;
            }
            else if (m_model.PropMaterial.SetMaterial(bhName, matType, color, notes, guid) == 0) //create the material
            {
                sap2000id.Id = bhName;
                SetObject(material);
            }
            else
            {
                CreateElementError("Material", bhName);
            }
            SetAdapterId(material, sap2000id);

            return(success);
        }
Esempio n. 2
0
        /***************************************************/
        /**** Public Methods                            ****/
        /***************************************************/

        public static List <RigidLink> JoinRigidLink(List <RigidLink> linkList)
        {
            Dictionary <string, RigidLink> joinedList = new Dictionary <string, RigidLink>();

            foreach (RigidLink link in linkList)
            {
                SAP2000Id idFragment = link.FindFragment <SAP2000Id>();
                string    Name       = idFragment.Id.ToString();
                string[]  nameParts  = Name.Split(new[] { ":::" }, StringSplitOptions.None);
                if (nameParts.Count() == 1)
                {
                    joinedList.Add(Name, link);
                }
                else
                {
                    string JoinedName = nameParts[0];
                    if (joinedList.ContainsKey(JoinedName))
                    {
                        joinedList[JoinedName].SecondaryNodes.Add(link.SecondaryNodes[0]);
                    }
                    else
                    {
                        RigidLink newJoinedLink = link.ShallowClone();
                        newJoinedLink.Name = JoinedName;
                        joinedList.Add(JoinedName, newJoinedLink);
                    }
                }
            }

            return(joinedList.Values.ToList());
        }
Esempio n. 3
0
        /***************************************************/
        /**** Private Methods                            ****/
        /***************************************************/

        private bool CreateObject(Panel bhPanel)
        {
            double mergeTol = 1E-6;

            List <Point> boundaryPoints = null;

            //Check for dealbreaking BHoM invalidity
            try
            {
                boundaryPoints = bhPanel.ControlPoints(true).CullDuplicates(mergeTol);
            }
            catch
            {
                Engine.Base.Compute.RecordError($"Panel {bhPanel.Name} could not be created, because its geometry could not be determined");
                return(false);
            }

            int segmentCount = boundaryPoints.Count();

            double[] x = boundaryPoints.Select(item => item.X).ToArray();
            double[] y = boundaryPoints.Select(item => item.Y).ToArray();
            double[] z = boundaryPoints.Select(item => item.Z).ToArray();

            string name = "";

            // Create Geometry in SAP
            if (m_model.AreaObj.AddByCoord(segmentCount, ref x, ref y, ref z, ref name, "None", bhPanel.Name.ToString()) != 0)
            {
                CreateElementError("Panel", bhPanel.Name);
                return(false);
            }

            // Set AdapterID
            if (name != bhPanel.Name & bhPanel.Name != "")
            {
                Engine.Base.Compute.RecordNote($"Panel {bhPanel.Name} was assigned SAP2000_id of {name}");
            }

            string guid = null;

            m_model.AreaObj.GetGUID(name, ref guid);

            SAP2000Id sap2000IdFragment = new SAP2000Id {
                Id = name, PersistentId = guid
            };

            bhPanel.SetAdapterId(sap2000IdFragment);

            // Set Properties
            SetObject(bhPanel);

            return(true);
        }
Esempio n. 4
0
        /***************************************************/
        /**** Private Methods                            ****/
        /***************************************************/

        private bool CreateObject(Bar bhBar)
        {
            string name = "";

            // Check for dealbreaking BHoM validity
            if (bhBar.StartNode == null || bhBar.EndNode == null)
            {
                Engine.Base.Compute.RecordError($"Bar {bhBar.Name} failed to push because its nodes are null");
                return(false);
            }

            string startId = GetAdapterId <string>(bhBar.StartNode);
            string endId   = GetAdapterId <string>(bhBar.EndNode);

            if (startId == null || endId == null)
            {
                Engine.Base.Compute.RecordError($"Bar {bhBar.Name} failed to push because its nodes were not found in SAP2000. Check that geometry is valid.");
                return(false);
            }

            // Create Geometry in SAP
            if (m_model.FrameObj.AddByPoint(startId, endId, ref name, "None", bhBar.Name.ToString()) != 0)
            {
                CreateElementError("Bar", name);
                return(false);
            }

            // Set AdapterID
            if (name != bhBar.Name & bhBar.Name != "")
            {
                Engine.Base.Compute.RecordNote($"Bar {bhBar.Name} was assigned SAP2000_id of {name}");
            }

            string guid = null;

            m_model.FrameObj.GetGUID(name, ref guid);

            SAP2000Id sap2000IdFragment = new SAP2000Id {
                Id = name, PersistentId = guid
            };

            bhBar.SetAdapterId(sap2000IdFragment);

            // Set Properties
            SetObject(bhBar);

            return(true);
        }
Esempio n. 5
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);
        }
Esempio n. 6
0
        /***************************************************/
        /**** Private Methods                           ****/
        /***************************************************/

        private List <Node> ReadNodes(List <string> ids = null)
        {
            List <Node> nodeList = new List <Node>();

            int nameCount = 0;

            string[] nameArr = { };

            m_model.PointObj.GetNameList(ref nameCount, ref nameArr);

            ids = FilterIds(ids, nameArr);

            foreach (string id in ids)
            {
                Node      bhNode    = new Node();
                string    guid      = null;
                SAP2000Id sap2000id = new SAP2000Id();
                sap2000id.Id = id;

                bhNode.Position = ReadNodeCoordinates(id);

                bhNode.Orientation = ReadNodeLocalAxes(id);

                bhNode.Support = ReadNodeSupport(id);

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

                if (m_model.PointObj.GetGUID(id, ref guid) == 0)
                {
                    sap2000id.PersistentId = guid;
                }
                bhNode.SetAdapterId(sap2000id);
                nodeList.Add(bhNode);
            }

            return(nodeList);
        }
Esempio n. 7
0
        /***************************************************/
        /**** Private Methods                            ****/
        /***************************************************/

        private bool CreateObject(Node bhNode)
        {
            string name = "";

            //Check for dealbreaking validity problems
            if (bhNode.Position == null)
            {
                Engine.Base.Compute.RecordError($"Node {bhNode.Name} has no position. Nothing was created.");
                return(false);
            }

            // Create geometry in SAP
            if (m_model.PointObj.AddCartesian(bhNode.Position.X, bhNode.Position.Y, bhNode.Position.Z, ref name, bhNode.Name.ToString()) != 0)
            {
                CreateElementError("Node", bhNode.Name);
                return(false);
            }

            // Set Adapter ID
            if (name != bhNode.Name & bhNode.Name != "")
            {
                Engine.Base.Compute.RecordNote($"Node {bhNode.Name} was assigned SAP2000_id of {name}");
            }

            string guid = null;

            m_model.PointObj.GetGUID(name, ref guid);

            SAP2000Id sap2000IdFragment = new SAP2000Id {
                Id = name, PersistentId = guid
            };

            bhNode.SetAdapterId(sap2000IdFragment);

            // Set Properties
            SetObject(bhNode);

            return(true);
        }
Esempio n. 8
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());
            }
        }
Esempio n. 9
0
        /***************************************************/
        /**** Private Methods                           ****/
        /***************************************************/

        private List <ISectionProperty> ReadSectionProperties(List <string> ids = null)
        {
            List <ISectionProperty> propList = new List <ISectionProperty>();
            Dictionary <string, IMaterialFragment> bhomMaterials = ReadMaterial().ToDictionary(x => GetAdapterId <string>(x));

            int nameCount = 0;

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

            ids = FilterIds(ids, nameArr);
            List <string> backLog = new List <string>();

            foreach (string id in ids)
            {
                eFramePropType   propertyType = eFramePropType.General;
                ISectionProperty bhomProperty = null;
                IProfile         bhomProfile  = null;
                SAP2000Id        sap2000id    = new SAP2000Id();

                sap2000id.Id = id;

                m_model.PropFrame.GetTypeOAPI(id, ref propertyType);

                string constructor = "standard";

                string materialName = "";
                string fileName = "";
                double t3 = 0;
                double t2 = 0;
                double tf = 0;
                double tw = 0;
                double tfb = 0;
                double t2b = 0;
                double dis = 0;
                double radius = 0;
                double angle = 0;
                int    color = 0;
                string notes = "";
                string guid = "";
                double Area, As2, As3, Torsion, I22, I33, S22, S33, Z22, Z33, R22, R33;
                Area = As2 = As3 = Torsion = I22 = I33 = S22 = S33 = Z22 = Z33 = R22 = R33 = 0;

                switch (propertyType)
                {
                case eFramePropType.I:
                    m_model.PropFrame.GetISection(id, ref fileName, ref materialName, ref t3, ref t2, ref tf, ref tw, ref t2b, ref tfb, ref color, ref notes, ref guid);
                    if (t2 == t2b)
                    {
                        bhomProfile = BH.Engine.Spatial.Create.ISectionProfile(t3, t2, tw, tf, 0, 0);
                    }
                    else
                    {
                        bhomProfile = BH.Engine.Spatial.Create.FabricatedISectionProfile(t3, t2, t2b, tw, tf, tfb, 0);
                    }
                    break;

                case eFramePropType.Channel:
                    m_model.PropFrame.GetChannel(id, ref fileName, ref materialName, ref t3, ref t2, ref tf, ref tw, ref color, ref notes, ref guid);
                    bhomProfile = BH.Engine.Spatial.Create.ChannelProfile(t3, t2, tw, tf, 0, 0);
                    break;

                case eFramePropType.T:
                case eFramePropType.ConcreteTee:
                    m_model.PropFrame.GetTee(id, ref fileName, ref materialName, ref t3, ref t2, ref tf, ref tw, ref color, ref notes, ref guid);
                    bhomProfile = BH.Engine.Spatial.Create.TSectionProfile(t3, t2, tw, tf);
                    break;

                case eFramePropType.Angle:
                case eFramePropType.Concrete_L:
                    m_model.PropFrame.GetAngle(id, ref fileName, ref materialName, ref t3, ref t2, ref tf, ref tw, ref color, ref notes, ref guid);
                    bhomProfile = BH.Engine.Spatial.Create.AngleProfile(t3, t2, tw, tf, 0, 0);
                    break;

                case eFramePropType.DblAngle:
                    break;

                case eFramePropType.Box:
                case eFramePropType.ConcreteBox:
                    m_model.PropFrame.GetTube(id, ref fileName, ref materialName, ref t3, ref t2, ref tf, ref tw, ref color, ref notes, ref guid);
                    if (tf == tw)
                    {
                        bhomProfile = BH.Engine.Spatial.Create.BoxProfile(t3, t2, tf, 0, 0);
                    }
                    else
                    {
                        bhomProfile = BH.Engine.Spatial.Create.FabricatedBoxProfile(t3, t2, tw, tf, tf, 0);
                    }
                    break;

                case eFramePropType.Pipe:
                case eFramePropType.ConcretePipe:
                    m_model.PropFrame.GetPipe(id, ref fileName, ref materialName, ref t3, ref tw, ref color, ref notes, ref guid);
                    bhomProfile = BH.Engine.Spatial.Create.TubeProfile(t3, tw);
                    break;

                case eFramePropType.Rectangular:
                case eFramePropType.SteelPlate:
                    m_model.PropFrame.GetRectangle(id, ref fileName, ref materialName, ref t3, ref t2, ref color, ref notes, ref guid);
                    bhomProfile = BH.Engine.Spatial.Create.RectangleProfile(t3, t2, 0);
                    break;

                case eFramePropType.Auto:    //not member will have this assigned but it still exists in the propertyType list
                    bhomProfile = BH.Engine.Spatial.Create.CircleProfile(0.2);
                    break;

                case eFramePropType.Circle:
                case eFramePropType.SteelRod:
                    m_model.PropFrame.GetCircle(id, ref fileName, ref materialName, ref t3, ref color, ref notes, ref guid);
                    bhomProfile = BH.Engine.Spatial.Create.CircleProfile(t3);
                    break;

                case eFramePropType.General:
                    m_model.PropFrame.GetGeneral(id, ref fileName, ref materialName, ref t3, ref t2, ref Area, ref As2, ref As3, ref Torsion, ref I22, ref I33, ref S22, ref S33, ref Z22, ref Z33, ref R22, ref R33, ref color, ref notes, ref guid);
                    constructor = "explicit";
                    break;

                case eFramePropType.Cold_Z:
                    m_model.PropFrame.GetColdZ(id, ref fileName, ref materialName, ref t3, ref t2, ref tw, ref radius, ref tfb, ref angle, ref color, ref notes, ref guid);
                    bhomProfile = BH.Engine.Spatial.Create.ZSectionProfile(t3, t2, tw, tw, radius, 0);
                    break;

                case eFramePropType.Variable:
                    if (!backLog.Contains(id))
                    {
                        //Can't read tapered sections until all other sections have been read.
                        backLog.Add(id);
                        continue;
                    }
                    break;

                case eFramePropType.DbChannel:
                case eFramePropType.SD:
                case eFramePropType.Joist:
                case eFramePropType.Bridge:
                case eFramePropType.Cold_C:
                case eFramePropType.Cold_2C:
                case eFramePropType.Cold_L:
                case eFramePropType.Cold_2L:
                case eFramePropType.Cold_Hat:
                case eFramePropType.BuiltupICoverplate:
                case eFramePropType.PCCGirderI:
                case eFramePropType.PCCGirderU:
                case eFramePropType.BuiltupIHybrid:
                case eFramePropType.BuiltupUHybrid:
                case eFramePropType.FilledTube:
                case eFramePropType.FilledPipe:
                case eFramePropType.EncasedRectangle:
                case eFramePropType.EncasedCircle:
                case eFramePropType.BucklingRestrainedBrace:
                case eFramePropType.CoreBrace_BRB:
                case eFramePropType.ConcreteCross:
                default:
                    break;
                }

                // Section Material

                IMaterialFragment material = null;
                if (!bhomMaterials.TryGetValue(materialName, out material))
                {
                    Engine.Base.Compute.RecordWarning($"Could not get material for SectionProperty {id}. A generic has been returned.");
                }

                if (bhomProfile == null)
                {
                    Engine.Base.Compute.RecordWarning("Reading sections of type " + propertyType.ToString() + " is not supported. An empty section with a default material has been returned.");
                    constructor = "explicit";
                }

                switch (constructor)
                {
                case "explicit":
                    bhomProperty = new ExplicitSection()
                    {
                        Area     = Area,
                        Asy      = As2,
                        Asz      = As3,
                        Iy       = I22,
                        Iz       = I33,
                        J        = Torsion,
                        Rgy      = R22,
                        Rgz      = R33,
                        Wply     = S22,
                        Wplz     = S33,
                        Wely     = Z22,
                        Welz     = Z33,
                        Material = material,
                        Name     = id
                    };
                    break;

                case "standard":
                    bhomProperty = BH.Engine.Structure.Create.SectionPropertyFromProfile(bhomProfile, material, id);
                    break;
                }

                // Apply Property Modifiers
                bhomProperty.Fragments.Add(ReadFrameSectionModifiers(id));

                // Apply the AdapterId
                bhomProperty.SetAdapterId(sap2000id);

                // Add to the list
                propList.Add(bhomProperty);
            }

            //Read any leftover sections (currently only tapered profiles)
            if (backLog.Count > 0)
            {
                foreach (string id in backLog)
                {
                    ISectionProperty bhomProperty = null;
                    SAP2000Id        sap2000id    = new SAP2000Id
                    {
                        Id = id
                    };

                    bhomProperty = ReadTaperedSection(id, propList);

                    bhomProperty.SetAdapterId(sap2000id);

                    bhomProperty.Fragments.Add(ReadFrameSectionModifiers(id));

                    propList.Add(bhomProperty);
                }
            }
            return(propList);
        }
Esempio n. 10
0
        /***************************************************/
        /**** Private Methods                            ****/
        /***************************************************/

        private bool CreateObject(RigidLink bhLink)
        {
            List <RigidLink> subLinks  = BH.Engine.Adapters.SAP2000.Query.SplitRigidLink(bhLink);
            List <string>    linkIds   = new List <string>();
            SAP2000Id        sap2000id = new SAP2000Id();

            if (subLinks.Count > 1)
            {
                Engine.Base.Compute.RecordNote($"The RigidLink {bhLink.Name} was split into {subLinks.Count} separate links. They will be added to a new group called \"BHoM_Link_{bhLink.Name}\"");
            }

            foreach (RigidLink subLink in subLinks)
            {
                string name = "";

                string primaryNode   = GetAdapterId <string>(subLink.PrimaryNode);
                string secondaryNode = GetAdapterId <string>(subLink.SecondaryNodes[0]);


                if (m_model.LinkObj.AddByPoint(primaryNode, secondaryNode, ref name, false, "Default", subLink.Name) == 0)
                {
                    //Check if SAP respected the link name.
                    if (subLink.Name != "" && subLink.Name != name)
                    {
                        Engine.Base.Compute.RecordNote($"RigidLink {bhLink.Name} was assigned SAP2000_id of {name}");
                    }

                    //Attempt to set property (if property has been pushed)
                    if (subLink.Constraint != null)
                    {
                        if (m_model.LinkObj.SetProperty(name, GetAdapterId <string>(subLink.Constraint)) != 0)
                        {
                            CreatePropertyWarning("LinkConstraint", "RigidLink", bhLink.Name);
                        }
                    }
                    else
                    {
                        CreatePropertyWarning("LinkConstraint", "RigidLink", bhLink.Name);
                    }


                    //Add to groups per tags. For links that have been split, the original name will be tagged
                    foreach (string gName in subLink.Tags)
                    {
                        string groupName = gName.ToString();
                        if (m_model.LinkObj.SetGroupAssign(name, groupName) != 0)
                        {
                            m_model.GroupDef.SetGroup(groupName);
                            m_model.LinkObj.SetGroupAssign(name, groupName);
                        }
                    }

                    linkIds.Add(name);
                }
                else
                {
                    //The sublink had a problem in SAP. the sublink property has not been set and the sublink was not added to a group. The sublink may or may not have been created.
                    CreateElementError("RigidLink", subLink.Name);
                }
            }

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

            return(true);
        }
Esempio n. 11
0
        /***************************************************/
        /**** Private Methods                           ****/
        /***************************************************/

        private List <ISurfaceProperty> ReadSurfaceProperty(List <string> ids = null)
        {
            List <ISurfaceProperty> propertyList = new List <ISurfaceProperty>();

            Dictionary <string, IMaterialFragment> bhomMaterials = ReadMaterial().ToDictionary(x => GetAdapterId <string>(x));

            int nameCount = 0;

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

            ids = FilterIds(ids, nameArr);

            foreach (string id in ids)
            {
                int       shellType          = 0;
                bool      includeDrillingDOF = true;
                string    materialName       = "";
                double    matAng             = 0;
                double    thickness          = 0;
                double    bending            = 0;
                int       color     = 0;
                string    notes     = "";
                string    guid      = null;
                SAP2000Id sap2000id = new SAP2000Id();
                sap2000id.Id = id;


                if (m_model.PropArea.GetShell_1(id, ref shellType, ref includeDrillingDOF, ref materialName, ref matAng, ref thickness, ref bending, ref color, ref notes, ref guid) != 0)
                {
                    Engine.Base.Compute.RecordWarning($"Error while pulling Surface Property {id}. Check results carefully.");
                }

                ConstantThickness bhSurfProp = new ConstantThickness();

                bhSurfProp.Name      = id;
                bhSurfProp.Thickness = thickness;
                bhSurfProp.CustomData.Add("MaterialAngle", matAng);
                bhSurfProp.CustomData.Add("BendingThickness", bending);
                bhSurfProp.CustomData.Add("Color", color);
                bhSurfProp.CustomData.Add("Notes", notes);
                bhSurfProp.CustomData.Add("GUID", guid);

                IMaterialFragment bhMat = new GenericIsotropicMaterial();
                bhomMaterials.TryGetValue(materialName, out bhMat);
                bhSurfProp.Material = bhMat;

                double[] modifiers = new double[6];

                if (m_model.PropArea.GetModifiers(id, ref modifiers) == 0)
                {
                    SurfacePropertyModifier modifier = new SurfacePropertyModifier
                    {
                        FXX    = modifiers[0],
                        FYY    = modifiers[1],
                        FXY    = modifiers[2],
                        MXX    = modifiers[3],
                        MYY    = modifiers[4],
                        MXY    = modifiers[5],
                        VXZ    = modifiers[6],
                        VYZ    = modifiers[7],
                        Mass   = modifiers[8],
                        Weight = modifiers[9]
                    };
                    bhSurfProp.Fragments.Add(modifier);
                }

                bhSurfProp.SetAdapterId(sap2000id);
                propertyList.Add(bhSurfProp);
            }

            return(propertyList);
        }
Esempio n. 12
0
        /***************************************************/
        /**** Private Methods                            ****/
        /***************************************************/
        private bool CreateObject(ISurfaceProperty surfaceProperty)
        {
            string propName = surfaceProperty.DescriptionOrName();
            string matName  = "Default";

            if (surfaceProperty.Material != null)
            {
                matName = GetAdapterId <string>(surfaceProperty.Material);
            }
            else
            {
                Engine.Base.Compute.RecordWarning($"SurfaceProperty {propName} had no material defined. Using a default material.");
            }

            SAP2000Id sap2000id = new SAP2000Id();

            if (surfaceProperty.GetType() == typeof(Waffle))
            {
                // not implemented!
                CreatePropertyError("Waffle Not Implemented!", "Panel", propName);
            }
            else if (surfaceProperty.GetType() == typeof(Ribbed))
            {
                // not implemented!
                CreatePropertyError("Ribbed Not Implemented!", "Panel", propName);
            }
            else if (surfaceProperty.GetType() == typeof(LoadingPanelProperty))
            {
                // not implemented!
                CreatePropertyError("Loading Panel Not Implemented!", "Panel", propName);
            }
            else if (surfaceProperty.GetType() == typeof(ConstantThickness))
            {
                ConstantThickness constantThickness = (ConstantThickness)surfaceProperty;
                int  shellType          = 1;
                bool includeDrillingDOF = true;
                if (m_model.PropArea.SetShell_1(propName, shellType, includeDrillingDOF, matName, 0, constantThickness.Thickness, constantThickness.Thickness) != 0)
                {
                    CreatePropertyError("ConstantThickness", "SurfaceProperty", propName);
                }
            }

            sap2000id.Id = propName;
            surfaceProperty.SetAdapterId(sap2000id);

            SurfacePropertyModifier modifier = surfaceProperty.FindFragment <SurfacePropertyModifier>();

            if (modifier != null)
            {
                double[] modifiers = new double[]
                {
                    modifier.FXX,
                    modifier.FYY,
                    modifier.FXY,
                    modifier.MXX,
                    modifier.MYY,
                    modifier.MXY,
                    modifier.VXZ,
                    modifier.VYZ,
                    modifier.Mass,
                    modifier.Weight
                };

                if (m_model.PropArea.SetModifiers(propName, ref modifiers) != 0)
                {
                    CreatePropertyError("Modifiers", "SurfaceProperty", propName);
                }
            }

            return(true);
        }
Esempio n. 13
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);
        }
Esempio n. 14
0
        /***************************************************/
        /**** Private Methods                           ****/
        /***************************************************/

        private List <Panel> ReadPanel(List <string> ids = null)
        {
            List <Panel> bhomPanels = new List <Panel>();

            Dictionary <string, Node>             bhomNodes      = ReadNodes().ToDictionary(x => GetAdapterId <string>(x));
            Dictionary <string, ISurfaceProperty> bhomProperties = ReadSurfaceProperty().ToDictionary(x => GetAdapterId <string>(x));

            int nameCount = 0;

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

            ids = FilterIds(ids, nameArr);

            foreach (string id in ids)
            {
                Panel     bhomPanel = new Panel();
                SAP2000Id sap2000id = new SAP2000Id();
                string    guid      = null;

                //Set the Adapter ID
                sap2000id.Id = id;

                //Get outline of panel
                string[] pointNames = null;
                int      pointCount = 0;

                if (m_model.AreaObj.GetPoints(id, ref pointCount, ref pointNames) == 0)
                {
                    List <Point> pts = new List <Point>();
                    foreach (string name in pointNames)
                    {
                        pts.Add(bhomNodes[name].Position);
                    }
                    pts.Add(pts[0]);
                    Polyline outline = new Polyline()
                    {
                        ControlPoints = pts
                    };
                    List <Edge> outEdges = new List <Edge>()
                    {
                        new Edge {
                            Curve = outline, Release = new oM.Structure.Constraints.Constraint4DOF()
                        }
                    };

                    bhomPanel.ExternalEdges = outEdges;
                }

                //There are no openings in SAP2000
                bhomPanel.Openings = new List <Opening>();

                //Get the section property
                string propertyName = "";
                if (m_model.AreaObj.GetProperty(id, ref propertyName) == 0)
                {
                    ISurfaceProperty bhProp = new ConstantThickness();
                    bhomProperties.TryGetValue(propertyName, out bhProp);
                    bhomPanel.Property = bhProp;
                }

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

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

                bhomPanel.SetAdapterId(sap2000id);
                //Add the panel to the list
                bhomPanels.Add(bhomPanel);
            }

            return(bhomPanels);
        }