コード例 #1
0
        /***************************************************/

        private List <Level> ReadLevel(List <string> ids = null)
        {
            List <Level> levellist   = new List <Level>();
            int          numberNames = 0;

            string[] names = null;
            m_model.Story.GetNameList(ref numberNames, ref names);

            ids = FilterIds(ids, names);

            foreach (string id in ids)
            {
                ETABSId etabsid = new ETABSId();
                etabsid.Id = id;

                double elevation = 0;
                int    ret       = m_model.Story.GetElevation(id, ref elevation);

                string guid = null;
                m_model.Story.GetGUID(id, ref guid);
                etabsid.PersistentId = guid;

                Level lvl = new Level()
                {
                    Elevation = elevation, Name = id
                };

                lvl.SetAdapterId(etabsid);
                levellist.Add(lvl);
            }

            return(levellist);
        }
コード例 #2
0
ファイル: Link.cs プロジェクト: BHoM/ETABS_Toolkit
        /***************************************************/

        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);
        }
コード例 #3
0
        /***************************************************/

        private List <Node> ReadNode(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)
            {
                ETABSId etabsIdFragment = new ETABSId();
                etabsIdFragment.Id = id;

                double x, y, z;
                x = y = z = 0;
                bool[]   restraint = new bool[6];
                double[] spring    = new double[6];

                m_model.PointObj.GetCoordCartesian(id, ref x, ref y, ref z);

                m_model.PointObj.GetRestraint(id, ref restraint);
                m_model.PointObj.GetSpring(id, ref spring);

                Constraint6DOF support = GetConstraint6DOF(restraint, spring);

                Node bhNode = new Node {
                    Position = new oM.Geometry.Point()
                    {
                        X = x, Y = y, Z = z
                    }, Support = support
                };

                //Label and story
                string label = "";
                string story = "";
                string guid  = null;
                if (m_model.PointObj.GetLabelFromName(id, ref label, ref story) == 0)
                {
                    etabsIdFragment.Label = label;
                    etabsIdFragment.Story = story;
                }

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

                bhNode.SetAdapterId(etabsIdFragment);
                nodeList.Add(bhNode);
            }


            return(nodeList);
        }
コード例 #4
0
ファイル: Node.cs プロジェクト: BHoM/ETABS_Toolkit
        /***************************************************/
        private bool CreateObject(Node bhNode)
        {
            string  name    = "";
            ETABSId etabsid = new ETABSId();

            if (!CheckPropertyError(bhNode, x => x.Position, true))
            {
                return(false);
            }

            oM.Geometry.Point position = bhNode.Position;
            if (m_model.PointObj.AddCartesian(position.X, position.Y, position.Z, ref name) == 0)
            {
                etabsid.Id = name;

                //Label and story
                string label = "";
                string story = "";
                if (m_model.PointObj.GetLabelFromName(name, ref label, ref story) == 0)
                {
                    etabsid.Label = label;
                    etabsid.Story = story;
                }

                string guid = null;
                if (m_model.PointObj.GetGUID(name, ref guid) == 0)
                {
                    etabsid.PersistentId = guid;
                }

                bhNode.SetAdapterId(etabsid);
                SetObject(bhNode, name);
            }

            return(true);
        }
