diff --git a/Etabs_Adapter/CRUD/Read/Mesh.cs b/Etabs_Adapter/CRUD/Read/Mesh.cs index 9689604..42bac28 100644 --- a/Etabs_Adapter/CRUD/Read/Mesh.cs +++ b/Etabs_Adapter/CRUD/Read/Mesh.cs @@ -63,21 +63,17 @@ private List ReadMesh(List ids = null) List meshes = new List(); Dictionary nodes = new Dictionary(); + Dictionary surfaceProps = ReadSurfaceProperty().ToDictionary(x => GetAdapterId(x)); foreach (string id in ids) { + FEMesh mesh = new FEMesh(); + ETABSId etabsid = new ETABSId(); etabsid.Id = id; List meshNodeIds = new List(); - string propertyName = ""; - - m_model.AreaObj.GetProperty(id, ref propertyName); - ISurfaceProperty panelProperty = ReadSurfaceProperty(new List() { propertyName })[0]; - - FEMesh mesh = new FEMesh() { Property = panelProperty }; - //Get out the "Element" ids, i.e. the mesh faces int nbELem = 0; string[] elemNames = new string[0]; @@ -121,35 +117,50 @@ private List ReadMesh(List ids = null) } - //Set mesh nodes - mesh.Nodes = meshNodeIds.Select(x => nodes[x]).ToList(); + //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 = ""; - //Get local x-axis - double orientation = 0; - bool advanced = false; - m_model.AreaObj.GetLocalAxes(id, ref orientation, ref advanced); + m_model.AreaObj.GetProperty(id, ref propertyName); - Vector normal = mesh.Faces.First().Normal(mesh); //Assuming flat mesh, all normals equal - Vector localX = Convert.FromCSILocalX(normal, orientation); - mesh = mesh.SetLocalOrientations(localX); + 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; - //Label and story - string label = ""; - string story = ""; - if (m_model.AreaObj.GetLabelFromName(id, ref label, ref story) == 0) + SetAdapterId(mesh, etabsid); + meshes.Add(mesh); + } + else { - etabsid.Label = label; - etabsid.Story = story; + BH.Engine.Reflection.Compute.RecordWarning("Mesh " + id.ToString() + " could not be pulled, because it contains no nodes"); } - - // Get guid - string guid = null; - m_model.AreaObj.GetGUID(id, ref guid); - etabsid.PersistentId = guid; - - SetAdapterId(mesh, etabsid); - meshes.Add(mesh); } return meshes;