Skip to content
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

FlipBar, Moments and other fixes #254

Merged
merged 21 commits into from
Feb 4, 2020
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions ETABS_Engine/Convert/ToCSI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
using BH.oM.Structure.Constraints;
using BH.oM.Structure.MaterialFragments;
using BH.oM.Geometry;

using System.Linq;

namespace BH.Engine.ETABS
{
Expand All @@ -52,7 +52,7 @@ public static void ToCSI(this Constraint6DOF support, ref bool[] restraint, ref

/***************************************************/

public static void ToCSI(this BarRelease release, ref bool[] startRestraint, ref double[] startSpring, ref bool[] endRestraint, ref double[] endSpring)
public static bool ToCSI(this BarRelease release, ref bool[] startRestraint, ref double[] startSpring, ref bool[] endRestraint, ref double[] endSpring)
{
startRestraint = new bool[6];
startRestraint[0] = release.StartRelease.TranslationX == DOFType.Free;
Expand Down Expand Up @@ -85,6 +85,25 @@ public static void ToCSI(this BarRelease release, ref bool[] startRestraint, ref
endSpring[3] = release.EndRelease.RotationalStiffnessX;
endSpring[4] = release.EndRelease.RotationalStiffnessY;
endSpring[5] = release.EndRelease.RotationalStiffnessZ;

bool[] startReleased = startRestraint.Zip(startSpring, (x, y) => x && y == 0).ToArray();
kThorsager marked this conversation as resolved.
Show resolved Hide resolved
bool[] endReleased = endRestraint.Zip(endSpring, (x, y) => x && y == 0).ToArray();
bool success = true;

if (startReleased[0] && endReleased[0])
{ Engine.Reflection.Compute.RecordWarning($"Unstable releases have not been set, can not release TranslationX for both ends"); success = false; }
if (startReleased[1] && endReleased[1])
{ Engine.Reflection.Compute.RecordWarning($"Unstable releases have not been set, can not release TranslationY for both ends"); success = false; }
if (startReleased[2] && endReleased[2])
{ Engine.Reflection.Compute.RecordWarning($"Unstable releases have not been set, can not release TranslationZ for both ends"); success = false; }
if (startReleased[3] && endReleased[3])
{ Engine.Reflection.Compute.RecordWarning($"Unstable releases have not been set, can not release RotationX for both ends"); success = false; }
if (startReleased[4] && endReleased[4] && (startReleased[2] || endReleased[2]))
{ Engine.Reflection.Compute.RecordWarning($"Unstable releases have not been set, can not release TranslationZ when RotationY is released for both ends"); success = false; }
if (startReleased[5] && endReleased[5] && (startReleased[1] || endReleased[1]))
{ Engine.Reflection.Compute.RecordWarning($"Unstable releases have not been set, can not release TranslationY when RotationZ is released for both ends"); success = false; }

return success;
}

/***************************************************/
Expand Down
2 changes: 2 additions & 0 deletions ETABS_Engine/ETABS_Engine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
<Compile Include="Create\Pier.cs" />
<Compile Include="Create\Spandrel.cs" />
<Compile Include="ModelData.cs" />
<Compile Include="Modify\FlipEndPoints.cs" />
<Compile Include="Modify\Upgrade.cs" />
<Compile Include="Modify\SetAutoLengthOffset.cs" />
<Compile Include="Modify\SetDiaphragm.cs" />
Expand All @@ -166,6 +167,7 @@
<Compile Include="Query\Diaphragm.cs" />
<Compile Include="Query\DiaphragmType.cs" />
<Compile Include="Query\InsertionPoint.cs" />
<Compile Include="Query\FlipBar.cs" />
<Compile Include="Query\Pier.cs" />
<Compile Include="Query\Spandrel.cs" />
</ItemGroup>
Expand Down
109 changes: 109 additions & 0 deletions ETABS_Engine/Modify/FlipEndPoints.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2019, 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 System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BH.oM.Structure.Elements;
using BH.oM.Adapters.ETABS;
using BH.oM.Adapters.ETABS.Elements;
using BH.Engine.Structure;
using BH.oM.Geometry;
using BH.oM.Structure.Constraints;

namespace BH.Engine.ETABS
{
public static partial class Modify
{

/***************************************************/
/**** Public Methods ****/
/***************************************************/

public static Bar FlipEndPoints(this Bar bar)
{
// Flip the endpoints
Bar clone = bar.Flip();

// Flip orientationAngle
if (!bar.IsVertical())
kThorsager marked this conversation as resolved.
Show resolved Hide resolved
clone.OrientationAngle = -clone.OrientationAngle;

// Flip Offsets
if (clone.Offset != null)
{
Vector tempV = clone.Offset.Start;
clone.Offset.Start = clone.Offset.End;
clone.Offset.End = tempV;

clone.Offset.Start.X *= -1;
clone.Offset.End.X *= -1;

if (!bar.IsVertical())
{
clone.Offset.Start.Y *= -1;
clone.Offset.End.Y *= -1;
}
}
// mirror the section
// not possible to push to ETABS afterwards if we did
// warning for asymetric sections?

// Flip Release
if (clone.Release != null)
{
Constraint6DOF tempC = clone.Release.StartRelease;
clone.Release.StartRelease = clone.Release.EndRelease;
clone.Release.EndRelease = tempC;
}

return clone;
}

/***************************************************/

public static Bar FlipInsertionPoint(this Bar bar)
{
int insertionPoint = (int)bar.InsertionPoint();

switch (insertionPoint)
{
case 1:
case 4:
case 7:
return bar.SetInsertionPoint((BarInsertionPoint)insertionPoint + 2);
case 3:
case 6:
case 9:
return bar.SetInsertionPoint((BarInsertionPoint)insertionPoint - 2);
default:
return bar;
}
}

/***************************************************/

}
}
59 changes: 59 additions & 0 deletions ETABS_Engine/Query/FlipBar.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2018, 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 System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BH.oM.Structure.Elements;
using BH.oM.Adapters.ETABS.Elements;
using BH.oM.Geometry;

namespace BH.Engine.ETABS
{
public static partial class Query
{

/***************************************************/
/**** Public Methods ****/
/***************************************************/

public static bool FlipBar(this Bar bar)
kThorsager marked this conversation as resolved.
Show resolved Hide resolved
{
Point start = bar.StartNode.Position;
Point end = bar.EndNode.Position;

if (start.Z > end.Z)
return true;
if (start.X > end.X)
return true;
if (start.Y > end.Y)
return true;

return false;
}

/***************************************************/

}
}
44 changes: 36 additions & 8 deletions Etabs_Adapter/CRUD/Create/Bar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,14 @@ private bool CreateObject(Bar bhBar)


string name = "";


// Evaluate if the bar is alinged as Etabs wants it
if (bhBar.FlipBar())
{
bhBar = bhBar.FlipEndPoints(); //CloneBeforePush means this is fine(?)
bhBar = bhBar.FlipInsertionPoint(); //ETABS specific operation
Engine.Reflection.Compute.RecordNote("Some bars has been flipped to comply with ETABS API, asymmetric sections will suffer");
}
ret = m_model.FrameObj.AddByPoint(bhBar.StartNode.CustomData[AdapterIdName].ToString(), bhBar.EndNode.CustomData[AdapterIdName].ToString(), ref name);

bhBar.CustomData[AdapterIdName] = name;
Expand Down Expand Up @@ -109,12 +116,13 @@ private bool CreateObject(Bar bhBar)
bool[] restraintEnd = null;
double[] springEnd = null;

bhBar.Release.ToCSI(ref restraintStart, ref springStart, ref restraintEnd, ref springEnd);

if (m_model.FrameObj.SetReleases(name, ref restraintStart, ref restraintEnd, ref springStart, ref springEnd) != 0)
if (bhBar.Release.ToCSI(ref restraintStart, ref springStart, ref restraintEnd, ref springEnd))
{
CreatePropertyWarning("Release", "Bar", name);
ret++;
if (m_model.FrameObj.SetReleases(name, ref restraintStart, ref restraintEnd, ref springStart, ref springEnd) != 0)
{
CreatePropertyWarning("Release", "Bar", name);
ret++;
}
}
}

Expand All @@ -132,13 +140,25 @@ private bool CreateObject(Bar bhBar)
}
else if (bhBar.Offset != null)
{
if (m_model.FrameObj.SetEndLengthOffset(name, false, -1 * (bhBar.Offset.Start.X), bhBar.Offset.End.X, 1) != 0)
if (m_model.FrameObj.SetEndLengthOffset(name, false, bhBar.Offset.Start.X, -1 * (bhBar.Offset.End.X), 1) != 0)
{
CreatePropertyWarning("Length offset", "Bar", name);
ret++;
}
}

switch (bhBar.FEAType)
{
case BarFEAType.CompressionOnly:
m_model.FrameObj.SetTCLimits(name, false, 0, true, 0);
break;
case BarFEAType.TensionOnly:
m_model.FrameObj.SetTCLimits(name, true, 0, false, 0);
break;
default:
break;
}

return true;
}