コード例 #5
0
ファイル: Mesh.cs プロジェクト: BHoM/ETABS_Toolkit
        /***************************************************/

        private List <FEMesh> ReadMesh(List <string> ids = null)
        {
            List <Panel> panelList = new List <Panel>();
            int          nameCount = 0;

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

            ids = FilterIds(ids, nameArr);

            List <FEMesh>                         meshes       = new List <FEMesh>();
            Dictionary <string, Node>             nodes        = new Dictionary <string, Node>();
            Dictionary <string, ISurfaceProperty> surfaceProps = ReadSurfaceProperty().ToDictionary(x => GetAdapterId <string>(x));

            foreach (string id in ids)
            {
                FEMesh mesh = new FEMesh();

                ETABSId etabsid = new ETABSId();
                etabsid.Id = id;

                List <string> meshNodeIds = new List <string>();

                //Get out the "Element" ids, i.e. the mesh faces
                int      nbELem    = 0;
                string[] elemNames = new string[0];
                m_model.AreaObj.GetElm(id, ref nbELem, ref elemNames);

                for (int j = 0; j < nbELem; j++)
                {
                    //Get out the name of the points for each face
                    int      nbPts    = 0;
                    string[] ptsNames = new string[0];
                    m_model.AreaElm.GetPoints(elemNames[j], ref nbPts, ref ptsNames);

                    FEMeshFace face = new FEMeshFace();

                    for (int k = 0; k < nbPts; k++)
                    {
                        string nodeId = ptsNames[k];
                        Node   node;

                        //Check if node already has been pulled
                        if (!nodes.TryGetValue(nodeId, out node))
                        {
                            double x = 0, y = 0, z = 0;
                            m_model.PointElm.GetCoordCartesian(nodeId, ref x, ref y, ref z);
                            node = new Node()
                            {
                                Position = new Point {
                                    X = x, Y = y, Z = z
                                }
                            };
                            SetAdapterId(node, nodeId);
                            nodes[ptsNames[k]] = node;
                        }

                        //Check if nodealready has been added to the mesh
                        if (!meshNodeIds.Contains(nodeId))
                        {
                            meshNodeIds.Add(nodeId);
                        }

                        //Get corresponding node index
                        face.NodeListIndices.Add(meshNodeIds.IndexOf(nodeId));
                    }

                    //Add face to list
                    SetAdapterId(face, elemNames[j]);
                    mesh.Faces.Add(face);
                }

                //Set mesh nodes - if there are no nodes, don't create the mesh.
                if (nodes.Count != 0 && mesh.Faces.Count != 0)
                {
                    mesh.Nodes = meshNodeIds.Select(x => nodes[x]).ToList();

                    string propertyName = "";

                    m_model.AreaObj.GetProperty(id, ref propertyName);

                    if (propertyName != "None")
                    {
                        mesh.Property = surfaceProps[propertyName];
                    }

                    //Get local x-axis
                    double orientation = 0;
                    bool   advanced    = false;
                    m_model.AreaObj.GetLocalAxes(id, ref orientation, ref advanced);

                    Vector normal = mesh.Faces.First().Normal(mesh);    //Assuming flat mesh, all normals equal
                    Vector localX = Convert.FromCSILocalX(normal, orientation);
                    mesh = mesh.SetLocalOrientations(localX);

                    //Label and story
                    string label = "";
                    string story = "";
                    if (m_model.AreaObj.GetLabelFromName(id, ref label, ref story) == 0)
                    {
                        etabsid.Label = label;
                        etabsid.Story = story;
                    }

                    // Get guid
                    string guid = null;
                    m_model.AreaObj.GetGUID(id, ref guid);
                    etabsid.PersistentId = guid;

                    SetAdapterId(mesh, etabsid);
                    meshes.Add(mesh);
                }
                else
                {
                    BH.Engine.Base.Compute.RecordWarning("Mesh " + id.ToString() + " could not be pulled, because it contains no nodes");
                }
            }

            return(meshes);
        }
