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

Make use of NameOrDescription Comparer when Pushing Properties #305

Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 3 additions & 2 deletions Etabs_Adapter/CRUD/Create/Link.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
using System.Linq;
using BH.oM.Structure.Elements;
using BH.oM.Structure.Constraints;
using BH.Engine.Structure;
#if Debug17 || Release17
using ETABSv17;
#elif Debug18 || Release18
Expand Down Expand Up @@ -60,7 +61,7 @@ private bool CreateObject(RigidLink bhLink)
{
string name = "";

retA = m_model.LinkObj.AddByPoint(masterNode.CustomData[AdapterIdName].ToString(), slaveNodes[i].CustomData[AdapterIdName].ToString(), ref name, false, constraint.Name);
retA = m_model.LinkObj.AddByPoint(masterNode.CustomData[AdapterIdName].ToString(), slaveNodes[i].CustomData[AdapterIdName].ToString(), ref name, false, constraint.DescriptionOrName());

linkIds.Add(name);
}
Expand All @@ -75,7 +76,7 @@ private bool CreateObject(RigidLink bhLink)
private bool CreateObject(LinkConstraint bhLinkConstraint)
{

string name = bhLinkConstraint.Name;
string name = bhLinkConstraint.DescriptionOrName();

bool[] dof = new bool[6];

Expand Down
12 changes: 6 additions & 6 deletions Etabs_Adapter/CRUD/Create/Material.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ private bool CreateObject(IMaterialFragment material)
string guid = "";
string notes = "";
string name = "";
if (m_model.PropMaterial.GetMaterial(material.Name, ref matType, ref colour, ref notes, ref guid) != 0)
if (m_model.PropMaterial.GetMaterial(material.DescriptionOrName(), ref matType, ref colour, ref notes, ref guid) != 0)
{
m_model.PropMaterial.AddMaterial(ref name, MaterialTypeToCSI(material.IMaterialType()), "", "", "");
m_model.PropMaterial.ChangeName(name, material.Name);
m_model.PropMaterial.ChangeName(name, material.DescriptionOrName());
if (material is IIsotropic)
{
IIsotropic isotropic = material as IIsotropic;
success &= m_model.PropMaterial.SetMPIsotropic(material.Name, isotropic.YoungsModulus, isotropic.PoissonsRatio, isotropic.ThermalExpansionCoeff) == 0;
success &= m_model.PropMaterial.SetMPIsotropic(material.DescriptionOrName(), isotropic.YoungsModulus, isotropic.PoissonsRatio, isotropic.ThermalExpansionCoeff) == 0;
}
else if (material is IOrthotropic)
{
Expand All @@ -72,12 +72,12 @@ private bool CreateObject(IMaterialFragment material)
double[] v = orthoTropic.PoissonsRatio.ToDoubleArray();
double[] a = orthoTropic.ThermalExpansionCoeff.ToDoubleArray();
double[] g = orthoTropic.ShearModulus.ToDoubleArray();
success &= m_model.PropMaterial.SetMPOrthotropic(material.Name, ref e, ref v, ref a, ref g) == 0;
success &= m_model.PropMaterial.SetMPOrthotropic(material.DescriptionOrName(), ref e, ref v, ref a, ref g) == 0;
}
success &= m_model.PropMaterial.SetWeightAndMass(material.Name, 2, material.Density) == 0;
success &= m_model.PropMaterial.SetWeightAndMass(material.DescriptionOrName(), 2, material.Density) == 0;
}
if (!success)
Engine.Reflection.Compute.RecordWarning($"Failed to assign material: {material.Name}, ETABS may have overwritten some properties with default values");
Engine.Reflection.Compute.RecordWarning($"Failed to assign material: {material.DescriptionOrName()}, ETABS may have overwritten some properties with default values");
return success;
}

Expand Down
23 changes: 7 additions & 16 deletions Etabs_Adapter/CRUD/Create/Panel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,44 +129,35 @@ private bool CreateObject(ISurfaceProperty property2d)
bool success = true;
int retA = 0;

string propertyName = "None";
if (property2d.Name != "")
{
property2d.CustomData[AdapterIdName] = propertyName = property2d.Name;
}
else
{
BH.Engine.Reflection.Compute.RecordWarning("Surface properties with no name will be converted to the null property 'None'.");
property2d.CustomData[AdapterIdName] = "None";
return true;
}
string propertyName = property2d.DescriptionOrName();
property2d.CustomData[AdapterIdName] = propertyName;

eShellType shellType = ShellTypeToCSI(property2d);

