diff --git a/Robot_Adapter/Convert/FromRobot/Properties/SectionProfile_General.cs b/Robot_Adapter/Convert/FromRobot/Properties/SectionProfile_General.cs index cb5acf8c..df7f7e19 100644 --- a/Robot_Adapter/Convert/FromRobot/Properties/SectionProfile_General.cs +++ b/Robot_Adapter/Convert/FromRobot/Properties/SectionProfile_General.cs @@ -181,7 +181,11 @@ private static IProfile NonStandardProfile(IRobotBarSectionShapeType shapeType, if (outstand < 0 && Math.Abs(outstand) < Tolerance.MicroDistance) outstand = 0; - sectionProfile = BH.Engine.Spatial.Create.GeneralisedFabricatedBoxProfile(h + (2 * tf), b1 + (2 * tw), tw, tf, tf, outstand, outstand); + //If outstands are 0 (less than microdistance fraction of the width) return a standard fabricated box section. + if (b1 > Tolerance.Distance && outstand / b1 < Tolerance.MicroDistance) + sectionProfile = BH.Engine.Spatial.Create.FabricatedBoxProfile(h + (2 * tf), b1 + 2 * tw, tw, tf, tf, 0); + else + sectionProfile = BH.Engine.Spatial.Create.GeneralisedFabricatedBoxProfile(h + (2 * tf), b1 + (2 * tw), tw, tf, tf, outstand, outstand); break; case IRobotBarSectionShapeType.I_BSST_USER_BOX_3: diff --git a/Robot_Adapter/Convert/ToRobot/Properties/SectionProperty_Geometrical.cs b/Robot_Adapter/Convert/ToRobot/Properties/SectionProperty_Geometrical.cs index d8c2a71a..026153d3 100644 --- a/Robot_Adapter/Convert/ToRobot/Properties/SectionProperty_Geometrical.cs +++ b/Robot_Adapter/Convert/ToRobot/Properties/SectionProperty_Geometrical.cs @@ -25,6 +25,7 @@ using BH.oM.Structure.SectionProperties; using BH.oM.Spatial.ShapeProfiles; using System.Linq; +using BH.oM.Geometry; namespace BH.Adapter.Robot { @@ -86,15 +87,16 @@ private static bool ToRobotGeometricalSection(this TaperedProfile section, IRobo { if (SetRobotTypeAndShapeType(startProfile as dynamic, sectionData)) { - SetNonStandardSectionData(startProfile as dynamic, sectionData, 0); - SetNonStandardSectionData(endProfile as dynamic, sectionData, 1); - sectionData.CalcNonstdGeometry(); - return true; + bool success = SetNonStandardSectionData(startProfile as dynamic, sectionData, 0); + success &= SetNonStandardSectionData(endProfile as dynamic, sectionData, 1); + if(success) + sectionData.CalcNonstdGeometry(); + return success; } } } - Engine.Base.Compute.RecordWarning("The robot adapter currently only support tapered sections with two profiles of the same type. Section set as explicit with 0-properties."); + Engine.Base.Compute.RecordWarning($"The robot adapter currently only support tapered sections with two profiles of the same type. Section with name {sectionData.Name} set as explicit section with 0-properties."); return false; } @@ -111,8 +113,17 @@ private static bool SetRobotTypeAndShapeType(this BoxProfile section, IRobotBarS private static bool SetRobotTypeAndShapeType(this FabricatedBoxProfile section, IRobotBarSectionData sectionData) { - sectionData.Type = IRobotBarSectionType.I_BST_NS_BOX_3; - sectionData.ShapeType = IRobotBarSectionShapeType.I_BSST_USER_BOX_3; + if (section.BotFlangeThickness > Tolerance.MicroDistance && (section.BotFlangeThickness - section.TopFlangeThickness) / (section.BotFlangeThickness + section.TopFlangeThickness) / 2 < 1e-6) //If same flange thickness on both top and bot flange + { + sectionData.Type = IRobotBarSectionType.I_BST_NS_BOX_2; + sectionData.ShapeType = IRobotBarSectionShapeType.I_BSST_USER_BOX_2; + } + else + { + sectionData.Type = IRobotBarSectionType.I_BST_NS_BOX_3; + sectionData.ShapeType = IRobotBarSectionShapeType.I_BSST_USER_BOX_3; + } + return true; } @@ -200,7 +211,7 @@ private static bool SetRobotTypeAndShapeType(this GeneralisedFabricatedBoxProfil private static bool SetRobotTypeAndShapeType(this IProfile section, IRobotBarSectionData sectionData) { - Engine.Base.Compute.RecordWarning("Profile of type " + section.GetType().Name + " is not yet fully supported for Steel sections. Section with name " + sectionData.Name + " set as explicit section"); + Engine.Base.Compute.RecordWarning("Profile of type " + section.GetType().Name + " is not yet fully supported for Steel sections. Section with name " + sectionData.Name + " set as explicit section."); return false; } @@ -222,13 +233,32 @@ private static bool SetNonStandardSectionData(this FabricatedBoxProfile section, { IRobotBarSectionNonstdData nonStdData = sectionData.CreateNonstd(position); - nonStdData.SetValue(IRobotBarSectionNonstdDataValue.I_BSNDV_BOX_3_B, section.Width); - nonStdData.SetValue(IRobotBarSectionNonstdDataValue.I_BSNDV_BOX_3_B1, section.Width - (2 * section.WebThickness)); - nonStdData.SetValue(IRobotBarSectionNonstdDataValue.I_BSNDV_BOX_3_B2, section.Width); - nonStdData.SetValue(IRobotBarSectionNonstdDataValue.I_BSNDV_BOX_3_H, section.Height - (section.TopFlangeThickness + section.BotFlangeThickness)); - nonStdData.SetValue(IRobotBarSectionNonstdDataValue.I_BSNDV_BOX_3_TW, section.WebThickness); - nonStdData.SetValue(IRobotBarSectionNonstdDataValue.I_BSNDV_BOX_3_TF, section.TopFlangeThickness); - nonStdData.SetValue(IRobotBarSectionNonstdDataValue.I_BSNDV_BOX_3_TF2, section.BotFlangeThickness); + if (sectionData.ShapeType == IRobotBarSectionShapeType.I_BSST_USER_BOX_3) //Check assigned shapetype. Box3 for varying flange thickness, box 2 will be set if flange thickness the same + { + if (position != 0) //Tapered sections only support box 2 + { + BH.Engine.Base.Compute.RecordWarning($"Robot only supports boxes with equal flanges for tapered sections. Section with name {sectionData.Name} set as explicit section with 0 properties."); + return false; + } + + nonStdData.SetValue(IRobotBarSectionNonstdDataValue.I_BSNDV_BOX_3_B, section.Width); + nonStdData.SetValue(IRobotBarSectionNonstdDataValue.I_BSNDV_BOX_3_B1, section.Width - (2 * section.WebThickness)); + nonStdData.SetValue(IRobotBarSectionNonstdDataValue.I_BSNDV_BOX_3_B2, section.Width); + nonStdData.SetValue(IRobotBarSectionNonstdDataValue.I_BSNDV_BOX_3_H, section.Height - (section.TopFlangeThickness + section.BotFlangeThickness)); + nonStdData.SetValue(IRobotBarSectionNonstdDataValue.I_BSNDV_BOX_3_TW, section.WebThickness); + nonStdData.SetValue(IRobotBarSectionNonstdDataValue.I_BSNDV_BOX_3_TF, section.TopFlangeThickness); + nonStdData.SetValue(IRobotBarSectionNonstdDataValue.I_BSNDV_BOX_3_TF2, section.BotFlangeThickness); + + } + else + { + nonStdData.SetValue(IRobotBarSectionNonstdDataValue.I_BSNDV_BOX_2_B, section.Width); + nonStdData.SetValue(IRobotBarSectionNonstdDataValue.I_BSNDV_BOX_2_B1, section.Width - (2 * section.WebThickness)); + nonStdData.SetValue(IRobotBarSectionNonstdDataValue.I_BSNDV_BOX_2_H, section.Height - (section.TopFlangeThickness + section.BotFlangeThickness)); + nonStdData.SetValue(IRobotBarSectionNonstdDataValue.I_BSNDV_BOX_2_TW, section.WebThickness); + nonStdData.SetValue(IRobotBarSectionNonstdDataValue.I_BSNDV_BOX_2_TF, section.TopFlangeThickness); + } + return true; }