コード例 #6
0
        /***************************************************/

        private bool CreateObject(Bar bhBar)
        {
            int ret = 0;

            if (!CheckPropertyError(bhBar, b => b.StartNode, true) || !CheckPropertyError(bhBar, b => b.EndNode, true) ||
                !CheckPropertyError(bhBar, b => b.StartNode.Position, true) || !CheckPropertyError(bhBar, b => b.EndNode.Position, true))
            {
                return(false);
            }

            string name = "";

#if Debug16 || Release16
            // Evaluate if the bar is alinged as Etabs wants it
            if (bhBar.CheckFlipBar())
            {
                FlipEndPoints(bhBar);      //CloneBeforePush means this is fine
                FlipInsertionPoint(bhBar); //ETABS specific operation
                Engine.Base.Compute.RecordNote("Some bars has been flipped to comply with ETABS API, asymmetric sections will suffer");
            }
#endif

            string stNodeId  = GetAdapterId <string>(bhBar.StartNode);
            string endNodeId = GetAdapterId <string>(bhBar.EndNode);

            if (string.IsNullOrEmpty(stNodeId) || string.IsNullOrEmpty(endNodeId))
            {
                Engine.Base.Compute.RecordError("Could not find the ids for at least one end node for at least one Bar. Bar not created.");
                return(false);
            }

            ret = m_model.FrameObj.AddByPoint(stNodeId, endNodeId, ref name);


            if (ret != 0)
            {
                CreateElementError("Bar", name);
                return(false);
            }

            //Label and story
            string label = "";
            string story = "";
            string guid  = null;

            ETABSId etabsIdFragment = new ETABSId {
                Id = name
            };

            if (m_model.FrameObj.GetLabelFromName(name, ref label, ref story) == 0)
            {
                etabsIdFragment.Label = label;
                etabsIdFragment.Story = story;
            }

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

            bhBar.SetAdapterId(etabsIdFragment);

            return(SetObject(bhBar));
        }
コード例 #7
0
ファイル: Panel.cs プロジェクト: BHoM/ETABS_Toolkit
        /***************************************************/
        /***    Create Methods                           ***/
        /***************************************************/

        private bool CreateObject(Panel bhPanel)
        {
            bool success = true;
            int  retA    = 0;

            double mergeTol = 1e-3; //Merging panel points to the mm, same behaviour as the default node comparer

            if (!CheckPropertyError(bhPanel, bhP => bhP.ExternalEdges, true))
            {
                return(false);
            }

            for (int i = 0; i < bhPanel.ExternalEdges.Count; i++)
            {
                if (!CheckPropertyError(bhPanel, bhP => bhP.ExternalEdges[i], true))
                {
                    return(false);
                }

                if (!CheckPropertyError(bhPanel, bhP => bhP.ExternalEdges[i].Curve, true))
                {
                    return(false);
                }
            }

            NonLinearEdgesCheck(bhPanel.ExternalEdges);

            string name         = "";
            string propertyName = "";

            if (CheckPropertyWarning(bhPanel, bhP => bhP.Property))
            {
                propertyName = GetAdapterId <string>(bhPanel.Property);
            }

            List <BH.oM.Geometry.Point> boundaryPoints = bhPanel.ControlPoints(true).CullDuplicates(mergeTol);

            int segmentCount = boundaryPoints.Count();

            double[] x = new double[segmentCount];
            double[] y = new double[segmentCount];
            double[] z = new double[segmentCount];
            for (int i = 0; i < segmentCount; i++)
            {
                x[i] = boundaryPoints[i].X;
                y[i] = boundaryPoints[i].Y;
                z[i] = boundaryPoints[i].Z;
            }

            retA = m_model.AreaObj.AddByCoord(segmentCount, ref x, ref y, ref z, ref name, propertyName);
            ETABSId etabsid = new ETABSId();

            etabsid.Id = name;

            //Label and story
            string label = "";
            string story = "";
            string guid  = null;

            if (m_model.AreaObj.GetLabelFromName(name, ref label, ref story) == 0)
            {
                etabsid.Label = label;
                etabsid.Story = story;
            }

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

            bhPanel.SetAdapterId(etabsid);

            if (retA != 0)
            {
                return(false);
            }

            if (bhPanel.Openings != null)
            {
                for (int i = 0; i < bhPanel.Openings.Count; i++)
                {
                    if (!CheckPropertyError(bhPanel, bhP => bhP.Openings[i]))
                    {
                        continue;
                    }

                    Opening opening = bhPanel.Openings[i];

                    for (int j = 0; j < opening.Edges.Count; j++)
                    {
                        if (!CheckPropertyError(opening, o => o.Edges[j], true))
                        {
                            return(false);
                        }

                        if (!CheckPropertyError(opening, o => o.Edges[j], true))
                        {
                            return(false);
                        }
                    }

                    NonLinearEdgesCheck(opening.Edges);

                    boundaryPoints = opening.ControlPoints().CullDuplicates(mergeTol);

                    segmentCount = boundaryPoints.Count();
                    x            = new double[segmentCount];
                    y            = new double[segmentCount];
                    z            = new double[segmentCount];

                    for (int j = 0; j < segmentCount; j++)
                    {
                        x[j] = boundaryPoints[j].X;
                        y[j] = boundaryPoints[j].Y;
                        z[j] = boundaryPoints[j].Z;
                    }

                    string openingName = name + "_Opening_" + i;
                    m_model.AreaObj.AddByCoord(segmentCount, ref x, ref y, ref z, ref openingName, "");//<-- setting panel property to empty string, verify that this is correct
                    m_model.AreaObj.SetOpening(openingName, true);

                    SetAdapterId(bhPanel.Openings[i], openingName);
                }
            }

            //Set local orientations:
            Basis orientation = bhPanel.LocalOrientation();

            m_model.AreaObj.SetLocalAxes(name, Convert.ToEtabsPanelOrientation(orientation.Z, orientation.Y));

            Pier      pier      = bhPanel.Pier();
            Spandrel  spandrel  = bhPanel.Spandrel();
            Diaphragm diaphragm = bhPanel.Diaphragm();

            if (pier != null)
            {
                int ret = m_model.PierLabel.SetPier(pier.Name);
                ret = m_model.AreaObj.SetPier(name, pier.Name);
            }
            if (spandrel != null)
            {
                int ret = m_model.SpandrelLabel.SetSpandrel(spandrel.Name, false);
                ret = m_model.AreaObj.SetSpandrel(name, spandrel.Name);
            }
            if (diaphragm != null)
            {
                m_model.AreaObj.SetDiaphragm(name, diaphragm.Name);
            }
            return(success);
        }