if (property2d.GetType() == typeof(Waffle))
{
Waffle waffleProperty = (Waffle)property2d;
m_model.PropArea.SetSlab(propertyName, eSlabType.Waffle, shellType, property2d.Material.Name, waffleProperty.Thickness);
m_model.PropArea.SetSlab(propertyName, eSlabType.Waffle, shellType, property2d.Material.DescriptionOrName(), waffleProperty.Thickness);
retA = m_model.PropArea.SetSlabWaffle(propertyName, waffleProperty.TotalDepthX, waffleProperty.Thickness, waffleProperty.StemWidthX, waffleProperty.StemWidthX, waffleProperty.SpacingX, waffleProperty.SpacingY);
}
else if (property2d.GetType() == typeof(Ribbed))
{
Ribbed ribbedProperty = (Ribbed)property2d;
m_model.PropArea.SetSlab(propertyName, eSlabType.Ribbed, shellType, property2d.Material.Name, ribbedProperty.Thickness);
m_model.PropArea.SetSlab(propertyName, eSlabType.Ribbed, shellType, property2d.Material.DescriptionOrName(), ribbedProperty.Thickness);
retA = m_model.PropArea.SetSlabRibbed(propertyName, ribbedProperty.TotalDepth, ribbedProperty.Thickness, ribbedProperty.StemWidth, ribbedProperty.StemWidth, ribbedProperty.Spacing, (int)ribbedProperty.Direction);
}
else if (property2d.GetType() == typeof(LoadingPanelProperty))
{
retA = m_model.PropArea.SetSlab(propertyName, eSlabType.Slab, shellType, property2d.Material.Name, 0);
retA = m_model.PropArea.SetSlab(propertyName, eSlabType.Slab, shellType, property2d.Material.DescriptionOrName(), 0);
}

else if (property2d.GetType() == typeof(ConstantThickness))
{
ConstantThickness constantThickness = (ConstantThickness)property2d;
if (constantThickness.PanelType == PanelType.Wall)
retA = m_model.PropArea.SetWall(propertyName, eWallPropType.Specified, shellType, property2d.Material.Name, constantThickness.Thickness);
retA = m_model.PropArea.SetWall(propertyName, eWallPropType.Specified, shellType, property2d.Material.DescriptionOrName(), constantThickness.Thickness);
else
retA = m_model.PropArea.SetSlab(propertyName, eSlabType.Slab, shellType, property2d.Material.Name, constantThickness.Thickness);
retA = m_model.PropArea.SetSlab(propertyName, eSlabType.Slab, shellType, property2d.Material.DescriptionOrName(), constantThickness.Thickness);
}


Expand Down
59 changes: 25 additions & 34 deletions Etabs_Adapter/CRUD/Create/SectionProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,9 @@ public partial class ETABS2016Adapter : BHoMAdapter

