Skip to content

Commit

Permalink
adds missing autocad converters
Browse files Browse the repository at this point in the history
  • Loading branch information
clairekuang committed Jul 1, 2024
1 parent 2a1c601 commit d2eef5e
Show file tree
Hide file tree
Showing 18 changed files with 420 additions and 313 deletions.
74 changes: 37 additions & 37 deletions All.sln
Original file line number Diff line number Diff line change
Expand Up @@ -563,15 +563,15 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Connectors.Civil3d2
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Autocad2024", "DUI3-DX\Converters\Autocad\Speckle.Converters.Autocad2024\Speckle.Converters.Autocad2024.csproj", "{C9C28F31-1367-438C-83B0-049C3B3A3E3B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Autocad2024.DependencyInjection", "DUI3-DX\Converters\Autocad\Speckle.Converters.Autocad2024.DependencyInjection\Speckle.Converters.Autocad2024.DependencyInjection.csproj", "{06082BAA-98E8-49B1-9D33-252B126A0561}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Civil3d", "Civil3d", "{34A6BB15-A030-4C5B-94B2-1A1DFE49334A}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Speckle.Converters.Civil3dShared", "DUI3-DX\Converters\Civil3d\Speckle.Converters.Civil3dShared\Speckle.Converters.Civil3dShared.shproj", "{35175682-DA83-4C0A-A49D-B191F5885D8E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Civil3d2024", "DUI3-DX\Converters\Civil3d\Speckle.Converters.Civil3d2024\Speckle.Converters.Civil3d2024.csproj", "{E7FA6A25-A224-4207-846B-75CE8236228D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Civil3d2024.DependencyInjection", "DUI3-DX\Converters\Civil3d\Speckle.Converters.Civil3d2024.DependencyInjection\Speckle.Converters.Civil3d2024.DependencyInjection.csproj", "{D6EBC116-8113-4F43-B5E5-35A3272D7ADE}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Civil3d2024.DependencyInjection", "DUI3-DX\Converters\Civil3d\Speckle.Converters.Civil3d2024.DependencyInjection\Speckle.Converters.Civil3d2024.DependencyInjection.csproj", "{9BCE88BA-1E01-44EE-BF9D-2CB906E63E34}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Autocad2024.DependencyInjection", "DUI3-DX\Converters\Autocad\Speckle.Converters.Autocad2024.DependencyInjection\Speckle.Converters.Autocad2024.DependencyInjection.csproj", "{2C587020-5F9F-40E1-8AF8-772FE3FC256A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -2871,22 +2871,6 @@ Global
{C9C28F31-1367-438C-83B0-049C3B3A3E3B}.Release|Any CPU.Build.0 = Release|Any CPU
{C9C28F31-1367-438C-83B0-049C3B3A3E3B}.Release|x64.ActiveCfg = Release|Any CPU
{C9C28F31-1367-438C-83B0-049C3B3A3E3B}.Release|x64.Build.0 = Release|Any CPU
{06082BAA-98E8-49B1-9D33-252B126A0561}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU
{06082BAA-98E8-49B1-9D33-252B126A0561}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU
{06082BAA-98E8-49B1-9D33-252B126A0561}.Debug Mac|x64.ActiveCfg = Debug|Any CPU
{06082BAA-98E8-49B1-9D33-252B126A0561}.Debug Mac|x64.Build.0 = Debug|Any CPU
{06082BAA-98E8-49B1-9D33-252B126A0561}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{06082BAA-98E8-49B1-9D33-252B126A0561}.Debug|Any CPU.Build.0 = Debug|Any CPU
{06082BAA-98E8-49B1-9D33-252B126A0561}.Debug|x64.ActiveCfg = Debug|Any CPU
{06082BAA-98E8-49B1-9D33-252B126A0561}.Debug|x64.Build.0 = Debug|Any CPU
{06082BAA-98E8-49B1-9D33-252B126A0561}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU
{06082BAA-98E8-49B1-9D33-252B126A0561}.Release Mac|Any CPU.Build.0 = Release|Any CPU
{06082BAA-98E8-49B1-9D33-252B126A0561}.Release Mac|x64.ActiveCfg = Release|Any CPU
{06082BAA-98E8-49B1-9D33-252B126A0561}.Release Mac|x64.Build.0 = Release|Any CPU
{06082BAA-98E8-49B1-9D33-252B126A0561}.Release|Any CPU.ActiveCfg = Release|Any CPU
{06082BAA-98E8-49B1-9D33-252B126A0561}.Release|Any CPU.Build.0 = Release|Any CPU
{06082BAA-98E8-49B1-9D33-252B126A0561}.Release|x64.ActiveCfg = Release|Any CPU
{06082BAA-98E8-49B1-9D33-252B126A0561}.Release|x64.Build.0 = Release|Any CPU
{E7FA6A25-A224-4207-846B-75CE8236228D}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU
{E7FA6A25-A224-4207-846B-75CE8236228D}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU
{E7FA6A25-A224-4207-846B-75CE8236228D}.Debug Mac|x64.ActiveCfg = Debug|Any CPU
Expand All @@ -2903,22 +2887,38 @@ Global
{E7FA6A25-A224-4207-846B-75CE8236228D}.Release|Any CPU.Build.0 = Release|Any CPU
{E7FA6A25-A224-4207-846B-75CE8236228D}.Release|x64.ActiveCfg = Release|Any CPU
{E7FA6A25-A224-4207-846B-75CE8236228D}.Release|x64.Build.0 = Release|Any CPU
{D6EBC116-8113-4F43-B5E5-35A3272D7ADE}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU
{D6EBC116-8113-4F43-B5E5-35A3272D7ADE}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU
{D6EBC116-8113-4F43-B5E5-35A3272D7ADE}.Debug Mac|x64.ActiveCfg = Debug|Any CPU
{D6EBC116-8113-4F43-B5E5-35A3272D7ADE}.Debug Mac|x64.Build.0 = Debug|Any CPU
{D6EBC116-8113-4F43-B5E5-35A3272D7ADE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D6EBC116-8113-4F43-B5E5-35A3272D7ADE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D6EBC116-8113-4F43-B5E5-35A3272D7ADE}.Debug|x64.ActiveCfg = Debug|Any CPU
{D6EBC116-8113-4F43-B5E5-35A3272D7ADE}.Debug|x64.Build.0 = Debug|Any CPU
{D6EBC116-8113-4F43-B5E5-35A3272D7ADE}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU
{D6EBC116-8113-4F43-B5E5-35A3272D7ADE}.Release Mac|Any CPU.Build.0 = Release|Any CPU
{D6EBC116-8113-4F43-B5E5-35A3272D7ADE}.Release Mac|x64.ActiveCfg = Release|Any CPU
{D6EBC116-8113-4F43-B5E5-35A3272D7ADE}.Release Mac|x64.Build.0 = Release|Any CPU
{D6EBC116-8113-4F43-B5E5-35A3272D7ADE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D6EBC116-8113-4F43-B5E5-35A3272D7ADE}.Release|Any CPU.Build.0 = Release|Any CPU
{D6EBC116-8113-4F43-B5E5-35A3272D7ADE}.Release|x64.ActiveCfg = Release|Any CPU
{D6EBC116-8113-4F43-B5E5-35A3272D7ADE}.Release|x64.Build.0 = Release|Any CPU
{9BCE88BA-1E01-44EE-BF9D-2CB906E63E34}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU
{9BCE88BA-1E01-44EE-BF9D-2CB906E63E34}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU
{9BCE88BA-1E01-44EE-BF9D-2CB906E63E34}.Debug Mac|x64.ActiveCfg = Debug|Any CPU
{9BCE88BA-1E01-44EE-BF9D-2CB906E63E34}.Debug Mac|x64.Build.0 = Debug|Any CPU
{9BCE88BA-1E01-44EE-BF9D-2CB906E63E34}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9BCE88BA-1E01-44EE-BF9D-2CB906E63E34}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9BCE88BA-1E01-44EE-BF9D-2CB906E63E34}.Debug|x64.ActiveCfg = Debug|Any CPU
{9BCE88BA-1E01-44EE-BF9D-2CB906E63E34}.Debug|x64.Build.0 = Debug|Any CPU
{9BCE88BA-1E01-44EE-BF9D-2CB906E63E34}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU
{9BCE88BA-1E01-44EE-BF9D-2CB906E63E34}.Release Mac|Any CPU.Build.0 = Release|Any CPU
{9BCE88BA-1E01-44EE-BF9D-2CB906E63E34}.Release Mac|x64.ActiveCfg = Release|Any CPU
{9BCE88BA-1E01-44EE-BF9D-2CB906E63E34}.Release Mac|x64.Build.0 = Release|Any CPU
{9BCE88BA-1E01-44EE-BF9D-2CB906E63E34}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9BCE88BA-1E01-44EE-BF9D-2CB906E63E34}.Release|Any CPU.Build.0 = Release|Any CPU
{9BCE88BA-1E01-44EE-BF9D-2CB906E63E34}.Release|x64.ActiveCfg = Release|Any CPU
{9BCE88BA-1E01-44EE-BF9D-2CB906E63E34}.Release|x64.Build.0 = Release|Any CPU
{2C587020-5F9F-40E1-8AF8-772FE3FC256A}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU
{2C587020-5F9F-40E1-8AF8-772FE3FC256A}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU
{2C587020-5F9F-40E1-8AF8-772FE3FC256A}.Debug Mac|x64.ActiveCfg = Debug|Any CPU
{2C587020-5F9F-40E1-8AF8-772FE3FC256A}.Debug Mac|x64.Build.0 = Debug|Any CPU
{2C587020-5F9F-40E1-8AF8-772FE3FC256A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2C587020-5F9F-40E1-8AF8-772FE3FC256A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2C587020-5F9F-40E1-8AF8-772FE3FC256A}.Debug|x64.ActiveCfg = Debug|Any CPU
{2C587020-5F9F-40E1-8AF8-772FE3FC256A}.Debug|x64.Build.0 = Debug|Any CPU
{2C587020-5F9F-40E1-8AF8-772FE3FC256A}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU
{2C587020-5F9F-40E1-8AF8-772FE3FC256A}.Release Mac|Any CPU.Build.0 = Release|Any CPU
{2C587020-5F9F-40E1-8AF8-772FE3FC256A}.Release Mac|x64.ActiveCfg = Release|Any CPU
{2C587020-5F9F-40E1-8AF8-772FE3FC256A}.Release Mac|x64.Build.0 = Release|Any CPU
{2C587020-5F9F-40E1-8AF8-772FE3FC256A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2C587020-5F9F-40E1-8AF8-772FE3FC256A}.Release|Any CPU.Build.0 = Release|Any CPU
{2C587020-5F9F-40E1-8AF8-772FE3FC256A}.Release|x64.ActiveCfg = Release|Any CPU
{2C587020-5F9F-40E1-8AF8-772FE3FC256A}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -3134,11 +3134,11 @@ Global
{95E23A97-E5EA-4506-A52C-D3DA9012DA02} = {2E00592E-558D-492D-88F9-3ECEE4C0C7DA}
{DDBBA313-69A6-40DE-AB3A-79EE5BF32A7E} = {743489BF-1941-43D5-8AF9-35C56D0DCC34}
{C9C28F31-1367-438C-83B0-049C3B3A3E3B} = {804E065F-914C-414A-AF84-009312C3CFF6}
{06082BAA-98E8-49B1-9D33-252B126A0561} = {804E065F-914C-414A-AF84-009312C3CFF6}
{34A6BB15-A030-4C5B-94B2-1A1DFE49334A} = {1FE3C60E-7865-40A5-9794-55ECB64F6489}
{35175682-DA83-4C0A-A49D-B191F5885D8E} = {34A6BB15-A030-4C5B-94B2-1A1DFE49334A}
{E7FA6A25-A224-4207-846B-75CE8236228D} = {34A6BB15-A030-4C5B-94B2-1A1DFE49334A}
{D6EBC116-8113-4F43-B5E5-35A3272D7ADE} = {34A6BB15-A030-4C5B-94B2-1A1DFE49334A}
{9BCE88BA-1E01-44EE-BF9D-2CB906E63E34} = {34A6BB15-A030-4C5B-94B2-1A1DFE49334A}
{2C587020-5F9F-40E1-8AF8-772FE3FC256A} = {804E065F-914C-414A-AF84-009312C3CFF6}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {1D43D91B-4F01-4A78-8250-CC6F9BD93A14}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@
<Compile Include="$(MSBuildThisFileDirectory)ToHost\Geometry\PointToHostConverter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ToSpeckle\Geometry\ArcToSpeckleConverter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ToSpeckle\Geometry\Solid3dToSpeckleConverter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ToSpeckle\Raw\Solid3dToSpeckleRawConverter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ToSpeckle\Raw\DBArcToSpeckleRawConverter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ToSpeckle\Raw\DBCircleToSpeckleRawConverter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ToSpeckle\Raw\DBEllipseToSpeckleRawConverter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ToSpeckle\Raw\DBLineToSpeckleRawConverter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ToSpeckle\Raw\DBSolid3dToSpeckleRawConverter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ToSpeckle\Raw\DBCurveToSpeckleRawConverter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ToSpeckle\Geometry\CircleToSpeckleConverter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ToSpeckle\Geometry\EllipseToSpeckleConverter.cs" />
Expand All @@ -57,6 +61,7 @@
<Compile Include="$(MSBuildThisFileDirectory)ToSpeckle\Raw\LineSegment3dToSpeckleRawConverter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ToSpeckle\Raw\PlaneToSpeckleRawConverter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ToSpeckle\Raw\PointToSpeckleRawConverter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ToSpeckle\Raw\DBSplineToSpeckleRawConverter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ToSpeckle\Raw\VectorToSpeckleRawConverter.cs" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,55 +5,16 @@
namespace Speckle.Converters.Autocad.ToSpeckle.Geometry;

[NameAndRankValue(nameof(ADB.Arc), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
public class DBArcToSpeckleConverter : IToSpeckleTopLevelConverter, ITypedConverter<ADB.Arc, SOG.Arc>
public class DBArcToSpeckleConverter : IToSpeckleTopLevelConverter
{
private readonly ITypedConverter<AG.Point3d, SOG.Point> _pointConverter;
private readonly ITypedConverter<AG.Plane, SOG.Plane> _planeConverter;
private readonly ITypedConverter<ADB.Extents3d, SOG.Box> _boxConverter;
private readonly IConversionContextStack<Document, ADB.UnitsValue> _contextStack;
private readonly ITypedConverter<ADB.Arc, SOG.Arc> _arcConverter;

public DBArcToSpeckleConverter(
ITypedConverter<AG.Point3d, SOG.Point> pointConverter,
ITypedConverter<AG.Plane, SOG.Plane> planeConverter,
ITypedConverter<ADB.Extents3d, SOG.Box> boxConverter,
IConversionContextStack<Document, ADB.UnitsValue> contextStack
)
public DBArcToSpeckleConverter(ITypedConverter<ADB.Arc, SOG.Arc> arcConverter)
{
_pointConverter = pointConverter;
_planeConverter = planeConverter;
_boxConverter = boxConverter;
_contextStack = contextStack;
_arcConverter = arcConverter;
}

public Base Convert(object target) => Convert((ADB.Arc)target);

public SOG.Arc Convert(ADB.Arc target)
{
SOG.Plane plane = _planeConverter.Convert(target.GetPlane());
SOG.Point start = _pointConverter.Convert(target.StartPoint);
SOG.Point end = _pointConverter.Convert(target.EndPoint);
SOG.Point mid = _pointConverter.Convert(target.GetPointAtDist(target.Length / 2.0));
SOP.Interval domain = new(target.StartParam, target.EndParam);
SOG.Box bbox = _boxConverter.Convert(target.GeometricExtents);

SOG.Arc arc =
new(
plane,
target.Radius,
target.StartAngle,
target.EndAngle,
target.TotalAngle,
_contextStack.Current.SpeckleUnits
)
{
startPoint = start,
endPoint = end,
midPoint = mid,
domain = domain,
length = target.Length,
bbox = bbox
};

return arc;
}
public SOG.Arc Convert(ADB.Arc target) => _arcConverter.Convert(target);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,14 @@ namespace Speckle.Converters.Autocad.ToSpeckle.Geometry;
[NameAndRankValue(nameof(ADB.Circle), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
public class DBCircleToSpeckleConverter : IToSpeckleTopLevelConverter
{
private readonly ITypedConverter<AG.Plane, SOG.Plane> _planeConverter;
private readonly ITypedConverter<ADB.Extents3d, SOG.Box> _boxConverter;
private readonly IConversionContextStack<Document, ADB.UnitsValue> _contextStack;
private readonly ITypedConverter<ADB.Circle, SOG.Circle> _circleConverter;

public DBCircleToSpeckleConverter(
ITypedConverter<AG.Plane, SOG.Plane> planeConverter,
ITypedConverter<ADB.Extents3d, SOG.Box> boxConverter,
IConversionContextStack<Document, ADB.UnitsValue> contextStack
)
public DBCircleToSpeckleConverter(ITypedConverter<ADB.Circle, SOG.Circle> circleConverter)
{
_planeConverter = planeConverter;
_boxConverter = boxConverter;
_contextStack = contextStack;
_circleConverter = circleConverter;
}

public Base Convert(object target) => RawConvert((ADB.Circle)target);

public SOG.Circle RawConvert(ADB.Circle target)
{
SOG.Plane plane = _planeConverter.Convert(target.GetPlane());
SOG.Box bbox = _boxConverter.Convert(target.GeometricExtents);
SOG.Circle circle =
new(plane, target.Radius, _contextStack.Current.SpeckleUnits) { length = target.Circumference, bbox = bbox };

return circle;
}
public SOG.Circle RawConvert(ADB.Circle target) => _circleConverter.Convert(target);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,14 @@ namespace Speckle.Converters.Autocad.ToSpeckle.Geometry;
[NameAndRankValue(nameof(ADB.Ellipse), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
public class DBEllipseToSpeckleConverter : IToSpeckleTopLevelConverter
{
private readonly ITypedConverter<AG.Plane, SOG.Plane> _planeConverter;
private readonly ITypedConverter<ADB.Extents3d, SOG.Box> _boxConverter;
private readonly IConversionContextStack<Document, ADB.UnitsValue> _contextStack;
private readonly ITypedConverter<ADB.Ellipse, SOG.Ellipse> _ellipseConverter;

public DBEllipseToSpeckleConverter(
ITypedConverter<AG.Plane, SOG.Plane> planeConverter,
ITypedConverter<ADB.Extents3d, SOG.Box> boxConverter,
IConversionContextStack<Document, ADB.UnitsValue> contextStack
)
public DBEllipseToSpeckleConverter(ITypedConverter<ADB.Ellipse, SOG.Ellipse> ellipseConverter)
{
_planeConverter = planeConverter;
_boxConverter = boxConverter;
_contextStack = contextStack;
_ellipseConverter = ellipseConverter;
}

public Base Convert(object target) => RawConvert((ADB.Ellipse)target);

public SOG.Ellipse RawConvert(ADB.Ellipse target)
{
SOG.Plane plane = _planeConverter.Convert(new AG.Plane(target.Center, target.MajorAxis, target.MinorAxis));
SOG.Box bbox = _boxConverter.Convert(target.GeometricExtents);

// the start and end param corresponds to start and end angle in radians
SOP.Interval trim = new(target.StartAngle, target.EndAngle);

SOG.Ellipse ellipse =
new(plane, target.MajorRadius, target.MinorRadius, _contextStack.Current.SpeckleUnits)
{
domain = new(0, Math.PI * 2),
trimDomain = trim,
length = target.GetDistanceAtParameter(target.EndParam),
bbox = bbox
};

return ellipse;
}
public SOG.Ellipse RawConvert(ADB.Ellipse target) => _ellipseConverter.Convert(target);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,16 @@
namespace Speckle.Converters.Autocad.ToSpeckle.Geometry;

[NameAndRankValue(nameof(ADB.Line), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
public class LineToSpeckleConverter : IToSpeckleTopLevelConverter, ITypedConverter<ADB.Line, SOG.Line>
public class LineToSpeckleConverter : IToSpeckleTopLevelConverter
{
private readonly ITypedConverter<AG.Point3d, SOG.Point> _pointConverter;
private readonly ITypedConverter<ADB.Extents3d, SOG.Box> _boxConverter;
private readonly IConversionContextStack<Document, ADB.UnitsValue> _contextStack;
private readonly ITypedConverter<ADB.Line, SOG.Line> _lineConverter;

public LineToSpeckleConverter(
ITypedConverter<AG.Point3d, SOG.Point> pointConverter,
ITypedConverter<ADB.Extents3d, SOG.Box> boxConverter,
IConversionContextStack<Document, ADB.UnitsValue> contextStack
)
public LineToSpeckleConverter(ITypedConverter<ADB.Line, SOG.Line> lineConverter)
{
_pointConverter = pointConverter;
_boxConverter = boxConverter;
_contextStack = contextStack;
_lineConverter = lineConverter;
}

public Base Convert(object target) => Convert((ADB.Line)target);

public SOG.Line Convert(ADB.Line target) =>
new(
_pointConverter.Convert(target.StartPoint),
_pointConverter.Convert(target.EndPoint),
_contextStack.Current.SpeckleUnits
)
{
length = target.Length,
domain = new SOP.Interval(0, target.Length),
bbox = _boxConverter.Convert(target.GeometricExtents)
};
public SOG.Line Convert(ADB.Line target) => _lineConverter.Convert(target);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ namespace Speckle.Converters.Autocad.Geometry;
/// The IToSpeckleTopLevelConverter inheritance should only expect database-resident <see cref="ADB.Polyline2d"/> objects. IRawConversion inheritance can expect non database-resident objects, when generated from other converters.
/// </remarks>
[NameAndRankValue(nameof(ADB.Polyline2d), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
public class Polyline2dToSpeckleConverter : IToSpeckleTopLevelConverter
public class Polyline2dToSpeckleConverter
: IToSpeckleTopLevelConverter,
ITypedConverter<ADB.Polyline2d, SOG.Autocad.AutocadPolycurve>
{
private readonly ITypedConverter<ADB.Arc, SOG.Arc> _arcConverter;
private readonly ITypedConverter<ADB.Line, SOG.Line> _lineConverter;
Expand Down Expand Up @@ -44,9 +46,9 @@ public Polyline2dToSpeckleConverter(
_contextStack = contextStack;
}

public Base Convert(object target) => RawConvert((ADB.Polyline2d)target);
public Base Convert(object target) => Convert((ADB.Polyline2d)target);

public SOG.Autocad.AutocadPolycurve RawConvert(ADB.Polyline2d target)
public SOG.Autocad.AutocadPolycurve Convert(ADB.Polyline2d target)
{
// get the poly type
var polyType = SOG.Autocad.AutocadPolyType.Unknown;
Expand Down
Loading

0 comments on commit d2eef5e

Please sign in to comment.