コード例 #8
0
        /***************************************************/
        /***    Read Methods                             ***/
        /***************************************************/

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

            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);

            //get openings, if any
            m_model.AreaObj.GetNameList(ref nameCount, ref nameArr);
            bool isOpening = false;
            Dictionary <string, Polyline> openingDict = new Dictionary <string, Polyline>();

            foreach (string name in nameArr)
            {
                m_model.AreaObj.GetOpening(name, ref isOpening);
                if (isOpening)
                {
                    openingDict.Add(name, GetPanelPerimeter(name));
                }
            }

            foreach (string id in ids)
            {
                ETABSId etabsId = new ETABSId();
                etabsId.Id = id;

                if (openingDict.ContainsKey(id))
                {
                    continue;
                }

                string propertyName = "";

                m_model.AreaObj.GetProperty(id, ref propertyName);

                ISurfaceProperty panelProperty = null;
                if (propertyName != "None")
                {
                    panelProperty = bhomProperties[propertyName];
                }

                Panel    panel = new Panel();
                Polyline pl    = GetPanelPerimeter(id);

                panel.ExternalEdges = pl.SubParts().Select(x => new Edge {
                    Curve = x
                }).ToList();

                foreach (KeyValuePair <string, Polyline> kvp in openingDict)
                {
                    if (pl.IsContaining(kvp.Value.ControlPoints))
                    {
                        Opening opening = new Opening();
                        opening.Edges = kvp.Value.SubParts().Select(x => new Edge {
                            Curve = x
                        }).ToList();
                        panel.Openings.Add(opening);
                    }
                }

                panel.Property = panelProperty;
                string PierName     = "";
                string SpandrelName = "";
                m_model.AreaObj.GetPier(id, ref PierName);
                m_model.AreaObj.GetSpandrel(id, ref SpandrelName);
                panel = panel.SetSpandrel(new Spandrel {
                    Name = SpandrelName
                });
                panel = panel.SetPier(new Pier {
                    Name = PierName
                });

                double orientation = 0;
                bool   advanced    = false;
                m_model.AreaObj.GetLocalAxes(id, ref orientation, ref advanced);

                panel = panel.SetLocalOrientation(Convert.FromCSILocalX(panel.Normal(), orientation));

                //Label and story
                string label = "";
                string story = "";
                string guid  = null;
                if (m_model.AreaObj.GetLabelFromName(id, ref label, ref story) == 0)
                {
                    etabsId.Label = label;
                    etabsId.Story = story;
                }

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

                panel.SetAdapterId(etabsId);
                panelList.Add(panel);
            }

            return(panelList);
        }