private bool CreateObject(ISectionProperty bhSection)
{
string propertyName = "None";
if (bhSection.Name != "")
{
bhSection.CustomData[AdapterIdName] = propertyName = bhSection.Name;
}
else
{
BH.Engine.Reflection.Compute.RecordWarning("Section properties with no name will be converted to the null property 'None'.");
bhSection.CustomData[AdapterIdName] = "None";
return true;
}

string propertyName = bhSection.DescriptionOrName();
bhSection.CustomData[AdapterIdName] = propertyName;

if (!LoadFromDatabase(bhSection))
{
SetSection(bhSection as dynamic);
Expand All @@ -95,7 +86,7 @@ private bool CreateObject(ISectionProperty bhSection)
etabsMods[6] = 1; //Mass, not currently implemented
etabsMods[7] = 1; //Weight, not currently implemented

m_model.PropFrame.SetModifiers(bhSection.Name, ref etabsMods);
m_model.PropFrame.SetModifiers(propertyName, ref etabsMods);
}

return true;
Expand All @@ -107,14 +98,14 @@ private bool CreateObject(ISectionProperty bhSection)

private void SetSection(IGeometricalSection section)
{
ISetProfile(section.SectionProfile, section.Name, section.Material);
ISetProfile(section.SectionProfile, section.DescriptionOrName(), section.Material);
}

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

private void SetSection(ExplicitSection section)
{
m_model.PropFrame.SetGeneral(section.Name, section.Material.Name, section.Vz + section.Vpz, section.Vy + section.Vpy,
m_model.PropFrame.SetGeneral(section.DescriptionOrName(), section.Material.DescriptionOrName(), section.Vz + section.Vpz, section.Vy + section.Vpy,
section.Area, section.Asz, section.Asy, section.J,
section.Iz, section.Iy, // I22, I33
section.Welz, section.Wely, // S22, S33
Expand All @@ -126,7 +117,7 @@ private void SetSection(ExplicitSection section)

private void SetSection(ISectionProperty section)
{
CreateElementError(section.GetType().ToString(), section.Name);
CreateElementError(section.GetType().ToString(), section.DescriptionOrName());
}

/***************************************************/
Expand Down Expand Up @@ -177,14 +168,14 @@ private void SetProfile(TaperedProfile profile, string sectionName, IMaterialFra

private void SetProfile(TubeProfile profile, string sectionName, IMaterialFragment material)
{
m_model.PropFrame.SetPipe(sectionName, material.Name, profile.Diameter, profile.Thickness);
m_model.PropFrame.SetPipe(sectionName, material.DescriptionOrName(), profile.Diameter, profile.Thickness);
}

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

private void SetProfile(BoxProfile profile, string sectionName, IMaterialFragment material)
{
m_model.PropFrame.SetTube(sectionName, material.Name, profile.Height, profile.Width, profile.Thickness, profile.Thickness);
m_model.PropFrame.SetTube(sectionName, material.DescriptionOrName(), profile.Height, profile.Width, profile.Thickness, profile.Thickness);
}

/***************************************************/
Expand All @@ -193,28 +184,28 @@ private void SetProfile(FabricatedBoxProfile profile, string sectionName, IMater
{
if (profile.TopFlangeThickness != profile.BotFlangeThickness)
Engine.Reflection.Compute.RecordWarning("different thickness of top and bottom flange is not supported in ETABS");
m_model.PropFrame.SetTube(sectionName, material.Name, profile.Height, profile.Width, profile.TopFlangeThickness, profile.WebThickness);
m_model.PropFrame.SetTube(sectionName, material.DescriptionOrName(), profile.Height, profile.Width, profile.TopFlangeThickness, profile.WebThickness);
}

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

private void SetProfile(ISectionProfile profile, string sectionName, IMaterialFragment material)
{
m_model.PropFrame.SetISection(sectionName, material.Name, profile.Height, profile.Width, profile.FlangeThickness, profile.WebThickness, profile.Width, profile.FlangeThickness);
m_model.PropFrame.SetISection(sectionName, material.DescriptionOrName(), profile.Height, profile.Width, profile.FlangeThickness, profile.WebThickness, profile.Width, profile.FlangeThickness);
}

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

private void SetProfile(FabricatedISectionProfile profile, string sectionName, IMaterialFragment material)
{
m_model.PropFrame.SetISection(sectionName, material.Name, profile.Height, profile.TopFlangeWidth, profile.TopFlangeThickness, profile.WebThickness, profile.BotFlangeWidth, profile.BotFlangeThickness);
m_model.PropFrame.SetISection(sectionName, material.DescriptionOrName(), profile.Height, profile.TopFlangeWidth, profile.TopFlangeThickness, profile.WebThickness, profile.BotFlangeWidth, profile.BotFlangeThickness);
}

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

private void SetProfile(ChannelProfile profile, string sectionName, IMaterialFragment material)
{
m_model.PropFrame.SetChannel(sectionName, material.Name, profile.Height, profile.FlangeWidth, profile.FlangeThickness, profile.WebThickness);
m_model.PropFrame.SetChannel(sectionName, material.DescriptionOrName(), profile.Height, profile.FlangeWidth, profile.FlangeThickness, profile.WebThickness);
if (profile.MirrorAboutLocalZ)
RecordFlippingError(sectionName);
}
Expand All @@ -225,12 +216,12 @@ private void SetProfile(AngleProfile profile, string sectionName, IMaterialFragm
{

if (material is Steel || material is Aluminium)
m_model.PropFrame.SetSteelAngle(sectionName, material.Name, profile.Height, profile.Width, profile.FlangeThickness, profile.WebThickness, profile.RootRadius, profile.MirrorAboutLocalZ, profile.MirrorAboutLocalY);
m_model.PropFrame.SetSteelAngle(sectionName, material.DescriptionOrName(), profile.Height, profile.Width, profile.FlangeThickness, profile.WebThickness, profile.RootRadius, profile.MirrorAboutLocalZ, profile.MirrorAboutLocalY);
else if (material is Concrete)
m_model.PropFrame.SetConcreteL(sectionName, material.Name, profile.Height, profile.Width, profile.FlangeThickness, profile.WebThickness, profile.WebThickness, profile.MirrorAboutLocalZ, profile.MirrorAboutLocalY);
m_model.PropFrame.SetConcreteL(sectionName, material.DescriptionOrName(), profile.Height, profile.Width, profile.FlangeThickness, profile.WebThickness, profile.WebThickness, profile.MirrorAboutLocalZ, profile.MirrorAboutLocalY);
else
{
m_model.PropFrame.SetAngle(sectionName, material.Name, profile.Height, profile.Width, profile.FlangeThickness, profile.WebThickness);
m_model.PropFrame.SetAngle(sectionName, material.DescriptionOrName(), profile.Height, profile.Width, profile.FlangeThickness, profile.WebThickness);
if (profile.MirrorAboutLocalY || profile.MirrorAboutLocalZ)
RecordFlippingError(sectionName);
}
Expand All @@ -242,12 +233,12 @@ private void SetProfile(AngleProfile profile, string sectionName, IMaterialFragm
private void SetProfile(TSectionProfile profile, string sectionName, IMaterialFragment material)
{
if (material is Steel || material is Aluminium)
m_model.PropFrame.SetSteelTee(sectionName, material.Name, profile.Height, profile.Width, profile.FlangeThickness, profile.WebThickness, profile.RootRadius, profile.MirrorAboutLocalY);
m_model.PropFrame.SetSteelTee(sectionName, material.DescriptionOrName(), profile.Height, profile.Width, profile.FlangeThickness, profile.WebThickness, profile.RootRadius, profile.MirrorAboutLocalY);
else if (material is Concrete)
m_model.PropFrame.SetConcreteTee(sectionName, material.Name, profile.Height, profile.Width, profile.FlangeThickness, profile.WebThickness, profile.WebThickness, profile.MirrorAboutLocalY);
m_model.PropFrame.SetConcreteTee(sectionName, material.DescriptionOrName(), profile.Height, profile.Width, profile.FlangeThickness, profile.WebThickness, profile.WebThickness, profile.MirrorAboutLocalY);
else
{
m_model.PropFrame.SetTee(sectionName, material.Name, profile.Height, profile.Width, profile.FlangeThickness, profile.WebThickness);
m_model.PropFrame.SetTee(sectionName, material.DescriptionOrName(), profile.Height, profile.Width, profile.FlangeThickness, profile.WebThickness);
if (profile.MirrorAboutLocalY)
RecordFlippingError(sectionName);
}
Expand All @@ -258,14 +249,14 @@ private void SetProfile(TSectionProfile profile, string sectionName, IMaterialFr

private void SetProfile(RectangleProfile profile, string sectionName, IMaterialFragment material)
{
m_model.PropFrame.SetRectangle(sectionName, material.Name, profile.Height, profile.Width);
m_model.PropFrame.SetRectangle(sectionName, material.DescriptionOrName(), profile.Height, profile.Width);
}

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

private void SetProfile(CircleProfile profile, string sectionName, IMaterialFragment material)
{
m_model.PropFrame.SetCircle(sectionName, material.Name, profile.Diameter);
m_model.PropFrame.SetCircle(sectionName, material.DescriptionOrName(), profile.Diameter);
}

/***************************************************/
Expand All @@ -283,7 +274,7 @@ private bool LoadFromDatabase(ISectionProperty bhSection)
if (EtabsSettings.DatabaseSettings.SectionDatabase == SectionDatabase.None)
return false;

string bhName = bhSection.Name;
string bhName = bhSection.DescriptionOrName();

// Formatt as uppercase and no spaces
bhName = bhName.ToUpper();
Expand Down Expand Up @@ -314,16 +305,16 @@ private bool LoadFromDatabase(ISectionProperty bhSection)

// Try to get it from the database, return false on faliure
if (1 == m_model.PropFrame.ImportProp(
bhSection.Name,
bhSection.Material.Name,
bhSection.DescriptionOrName(),
bhSection.Material.DescriptionOrName(),
ToEtabsFileName(EtabsSettings.DatabaseSettings.SectionDatabase),
m_DBSectionsNames[index]))
{
return false;
}

// Notify user and return true to stop the adapter from creating a new Section
Engine.Reflection.Compute.RecordNote(bhSection.Name + " properties has been assigned from the database section " + bhName + ".");
Engine.Reflection.Compute.RecordNote(bhSection.DescriptionOrName() + " properties has been assigned from the database section " + bhName + ".");
return true;
}

Expand Down
Loading