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

Dogukan/cnx 691 extract appropriate class properties by type #352

Merged
Merged
Next Next commit
adds new properties
dogukankaratas committed Nov 5, 2024
commit 1d852008fbbde45da72a36fa546b4404ab8d60b3
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

namespace Speckle.Connector.Tekla2024.Plugin;

[Plugin("Speckle")]
[Plugin("Speckle (Beta)")]
[PluginUserInterface("Speckle.Connector.Tekla2024.SpeckleTeklaPanelHost")]
[InputObjectDependency(InputObjectDependency.NOT_DEPENDENT)] // See DevDocs/InputObjectDependency.NOT_DEPENDENT.png
public class TeklaPlugin : PluginBase
Original file line number Diff line number Diff line change
@@ -22,8 +22,8 @@ public class SpeckleTeklaPanelHost : PluginFormBase

public SpeckleTeklaPanelHost()
{
this.Text = "Speckle Beta";
this.Name = "Speckle Beta";
this.Text = "Speckle (Beta)";
this.Name = "Speckle (Beta)";
//TODO: Add Speckle icon
// TODO: Add thumbnail to connector
var services = new ServiceCollection();
Original file line number Diff line number Diff line change
@@ -7,14 +7,20 @@ namespace Speckle.Converter.Tekla2024.ToSpeckle.Helpers;
public sealed class DisplayValueExtractor
{
private readonly ITypedConverter<TSM.Solid, SOG.Mesh> _meshConverter;
private readonly ITypedConverter<TG.Point, SOG.Point> _pointConverter;
private readonly ITypedConverter<TG.LineSegment, SOG.Line> _lineConverter;
private readonly IConverterSettingsStore<TeklaConversionSettings> _settingsStore;

public DisplayValueExtractor(
ITypedConverter<TSM.Solid, SOG.Mesh> meshConverter,
ITypedConverter<TG.Point, SOG.Point> pointConverter,
ITypedConverter<TG.LineSegment, SOG.Line> lineConverter,
IConverterSettingsStore<TeklaConversionSettings> settingsStore
)
{
_meshConverter = meshConverter;
_pointConverter = pointConverter;
_lineConverter = lineConverter;
_settingsStore = settingsStore;
}

@@ -38,11 +44,23 @@ public IEnumerable<Base> GetDisplayValue(TSM.ModelObject modelObject)
}
break;

case TSM.Reinforcement reinforcement:
if (reinforcement.GetSolid() is TSM.Solid reinforcementSolid)
case TSM.SingleRebar singleRebar:
if (singleRebar.Polygon is TSM.Polygon rebarPolygon)
{
yield return _meshConverter.Convert(reinforcementSolid);
for (int i = 0; i < rebarPolygon.Points.Count - 1; i++)
{
var startPoint = (TG.Point)rebarPolygon.Points[i];
var endPoint = (TG.Point)rebarPolygon.Points[i + 1];
var line = new TG.LineSegment(startPoint, endPoint);

var speckleLine = _lineConverter.Convert(line);
speckleLine.start = _pointConverter.Convert(startPoint);
speckleLine.end = _pointConverter.Convert(endPoint);

yield return speckleLine;
}
}

break;

default:
Original file line number Diff line number Diff line change
@@ -16,8 +16,17 @@ public PropertyExtractor() { }
case TSM.ContourPlate plate:
AddContourPlateProperties(plate, properties);
break;
case TSM.BoltGroup boltGroup:
AddBoltGroupProperties(boltGroup, properties);
case TSM.BoltArray boltArray:
AddBoltArrayProperties(boltArray, properties);
break;
case TSM.SingleRebar singleRebar:
AddSingleRebarProperties(singleRebar, properties);
break;
case TSM.RebarMesh rebarMesh:
AddRebarMeshProperties(rebarMesh, properties);
break;
case TSM.RebarGroup rebarGroup:
AddRebarGroupProperties(rebarGroup, properties);
break;
}

@@ -28,19 +37,80 @@ private void AddBeamProperties(TSM.Beam beam, Dictionary<string, object?> proper
{
properties["profile"] = beam.Profile.ProfileString;
properties["material"] = beam.Material.MaterialString;
properties["class"] = beam.Class;

double volume = 0.0;
beam.GetReportProperty("VOLUME", ref volume);
double volumeCubic = volume / 1000000000.0; // converting to m3 from mm3

properties["volume(m3)"] = String.Format("{0:0.0000}", volumeCubic);

double weight = 0.0;
beam.GetReportProperty("WEIGHT", ref weight);

properties["weight(kg)"] = String.Format("{0:0.0000}", weight);
}

private void AddContourPlateProperties(TSM.ContourPlate plate, Dictionary<string, object?> properties)
{
properties["profile"] = plate.Profile.ProfileString;
properties["material"] = plate.Material.MaterialString;
properties["class"] = plate.Class;

double volume = 0.0;
plate.GetReportProperty("VOLUME", ref volume);
double volumeCubic = volume / 1000000000.0; // converting to m3 from mm3

properties["volume(m3)"] = String.Format("{0:0.0000}", volumeCubic);

double weight = 0.0;
plate.GetReportProperty("WEIGHT", ref weight);

properties["weight(kg)"] = String.Format("{0:0.0000}", weight);
}

private void AddBoltArrayProperties(TSM.BoltArray boltArray, Dictionary<string, object?> properties)
{
properties["boltSize"] = boltArray.BoltSize.ToString();
properties["boltCount"] = boltArray.BoltPositions.Count.ToString();
properties["boltStandard"] = boltArray.BoltStandard;
}

private void AddBoltGroupProperties(TSM.BoltGroup boltGroup, Dictionary<string, object?> properties)
private void AddSingleRebarProperties(TSM.SingleRebar singleRebar, Dictionary<string, object?> properties)
{
properties["boltSize"] = boltGroup.BoltSize;
properties["bolt"] = boltGroup.Bolt;
properties["grade"] = singleRebar.Grade;
properties["size"] = singleRebar.Size;

double volume = 0.0;
singleRebar.GetReportProperty("VOLUME", ref volume);
properties["volume(m3)"] = String.Format("{0:0.0000}", volume);

double weight = 0.0;
singleRebar.GetReportProperty("WEIGHT", ref weight);
properties["weight(kg)"] = String.Format("{0:0.0000}", weight);
}

private void AddRebarMeshProperties(TSM.RebarMesh rebarMesh, Dictionary<string, object?> properties)
{
properties["grade"] = rebarMesh.Grade;

double area = (rebarMesh.Width * rebarMesh.Length) / 100.0; // converting to cm2
properties["area(cm2)"] = String.Format("{0:0.0000}", area);

double weight = 0.0;
rebarMesh.GetReportProperty("WEIGHT", ref weight);
properties["weight(kg)"] = String.Format("{0:0.0000}", weight);
}

private void AddRebarGroupProperties(TSM.RebarGroup rebarGroup, Dictionary<string, object?> properties)
{
properties["grade"] = rebarGroup.Grade;
properties["size"] = rebarGroup.Size;

double volume = 0.0;
rebarGroup.GetReportProperty("VOLUME", ref volume);
properties["volume(m3)"] = String.Format("{0:0.0000}", volume);

double weight = 0.0;
rebarGroup.GetReportProperty("WEIGHT", ref weight);
properties["weight(kg)"] = String.Format("{0:0.0000}", weight);
}
}