-
Notifications
You must be signed in to change notification settings - Fork 2
Allow Pull of FE Mesh Objects #353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
peterjamesnugent
merged 14 commits into
develop
from
SAP2000_Toolkit-#352-AllowPullOfMeshObjects
Aug 4, 2026
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
d93025b
Add Utility Methods for Panels conversion from SAP to BHoM
GCRA101 51fcb30
Create Read Method for Mesh Objects
GCRA101 0e6aab4
Update Adapter csproj with Read Mesh.cs
GCRA101 dfc98da
Add ReadMesh Method in _IRead.cs
GCRA101 eb31b60
Remove unused panelList from ReadMesh method
GCRA101 4268380
Replace variable name "etabsid" with "sap2000id"
GCRA101 4e54455
Replace IsSAPVertical() method with Query.IsParallel()
GCRA101 c0cb2c9
Add Warning on single normal vector for all faces of a mesh
GCRA101 6d766d8
Rename PanelLocalAxisToBHoM method to ToPanelLocalXAxis
GCRA101 5afb102
Add missing copyright header to Read/Mesh.cs file
GCRA101 0f502f5
User BH Convert.FromDegree for angle values conversion
GCRA101 f35d879
Update project compliance
BHoMBot bf2795e
Remove redundant ref to BH.Engine.Units in Panel.cs
GCRA101 fad69cf
Update dependencies.txt
peterjamesnugent File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,147 @@ | ||
| /* | ||
| * This file is part of the Buildings and Habitats object Model (BHoM) | ||
| * Copyright (c) 2015 - 2026, the respective contributors. All rights reserved. | ||
| * | ||
| * Each contributor holds copyright over their respective contributions. | ||
| * The project versioning (Git) records all such contribution source information. | ||
| * | ||
| * | ||
| * The BHoM is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU Lesser General Public License as published by | ||
| * the Free Software Foundation, either version 3.0 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * The BHoM is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU Lesser General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Lesser General Public License | ||
| * along with this code. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>. | ||
| */ | ||
|
|
||
| using BH.oM.Structure.Elements; | ||
| using BH.oM.Adapters.SAP2000; | ||
| using BH.oM.Geometry; | ||
| using BH.oM.Structure.Elements; | ||
| using BH.oM.Structure.SurfaceProperties; | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| using System.Text; | ||
| using System.Threading.Tasks; | ||
| using BH.Engine.Structure; | ||
|
|
||
| namespace BH.Adapter.SAP2000 | ||
| { | ||
| public partial class SAP2000Adapter | ||
| { | ||
| /***************************************************/ | ||
|
|
||
| private List<FEMesh> ReadMesh(List<string> ids = null) | ||
| { | ||
| 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 = GetCachedOrReadAsDictionary<string, Node>(); | ||
| Dictionary<string, ISurfaceProperty> surfaceProps = GetCachedOrReadAsDictionary<string, ISurfaceProperty>(); | ||
|
|
||
| foreach (string id in ids) | ||
| { | ||
| FEMesh mesh = new FEMesh(); | ||
|
|
||
| SAP2000Id sap2000id = new SAP2000Id(); | ||
| sap2000id.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 node already 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.ToPanelLocalXAxis(normal, orientation); | ||
| mesh = mesh.SetLocalOrientations(localX); | ||
|
|
||
| // Get guid | ||
| string guid = null; | ||
| m_model.AreaObj.GetGUID(id, ref guid); | ||
| sap2000id.PersistentId = guid; | ||
|
|
||
| SetAdapterId(mesh, sap2000id); | ||
| meshes.Add(mesh); | ||
| } | ||
| else | ||
| { | ||
| BH.Engine.Base.Compute.RecordWarning("Mesh " + id.ToString() + " could not be pulled, because it contains no nodes"); | ||
| } | ||
| } | ||
| BH.Engine.Base.Compute.RecordWarning("Meshes - Only one face normal vector is pulled from every mesh and it is applied to all the faces of the mesh."); | ||
| return meshes; | ||
| } | ||
|
|
||
| /***************************************************/ | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| /* | ||
| * This file is part of the Buildings and Habitats object Model (BHoM) | ||
| * Copyright (c) 2015 - 2026, the respective contributors. All rights reserved. | ||
| * | ||
| * Each contributor holds copyright over their respective contributions. | ||
| * The project versioning (Git) records all such contribution source information. | ||
| * | ||
| * | ||
| * The BHoM is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU Lesser General Public License as published by | ||
| * the Free Software Foundation, either version 3.0 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * The BHoM is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU Lesser General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Lesser General Public License | ||
| * along with this code. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>. | ||
| */ | ||
|
|
||
| using BH.Engine; | ||
| using BH.Engine.Geometry; | ||
| using BH.oM.Geometry; | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| using System.Text; | ||
| using System.Threading.Tasks; | ||
|
|
||
| namespace BH.Adapter.SAP2000 | ||
| { | ||
| public static partial class Convert | ||
| { | ||
| /***************************************************/ | ||
| /**** Public Methods ****/ | ||
| /***************************************************/ | ||
|
|
||
| public static Vector ToPanelLocalXAxis(Vector normal, double orientationAngle) | ||
| { | ||
| Vector locYref; | ||
|
|
||
| if (Query.IsParallel(normal, Vector.ZAxis)!=0) | ||
| { | ||
| //Vector is paralell to z-axis | ||
| locYref = Vector.YAxis; | ||
| } | ||
| else | ||
| { | ||
| //Vector is not paralell to z-axis | ||
| locYref = Vector.ZAxis.Project(new Plane { Normal = normal }); | ||
| } | ||
|
|
||
| Vector localXref = locYref.CrossProduct(normal); | ||
|
|
||
| return localXref.Rotate(BH.Engine.Units.Convert.FromDegree(orientationAngle), normal); | ||
| } | ||
|
|
||
| /***************************************************/ | ||
|
|
||
| } | ||
| } | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| BHoM/BHoM | ||
| BHoM/BHoM_Engine | ||
| BHoM/BHoM_Adapter | ||
| BHoM/BHoM_Adapter | ||
| BHoM/Localisation_Toolkit |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.