Compare commits

..

8 Commits

Author SHA1 Message Date
Adam Hathcock b3f4190614 Merge pull request #260 from specklesystems/adam/fix-cancel-check
.NET Build and Publish / build (push) Has been cancelled
Cancellation check for sending needs to not be wrapped
2025-03-17 12:21:44 +00:00
Adam Hathcock 2fc0024cd2 Cancellation check for sending needs to not be wrapped 2025-03-17 12:08:42 +00:00
Adam Hathcock 300a5627fd Merge pull request #259 from specklesystems/revit-levels
.NET Build and Publish / build (push) Has been cancelled
feat(objects): adds level to revitobject
2025-03-17 11:06:13 +00:00
Claire Kuang 22f029fe33 Update RevitObject.cs 2025-03-17 10:32:47 +00:00
Claire Kuang c728266c88 Update RevitObject.cs 2025-03-17 10:31:43 +00:00
Claire Kuang 7f2d57cdad adds level 2025-03-17 10:05:41 +00:00
Adam Hathcock 4e84766be9 Merge pull request #253 from specklesystems/regions-PR-to-main
.NET Build and Publish / build (push) Has been cancelled
2025-03-12 17:55:01 +00:00
KatKatKateryna 73a95aded0 Regions class (#241)
* region class

* comments

* adjusted constructor

* todos

* comment

* change displayValur to curves

* small refactor

* assign correct property

* generalize display value

* some minor xml changes

* transform meshes; bbox not required

* remove comment

* Update Region.cs

---------

Co-Authored-By: Claire Kuang <kuang.claire@gmail.com>
Co-Authored-By: Adam Hathcock <adamhathcock@users.noreply.github.com>
2025-03-12 17:38:28 +00:00
3 changed files with 106 additions and 1 deletions
+7
View File
@@ -12,6 +12,13 @@ public class RevitObject : DataObject, IRevitObject
public required string family { get; set; }
public required string category { get; set; }
/// <summary>
/// The level constraint of the object.
/// For objects constrained by multiple levels, this represents the base constraint.
/// For objects with no level constraint, this should be null.
/// </summary>
public required string? level { get; set; }
/// <summary>
/// A Curve or Point object representing the location of a Revit element.
/// </summary>
+97
View File
@@ -0,0 +1,97 @@
using Speckle.Objects.Other;
using Speckle.Sdk.Common;
using Speckle.Sdk.Models;
namespace Speckle.Objects.Geometry;
/// <summary>
/// Flat polygon, defined by an outer boundary and inner loops.
/// </summary>
[SpeckleType("Objects.Geometry.Region")]
public class Region : Base, IHasArea, IHasBoundingBox, ITransformable, IDisplayValue<List<Mesh>>
{
/// <summary>
/// Boundary of a region.
/// Should be a planar, closed, non-self-intersecting ICurve.
/// </summary>
public required ICurve boundary { get; set; }
/// <summary>
/// Loops (voids) in the region.
/// Each loop should be planar, closed, non-self-intersecting ICurve, located inside the boundary.
/// The loops should not intersect or touch each other.
/// </summary>
public required List<ICurve> innerLoops { get; set; } = new();
/// <summary>
/// The units of object's coordinates.
/// This should be one of <see cref="Units"/>
/// </summary>
public required string units { get; set; }
/// <summary>
/// Indication whether the region is just a geometry (false) or has a hatch pattern (true).
/// It's a distinction for receiving in apps that support both Region and Hatch (aka region with hatch pattern)
/// </summary>
public required bool hasHatchPattern { get; set; }
/// <inheritdoc/>
public double area { get; set; }
/// <inheritdoc/>
public Box? bbox { get; set; }
/// <inheritdoc/>
[DetachProperty]
public List<Mesh> displayValue { get; set; } = new();
/// <inheritdoc/>
public bool TransformTo(Transform transform, out ITransformable transformed)
{
// assign self to the returned object, in case transformation fails
transformed = this;
// transform boundary
if (boundary is ITransformable boundaryTransformable)
{
boundaryTransformable.TransformTo(transform, out ITransformable transformedBoundaryResult);
var transformedBoundary = (ICurve)transformedBoundaryResult;
// transform inner loops
var transformedLoops = new List<ICurve>();
foreach (var loop in innerLoops)
{
if (loop is ITransformable loopTransformable)
{
loopTransformable.TransformTo(transform, out ITransformable transformedLoop);
transformedLoops.Add((ICurve)transformedLoop);
}
else
{
return false;
}
}
// transform display meshes
var transformedMeshes = new List<Mesh>();
foreach (var mesh in displayValue)
{
mesh.TransformTo(transform, out ITransformable transformedMesh);
transformedMeshes.Add((Mesh)transformedMesh);
}
// if boundary and loops transformations succeeded
transformed = new Region
{
boundary = transformedBoundary,
innerLoops = transformedLoops,
hasHatchPattern = hasHatchPattern,
displayValue = transformedMeshes,
units = units,
};
return true;
}
return false;
}
}
@@ -89,11 +89,12 @@ public sealed class SerializeProcess(
public void ThrowIfFailed()
{
//always check for cancellation first
cancellationToken.ThrowIfCancellationRequested();
if (Exception is not null)
{
throw new SpeckleException("Error while sending", Exception);
}
cancellationToken.ThrowIfCancellationRequested();
}
private async Task WaitForSchedulerCompletion()