09f9b1ee51
* Bjorn/cnx 1359 have a setting in UI whether include or not (#646) * feat(revit): linked model settings * docs: cache invalidation note * Feat(revit): linked models POC (#656) * cleanup on RefreshElementsIdsOnSender * POC for multiple and copied linked models * fix render materials for copied linked models * comment * comment * split linked models with collections * style: ci potential null on key * style: not null --------- Co-authored-by: Björn <steinhagen.bjoern@gmail.com> * feat(revit): sending linked model poc round two (#657) * Added IFC app name (#648) * test: add tests for threadcontext (#651) * add tests for threadcontext * add test for extensions * remove needed usage * fix for looking for model store (#654) Co-authored-by: Oğuzhan Koral <45078678+oguzhankoral@users.noreply.github.com> * test: Send Operation tests (#652) * add tests for threadcontext * add test for extensions * remove needed usage * move cancellation * Only add send operation tests --------- Co-authored-by: Oğuzhan Koral <45078678+oguzhankoral@users.noreply.github.com> * chore (autocad/civil): add regen after receive (#650) * regenerates doc * moves regen to receive base binding * Update AutocadReceiveBaseBinding.cs * feat: linked model send responsive to ui - current throw just a placeholder - small variable name refactor * fix: object reference not set to an instance of an object * fix: display value extractor * refactor: converterSettings as readonly field * feat: warning in response to ui setting not enabled * docs: todos etc. * Revert "Merge branch 'dev' into bjorn/cnx-1360-get-linked-models-on-send-function-according-to-setting" This reverts commit7202058a98, reversing changes made to4bc9ec2352. --------- Co-authored-by: Jedd Morgan <45512892+JR-Morgan@users.noreply.github.com> Co-authored-by: Adam Hathcock <adamhathcock@users.noreply.github.com> Co-authored-by: Oğuzhan Koral <45078678+oguzhankoral@users.noreply.github.com> Co-authored-by: Claire Kuang <kuang.claire@gmail.com> * fix: transform needed to be inversed (#659) * feat(revit): linked models send by category (#666) * docs: notes on collection filtering * feature: RevitCategoriesFilter with linked models too poc * docs: notes * feat(revit): commit structure (#675) * feat: collection structure switch - poc - if linked models, send nested - if not linked, send flat * docs: comments on updates * docs: comment on exception swallowing * fix: nullability * refactor: linked model helper class and refactor (#682) * fix: premature processing of linked models - add early check for linked models setting - skips expensive element collection for linked models when disabled - add empty document contexts for linked models when disabled to maintain warning generation (HACK) - improve code readability with clearer variable names and comments * refactor: category ids outside of linked model processing - inefficient to repeat for every document * fix: improve separation of concerns for linked model handling - extract linked model processing to a dedicated method - add IsLinkedDocument flag to DocumentToConvert class - move linked model warning generation to RevitRootObjectBuilder - make RevitSendBinding responsible only for element collection * refactor: dedicated LinkedModelHandler class for linked model processing - extract linked model element collection logic to a separate class - improve separation of concerns between flow control and element collection - add clear documentation explaining the responsibility boundaries * fix: duplicate if check still floating around * docs: over-explaining myself * Fix(revit): do not use converter settings in element unpacker (#687) * fix resetting the selected object ids after collecting the elements * Pass document to element unpacker for the sake of linked models * fix: send by categories mode --------- Co-authored-by: Björn <steinhagen.bjoern@gmail.com> * fix(revit): handle multiple linked model instances with transform hashing (#688) * feat: linked model transform caching in RevitRootObjectBuilder Add transform-specific hashing to properly handle multiple instances of the same linked model. Uses transform properties to create a unique suffix for the applicationId, preventing cached objects from being incorrectly reused across different transform contexts. * more comments --------- Co-authored-by: oguzhankoral <oguzhankoral@gmail.com> * fix: handle null elements when unpacking linked model groups - add null element check before GroupBy in ElementUnpacker to prevent NullReferenceException - improve robustness when processing groups in linked models - add documentation explaining linked model element handling throughout UnpackElements method - edge case where group member elements might not resolve properly in linked contexts * make linked model setting true by default * Fix(revit): illegal attempt to modify document (#700) * Run refresh object ids in revit task * Proper not null * await instead .result * feat(revit): collection structure for multiple linked model instances (#701) * feat: suffix for instances of linked model * Extract out GetIdFromDocumentToConvert --------- Co-authored-by: oguzhankoral <oguzhankoral@gmail.com> * Correct receive default setting for linked models even if irrevelant * Fix post conflict * Cleanup the code * Add comment --------- Co-authored-by: Björn Steinhagen <steinhagen.bjoern@gmail.com> Co-authored-by: oguzhankoral <oguzhankoral@gmail.com> Co-authored-by: Oğuzhan Koral <45078678+oguzhankoral@users.noreply.github.com> Co-authored-by: Jedd Morgan <45512892+JR-Morgan@users.noreply.github.com> Co-authored-by: Adam Hathcock <adamhathcock@users.noreply.github.com> Co-authored-by: Claire Kuang <kuang.claire@gmail.com>
85 lines
3.1 KiB
C#
85 lines
3.1 KiB
C#
using FluentAssertions;
|
|
using NUnit.Framework;
|
|
using Speckle.Converters.Common;
|
|
using Speckle.Converters.Common.Objects;
|
|
using Speckle.Converters.RevitShared.Raw;
|
|
using Speckle.Converters.RevitShared.Services;
|
|
using Speckle.Converters.RevitShared.Settings;
|
|
using Speckle.Objects;
|
|
using Speckle.Sdk.Common.Exceptions;
|
|
using Speckle.Testing;
|
|
|
|
namespace Speckle.Converters.Revit2023.Tests;
|
|
|
|
public class ModelCurveArrayToSpeckleConverterTests : MoqTest
|
|
{
|
|
[Test]
|
|
public void Convert_Empty()
|
|
{
|
|
var revitConversionContextStack = Create<IConverterSettingsStore<RevitConversionSettings>>();
|
|
var scalingServiceToSpeckle = Create<IScalingServiceToSpeckle>();
|
|
var curveConverter = Create<ITypedConverter<DB.Curve, ICurve>>();
|
|
|
|
var sut = new ModelCurveArrayToSpeckleConverter(
|
|
revitConversionContextStack.Object,
|
|
scalingServiceToSpeckle.Object,
|
|
curveConverter.Object
|
|
);
|
|
var array = Create<DB.ModelCurveArray>();
|
|
array.Setup(x => x.GetEnumerator()).Returns(Enumerable.Empty<object>().GetEnumerator());
|
|
Assert.Throws<ValidationException>(() => sut.Convert(array.Object));
|
|
}
|
|
|
|
[Test]
|
|
public void Convert()
|
|
{
|
|
var revitConversionContextStack = Create<IConverterSettingsStore<RevitConversionSettings>>();
|
|
var scalingServiceToSpeckle = Create<IScalingServiceToSpeckle>();
|
|
var curveConverter = Create<ITypedConverter<DB.Curve, ICurve>>();
|
|
|
|
var endpoint1 = Create<DB.XYZ>();
|
|
var geometry1 = Create<DB.Curve>();
|
|
var curve1 = Create<DB.ModelCurve>();
|
|
curve1.Setup(x => x.GeometryCurve).Returns(geometry1.Object);
|
|
geometry1.Setup(x => x.Length).Returns(2);
|
|
geometry1.Setup(x => x.GetEndPoint(0)).Returns(endpoint1.Object);
|
|
|
|
var endpoint2 = Create<DB.XYZ>();
|
|
var geometry2 = Create<DB.Curve>();
|
|
var curve2 = Create<DB.ModelCurve>();
|
|
curve2.Setup(x => x.GeometryCurve).Returns(geometry2.Object);
|
|
geometry2.Setup(x => x.Length).Returns(3);
|
|
geometry2.Setup(x => x.GetEndPoint(1)).Returns(endpoint2.Object);
|
|
|
|
var units = "units";
|
|
revitConversionContextStack
|
|
.Setup(x => x.Current)
|
|
.Returns(new RevitConversionSettings(null!, DetailLevelType.Coarse, null, units, false, false));
|
|
|
|
var scaleLength = 2.2;
|
|
scalingServiceToSpeckle.Setup(x => x.ScaleLength(2 + 3)).Returns(scaleLength);
|
|
|
|
endpoint1.Setup(x => x.DistanceTo(endpoint2.Object)).Returns(4.4);
|
|
|
|
curveConverter.Setup(x => x.Convert(geometry1.Object)).Returns(Create<ICurve>().Object);
|
|
curveConverter.Setup(x => x.Convert(geometry2.Object)).Returns(Create<ICurve>().Object);
|
|
|
|
var sut = new ModelCurveArrayToSpeckleConverter(
|
|
revitConversionContextStack.Object,
|
|
scalingServiceToSpeckle.Object,
|
|
curveConverter.Object
|
|
);
|
|
var array = Create<DB.ModelCurveArray>();
|
|
|
|
array
|
|
.Setup(x => x.GetEnumerator())
|
|
.Returns(new List<DB.ModelCurve> { curve1.Object, curve2.Object }.GetEnumerator());
|
|
var polycurve = sut.Convert(array.Object);
|
|
|
|
polycurve.units.Should().Be(units);
|
|
polycurve.closed.Should().BeFalse();
|
|
polycurve.length.Should().Be(scaleLength);
|
|
polycurve.segments.Count.Should().Be(2);
|
|
}
|
|
}
|