コード例 #9
0
ファイル: Bar.cs プロジェクト: BHoM/ETABS_Toolkit
        /***************************************************/

        private List <Bar> ReadBar(List <string> ids = null)
        {
            List <Bar> barList = new List <Bar>();
            Dictionary <string, Node>             bhomNodes    = ReadNode().ToDictionary(x => GetAdapterId <string>(x));
            Dictionary <string, ISectionProperty> bhomSections = ReadSectionProperty().ToDictionary(x => GetAdapterId <string>(x));

            int nameCount = 0;

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

            ids = FilterIds(ids, names);

            foreach (string id in ids)
            {
                ETABSId etabsIdFragment = new ETABSId();
                etabsIdFragment.Id = id;

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

                    bhBar.StartNode = bhomNodes[startId];
                    bhBar.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);
                    bhBar.Release = GetBarRelease(restraintStart, springStart, restraintEnd, springEnd);

                    string propertyName = "";
                    string sAuto        = "";
                    m_model.FrameObj.GetSection(id, ref propertyName, ref sAuto);
                    if (propertyName != "None")
                    {
                        bhBar.SectionProperty = bhomSections[propertyName];
                    }

                    bool   autoOffset  = false;
                    double startLength = 0;
                    double endLength   = 0;
                    double rz          = 0;
                    m_model.FrameObj.GetEndLengthOffset(id, ref autoOffset, ref startLength, ref endLength, ref rz);
                    if (!autoOffset)
                    {
                        bhBar.Offset       = new oM.Structure.Offsets.Offset();
                        bhBar.Offset.Start = startLength == 0 ? null : new Vector()
                        {
                            X = startLength * (-1), Y = 0, Z = 0
                        };
                        bhBar.Offset.End = endLength == 0 ? null : new Vector()
                        {
                            X = endLength, Y = 0, Z = 0
                        };
                    }
                    else if (rz > 0)
                    {
                        bhBar = bhBar.SetAutoLengthOffset(autoOffset, rz);
                    }

                    // OrientationAngle
                    double angle    = 0;
                    bool   advanced = false;
                    m_model.FrameObj.GetLocalAxes(id, ref angle, ref advanced);
                    if (!advanced)
                    {
                        bhBar.OrientationAngle = angle * Math.PI / 180;
                    }
                    else
                    {
                        BH.Engine.Base.Compute.RecordWarning("advanced local axis for bars are not supported");
                    }

                    //Label and story
                    string label = "";
                    string story = "";
                    string guid  = null;

                    if (m_model.FrameObj.GetLabelFromName(id, ref label, ref story) == 0)
                    {
                        etabsIdFragment.Label = label;
                        etabsIdFragment.Story = story;
                    }

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

                    bhBar.SetAdapterId(etabsIdFragment);
                    barList.Add(bhBar);
                }
                catch
                {
                    BH.Engine.Base.Compute.RecordError("Bar " + id.ToString() + " could not be pulled");
                }
            }
            return(barList);
        }