Skip to content

Commit

Permalink
Csharpier CSI (#2999)
Browse files Browse the repository at this point in the history
* Renamed project to avoid spaces in directory path

* Csharpier format
  • Loading branch information
JR-Morgan authored Oct 24, 2023
1 parent 804c26c commit 6e1d7b4
Show file tree
Hide file tree
Showing 42 changed files with 110 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,45 +18,45 @@
<Compile Include="$(MSBuildThisFileDirectory)Extensions\PolycurveExtensions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Models\DatabaseTableWrapper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Models\ETABSGridLineDefinitionTable.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Partial Classes\Analysis\ConvertModelSettings.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Partial Classes\Analysis\ConvertModel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Partial Classes\Analysis\ConvertModelInfo.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Partial Classes\Analysis\ConvertModelUnits.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Partial Classes\Geometry\ConvertArea.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Partial Classes\Geometry\ConvertBeam.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Partial Classes\Geometry\ConvertBraces.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Partial Classes\Geometry\ConvertBuiltElement.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Partial Classes\Geometry\ConvertColumn.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Partial Classes\Geometry\ConvertFloor.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Partial Classes\Geometry\ConvertFrame.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Partial Classes\Geometry\ConvertGridLines.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Partial Classes\Geometry\ConvertLine.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Partial Classes\Geometry\ConvertLinks.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Partial Classes\Geometry\ConvertPier.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Partial Classes\Geometry\ConvertPoint.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Partial Classes\Geometry\ConvertSpandrel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Partial Classes\Geometry\ConvertStories.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Partial Classes\Geometry\ConvertTendon.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Partial Classes\Geometry\ConvertWall.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Partial Classes\Loading\ConvertLoadPattern.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Partial Classes\Loading\Loading1DElements.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Partial Classes\Loading\Loading2DElements.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Partial Classes\Loading\LoadingNode.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Partial Classes\Materials\ConvertMaterials.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Partial Classes\Properties\Convert1DProperty.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Partial Classes\Properties\Convert2DProperty.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Partial Classes\Properties\Convert2DPropertyFloor.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Partial Classes\Properties\Convert2DPropertyWall.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Partial Classes\Properties\ConvertDiaphragm.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Partial Classes\Properties\ConvertLinkProperty.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Partial Classes\Properties\ConvertSectionProfile.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Partial Classes\Properties\ConvertSpring.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Partial Classes\Properties\ConvertTendonProperty.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Partial Classes\Results\ConvertResultGlobal.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Partial Classes\Results\ConvertResultNodes.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Partial Classes\Results\ConvertResults.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Partial Classes\Results\ConvertResultSet1D.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Partial Classes\Results\ConvertResultSet2D.cs" />
<Compile Include="$(MSBuildThisFileDirectory)PartialClasses\Analysis\ConvertModelSettings.cs" />
<Compile Include="$(MSBuildThisFileDirectory)PartialClasses\Analysis\ConvertModel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)PartialClasses\Analysis\ConvertModelInfo.cs" />
<Compile Include="$(MSBuildThisFileDirectory)PartialClasses\Analysis\ConvertModelUnits.cs" />
<Compile Include="$(MSBuildThisFileDirectory)PartialClasses\Geometry\ConvertArea.cs" />
<Compile Include="$(MSBuildThisFileDirectory)PartialClasses\Geometry\ConvertBeam.cs" />
<Compile Include="$(MSBuildThisFileDirectory)PartialClasses\Geometry\ConvertBraces.cs" />
<Compile Include="$(MSBuildThisFileDirectory)PartialClasses\Geometry\ConvertBuiltElement.cs" />
<Compile Include="$(MSBuildThisFileDirectory)PartialClasses\Geometry\ConvertColumn.cs" />
<Compile Include="$(MSBuildThisFileDirectory)PartialClasses\Geometry\ConvertFloor.cs" />
<Compile Include="$(MSBuildThisFileDirectory)PartialClasses\Geometry\ConvertFrame.cs" />
<Compile Include="$(MSBuildThisFileDirectory)PartialClasses\Geometry\ConvertGridLines.cs" />
<Compile Include="$(MSBuildThisFileDirectory)PartialClasses\Geometry\ConvertLine.cs" />
<Compile Include="$(MSBuildThisFileDirectory)PartialClasses\Geometry\ConvertLinks.cs" />
<Compile Include="$(MSBuildThisFileDirectory)PartialClasses\Geometry\ConvertPier.cs" />
<Compile Include="$(MSBuildThisFileDirectory)PartialClasses\Geometry\ConvertPoint.cs" />
<Compile Include="$(MSBuildThisFileDirectory)PartialClasses\Geometry\ConvertSpandrel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)PartialClasses\Geometry\ConvertStories.cs" />
<Compile Include="$(MSBuildThisFileDirectory)PartialClasses\Geometry\ConvertTendon.cs" />
<Compile Include="$(MSBuildThisFileDirectory)PartialClasses\Geometry\ConvertWall.cs" />
<Compile Include="$(MSBuildThisFileDirectory)PartialClasses\Loading\ConvertLoadPattern.cs" />
<Compile Include="$(MSBuildThisFileDirectory)PartialClasses\Loading\Loading1DElements.cs" />
<Compile Include="$(MSBuildThisFileDirectory)PartialClasses\Loading\Loading2DElements.cs" />
<Compile Include="$(MSBuildThisFileDirectory)PartialClasses\Loading\LoadingNode.cs" />
<Compile Include="$(MSBuildThisFileDirectory)PartialClasses\Materials\ConvertMaterials.cs" />
<Compile Include="$(MSBuildThisFileDirectory)PartialClasses\Properties\Convert1DProperty.cs" />
<Compile Include="$(MSBuildThisFileDirectory)PartialClasses\Properties\Convert2DProperty.cs" />
<Compile Include="$(MSBuildThisFileDirectory)PartialClasses\Properties\Convert2DPropertyFloor.cs" />
<Compile Include="$(MSBuildThisFileDirectory)PartialClasses\Properties\Convert2DPropertyWall.cs" />
<Compile Include="$(MSBuildThisFileDirectory)PartialClasses\Properties\ConvertDiaphragm.cs" />
<Compile Include="$(MSBuildThisFileDirectory)PartialClasses\Properties\ConvertLinkProperty.cs" />
<Compile Include="$(MSBuildThisFileDirectory)PartialClasses\Properties\ConvertSectionProfile.cs" />
<Compile Include="$(MSBuildThisFileDirectory)PartialClasses\Properties\ConvertSpring.cs" />
<Compile Include="$(MSBuildThisFileDirectory)PartialClasses\Properties\ConvertTendonProperty.cs" />
<Compile Include="$(MSBuildThisFileDirectory)PartialClasses\Results\ConvertResultGlobal.cs" />
<Compile Include="$(MSBuildThisFileDirectory)PartialClasses\Results\ConvertResultNodes.cs" />
<Compile Include="$(MSBuildThisFileDirectory)PartialClasses\Results\ConvertResults.cs" />
<Compile Include="$(MSBuildThisFileDirectory)PartialClasses\Results\ConvertResultSet1D.cs" />
<Compile Include="$(MSBuildThisFileDirectory)PartialClasses\Results\ConvertResultSet2D.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Services\ToNativeScalingService.cs" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ protected DatabaseTableWrapper(cSapModel cSapModel, ToNativeScalingService toNat
this.toNativeScalingService = toNativeScalingService;
this.tableData = new List<string>(GetTableData());
}

private string[] GetTableData()
{
var tableData = Array.Empty<string>();
Expand All @@ -39,7 +40,9 @@ protected void AddRow(params string[] arguments)
{
if (arguments.Length != fieldKeysIncluded.Length)
{
throw new ArgumentException($"Method {nameof(AddRow)} was passed an array of length {arguments.Length}, but was expecting an array of length {fieldKeysIncluded.Length}");
throw new ArgumentException(
$"Method {nameof(AddRow)} was passed an array of length {arguments.Length}, but was expecting an array of length {fieldKeysIncluded.Length}"
);
}
tableData.AddRange(arguments);
numRecords++;
Expand All @@ -48,14 +51,27 @@ protected void AddRow(params string[] arguments)
public void ApplyEditedTables()
{
var tableDataArray = tableData.ToArray();
cSapModel.DatabaseTables.SetTableForEditingArray(TableKey, ref tableVersion, ref fieldKeysIncluded, numRecords, ref tableDataArray);
cSapModel.DatabaseTables.SetTableForEditingArray(
TableKey,
ref tableVersion,
ref fieldKeysIncluded,
numRecords,
ref tableDataArray
);

int numFatalErrors = 0;
int numWarnMsgs = 0;
int numInfoMsgs = 0;
int numErrorMsgs = 0;
string importLog = "";
cSapModel.DatabaseTables.ApplyEditedTables(false, ref numFatalErrors, ref numErrorMsgs, ref numWarnMsgs, ref numInfoMsgs, ref importLog);
cSapModel.DatabaseTables.ApplyEditedTables(
false,
ref numFatalErrors,
ref numErrorMsgs,
ref numWarnMsgs,
ref numInfoMsgs,
ref importLog
);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,23 @@ internal class ETABSGridLineDefinitionTable : DatabaseTableWrapper
{
private const double gridTolerance = .001; // .05 degrees as radians
public override string TableKey => "Grid Definitions - Grid Lines";
public static string?[] DefaultRow => new string?[] {
null, // Name : Grid System name
null, // LineType
null, // Id : Grid name
null, // Ordinate : Offset in the positive direction
null, // Angle : clockwise offset in degrees for polar (cylindrical) coordinates
null, // X1
null, // Y1
null, // X2
null, // Y2
"Start", // BubbleLoc
"Yes", // Visible
};
public ETABSGridLineDefinitionTable(cSapModel cSapModel, ToNativeScalingService toNativeScalingService)
public static string?[] DefaultRow =>
new string?[]
{
null, // Name : Grid System name
null, // LineType
null, // Id : Grid name
null, // Ordinate : Offset in the positive direction
null, // Angle : clockwise offset in degrees for polar (cylindrical) coordinates
null, // X1
null, // Y1
null, // X2
null, // Y2
"Start", // BubbleLoc
"Yes", // Visible
};

public ETABSGridLineDefinitionTable(cSapModel cSapModel, ToNativeScalingService toNativeScalingService)
: base(cSapModel, toNativeScalingService) { }

public const string XGridLineType = "X (Cartesian)";
Expand All @@ -47,9 +50,9 @@ public ETABSGridLineDefinitionTable(cSapModel cSapModel, ToNativeScalingService
/// <param name="visible"></param>
/// <exception cref="ArgumentException"></exception>
public void AddCartesian(
string gridSystemName,
string gridLineType,
string gridName,
string gridSystemName,
string gridLineType,
string gridName,
double location,
string visible = "Yes"
)
Expand Down Expand Up @@ -102,18 +105,24 @@ public void AddCartesian(GridLine gridLine)
if (newUx < gridTolerance)
{
lineType = XGridLineType;
gridLineOffset = toNativeScalingService
.ScaleLength(transformedLine.start.x, transformedLine.units ?? transformedLine.start.units);
gridLineOffset = toNativeScalingService.ScaleLength(
transformedLine.start.x,
transformedLine.units ?? transformedLine.start.units
);
}
else if (newUy < gridTolerance)
{
lineType = YGridLineType;
gridLineOffset = toNativeScalingService
.ScaleLength(transformedLine.start.y, transformedLine.units ?? transformedLine.start.units);
gridLineOffset = toNativeScalingService.ScaleLength(
transformedLine.start.y,
transformedLine.units ?? transformedLine.start.units
);
}
else
{
throw new SpeckleException($"Error in transforming line from global coordinates to grid system with rotation {gridSystem.Rotation} and x,y offsets {gridSystem.XOrigin}, {gridSystem.YOrigin}");
throw new SpeckleException(
$"Error in transforming line from global coordinates to grid system with rotation {gridSystem.Rotation} and x,y offsets {gridSystem.XOrigin}, {gridSystem.YOrigin}"
);
}

AddCartesian(gridSystem.Name, lineType, gridLine.label, gridLineOffset);
Expand All @@ -137,7 +146,7 @@ private static double GetAngleOffsetFromGlobalCoordinateSystem(Line line)
}

/// <summary>
/// Find a GridSystem in the CSi model whose local x axis is either parallel or perpendicular to the provided
/// Find a GridSystem in the CSi model whose local x axis is either parallel or perpendicular to the provided
/// grid angle.
/// </summary>
/// <param name="gridRotation">Rotation counter-clockwise from the global x axis in radians</param>
Expand Down Expand Up @@ -198,7 +207,7 @@ private string GetUniqueGridSystemName()
var gridSystemNamePrefix = "SpeckleGridSystem";
foreach (var gridSysName in gridSysNames)
{
// test if this grid system is one that we already created. If it is, then we need to adjust our
// test if this grid system is one that we already created. If it is, then we need to adjust our
// numberOfGridSystems so that if we do end up creating a new one, it doesn't override an existing one.
if (!gridSysName.StartsWith(gridSystemNamePrefix))
{
Expand All @@ -210,18 +219,31 @@ private string GetUniqueGridSystemName()
numberOfGridSystems = Math.Max(numberOfGridSystems, gridSysNum + 1);
}
}
return $"{gridSystemNamePrefix}{numberOfGridSystems}"; ;
return $"{gridSystemNamePrefix}{numberOfGridSystems}";
;
}

private static Transform GetTransformFromGridSystem(GridSystemRepresentation sys)
{
return new Transform(
new double[]
{
Math.Cos(sys.Rotation), -Math.Sin(sys.Rotation), 0, sys.XOrigin,
Math.Sin(sys.Rotation), Math.Cos(sys.Rotation), 0, sys.YOrigin,
0, 0, 1, 0,
0, 0, 0, 1
Math.Cos(sys.Rotation),
-Math.Sin(sys.Rotation),
0,
sys.XOrigin,
Math.Sin(sys.Rotation),
Math.Cos(sys.Rotation),
0,
sys.YOrigin,
0,
0,
1,
0,
0,
0,
0,
1
}
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public partial class ConverterCSI
{
private ETABSGridLineDefinitionTable gridLineDefinitionTable;
private ETABSGridLineDefinitionTable GridLineDefinitionTable => gridLineDefinitionTable ??= new(Model, new(Model));

public void GridLineToNative(GridLine gridline)
{
GridLineDefinitionTable.AddCartesian(gridline);
Expand Down

0 comments on commit 6e1d7b4

Please sign in to comment.