Expand Down Expand Up @@ -199,7 +219,15 @@ private void SetSection(ConcreteSection section)

private void SetSection(ExplicitSection section)
{
m_model.PropFrame.SetGeneral(section.Name, section.Material.Name, section.CentreZ * 2, section.CentreY * 2, section.Area, section.Asy, section.Asz, section.J, section.Iy, section.Iz, section.Wply, section.Wplz, section.Wely, section.Wely, section.Rgy, section.Rgz);
m_model.PropFrame.SetGeneral(section.Name, section.Material.Name, section.Vz + section.Vpz, section.Vy + section.Vpy, section.Area, section.Asy, section.Asz, section.J, section.Iy, section.Iz, section.Wply, section.Wplz, section.Wely, section.Wely, section.Rgy, section.Rgz);
kThorsager marked this conversation as resolved.
Show resolved Hide resolved
}

/***************************************************/

private void SetSection(CableSection section)
{
double diameter = (section as CableSection).CableDiameter;
m_model.PropFrame.SetGeneral(section.Name, section.Material.Name, diameter, diameter, section.Area, section.Asy, section.Asz, section.J, section.Iy, section.Iz, section.Wply, section.Wplz, section.Wely, section.Wely, section.Rgy, section.Rgz);
}

/***************************************************/
Expand Down
14 changes: 13 additions & 1 deletion Etabs_Adapter/CRUD/Create/Load.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,19 @@ public void SetLoad(BarUniformlyDistributedLoad barUniformLoad, bool replace)

stepReplace = false;
}
//moments ? does not exist in old toolkit either!
// Moment
for (int direction = 1; direction <= 3; direction++)
{
int ret = 1;
double val = direction == 1 ? barUniformLoad.Moment.X : direction == 2 ? barUniformLoad.Moment.Y : barUniformLoad.Moment.Z; //note: etabs acts different then stated in API documentstion

if (val != 0)
{
ret = m_model.FrameObj.SetLoadDistributed(barName, caseName, 2, direction + 3, 0, 1, val, val, "Global", true, stepReplace);
}

stepReplace = false;
}
}
}

Expand Down