Skip to content

Commit

Permalink
Merge branch '1.x' into pedro/1.x
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrocortesark authored Jan 9, 2025
2 parents 333bb10 + de3cc26 commit 7f17441
Show file tree
Hide file tree
Showing 31 changed files with 127 additions and 104 deletions.
File renamed without changes
File renamed without changes
4 changes: 4 additions & 0 deletions docs/pages/_en/1.0/reference/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ group: Deployment & Configs

{% include ltr/release_header_next.html title="Upcoming Changes" note=rc_release_notes %}

{% include ltr/release-header.html title="v1.28 RC2" version="v1.28.9133.21774" pre_release=true time="01/07/2025" %}

- Fix on {% include ltr/comp.html uuid='2beb60ba' %} component when updating element location.

{% include ltr/release-header.html title="v1.28 RC1" version="v1.28.9121.7332" pre_release=true time="12/21/2024" %}

- Miscellaneous Improvements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ internal static void SetLocation<T>(this T element, XYZ newOrigin, double newAng
// Set Origin
{
var translation = newOrigin - origin;
if (translation.IsZeroLength())
if (!translation.IsZeroLength())
{
if (element.Pinned) element.Pinned = false;
modified = true;
Expand Down
36 changes: 35 additions & 1 deletion src/RhinoInside.Revit.External/Extensions/RhinoCommon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ public PlanarBrepFace(BrepFace f)

public NurbsCurve Loop
{
get { if (Plane.IsValid && loop is null) loop = Curve.ProjectToPlane(Face.OuterLoop.To3dCurve()?.ToNurbsCurve(), Plane) as NurbsCurve; return loop; }
get { if (Plane.IsValid && loop is null) loop = Face.OuterLoop.To3dCurve()?.ToNurbsCurve().ProjectToPlane(Plane) as NurbsCurve; return loop; }
}
public Point3d Centroid
{
Expand Down Expand Up @@ -897,6 +897,40 @@ public static IEnumerable<double> Discontinuities(this Curve curve, Continuity c
while (curve.GetNextDiscontinuity(continuity, t, domain.T1, tol1, tol2, out t))
yield return t;
}

public static Curve ProjectToPlane(this Curve curve, Plane plane)
{
switch (curve)
{
case null:
return null;

case LineCurve line:
line = line.DuplicateCurve() as LineCurve;
line.SetStartPoint(plane.ClosestPoint(line.PointAtStart));
line.SetEndPoint(plane.ClosestPoint(line.PointAtEnd));
return line;

case PolylineCurve polyline:
polyline = polyline.DuplicateCurve() as PolylineCurve;
for(int p = 0; p < polyline.PointCount; ++p)
polyline.SetPoint(p, plane.ClosestPoint(polyline.Point(p)));
return polyline;

case ArcCurve arc:

if (arc.Arc.Plane.Normal.EpsilonEquals(plane.Normal, RhinoMath.Epsilon))
{
arc = arc.DuplicateCurve() as ArcCurve;
arc.Translate(plane.ClosestPoint(arc.Arc.Plane.Origin) - arc.Arc.Plane.Origin);
return arc;
}
else return Curve.ProjectToPlane(curve?.ToNurbsCurve(), plane);

default:
return Curve.ProjectToPlane(curve?.ToNurbsCurve(), plane);
}
}
}

static class SurfaceExtension
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ protected override void TrySolveInstance(IGH_DataAccess DA)
var plane = view.DetailPlane;
var tol = GeometryTolerance.Model;

if (Curve.ProjectToPlane(curve.ToNurbsCurve(), plane) is Curve projectedCurve)
if (curve.ProjectToPlane(plane) is Curve projectedCurve)
curve = projectedCurve;
else
throw new Exceptions.RuntimeArgumentException("Curve", "Failed to project 'Curve' into view plane", curve);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ protected override void TrySolveInstance(IGH_DataAccess DA)
throw new Exceptions.RuntimeArgumentException("Boundary", "Curve should be a valid planar, closed curve and parallel to the input view.", loop);
}

loops = loops.Select(x => Curve.ProjectToPlane(x, viewPlane)).ToArray();
loops = loops.Select(x => x.ProjectToPlane(viewPlane)).ToArray();

// Compute
region = Reconstruct
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ protected override void TrySolveInstance(IGH_DataAccess DA)
throw new Exceptions.RuntimeArgumentException("Boundary", "Curve should be a valid planar, closed curve and perperdicular to the input view.", loop);
}

loops = loops.Select(x => Curve.ProjectToPlane(x, viewPlane)).ToArray();
loops = loops.Select(x => x.ProjectToPlane(viewPlane)).ToArray();

if (revision is null)
{
Expand Down
12 changes: 2 additions & 10 deletions src/RhinoInside.Revit.GH/Components/Annotations/AddSymbol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,17 +142,9 @@ ARDB.AnnotationSymbolType type
if (detail is null) return false;

if (detail.OwnerViewId != view.Id) return false;
if (detail.GetTypeId() != type.Id)
{
if (ARDB.Element.IsValidType(detail.Document, new ARDB.ElementId[] { detail.Id }, type.Id))
{
if (detail.ChangeTypeId(type.Id) is ARDB.ElementId id && id != ARDB.ElementId.InvalidElementId)
detail = detail.Document.GetElement(id) as ARDB.AnnotationSymbol;
}
else return false;
}
if (detail.GetTypeId() != type.Id) detail.ChangeTypeId(type.Id);

return false;
return true;
}

ARDB.AnnotationSymbol Create(ARDB.View view, ARDB.XYZ point, ARDB.AnnotationSymbolType type)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ protected override void TrySolveInstance(IGH_DataAccess DA)
var tol = GeometryTolerance.Model;
var axisPlane = sketchPlane.Location;

curve = Curve.ProjectToPlane(curve, axisPlane);
curve = curve.ProjectToPlane(axisPlane);
if (curve is null) throw new RuntimeArgumentException("Curve", "Failed to project Curve on to Work Plane.", curve);

curve = curve.ToArcsAndLines(tol.VertexTolerance, 10.0 * tol.AngleTolerance, tol.ShortCurveTolerance, 0.0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ protected override void TrySolveInstance(IGH_DataAccess DA)
if (!curve.IsParallelToPlane(plane, tol.VertexTolerance, tol.AngleTolerance))
throw new Exceptions.RuntimeArgumentException("Curve", $"Curve should be planar and parallel to view plane.\nTolerance is {Rhino.RhinoMath.ToDegrees(tol.AngleTolerance):N1}°", curve);

if ((curve = Curve.ProjectToPlane(curve, plane)) is null)
if ((curve = curve.ProjectToPlane(plane)) is null)
throw new Exceptions.RuntimeArgumentException("Curve", "Failed to project Curve into 'Work Plane'", curve);

if (curve.IsClosed || curve.PointAtStart.DistanceTo(curve.PointAtEnd) < tol.VertexTolerance)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ protected override void TrySolveInstance(IGH_DataAccess DA)

foreach (var profile in profiles.OfType<Curve>())
{
var loop = Curve.ProjectToPlane(profile, projectionPlane);
var loop = profile.ProjectToPlane(projectionPlane);

var segments = loop.TryGetPolyCurve(out var polyCurve, tol.AngleTolerance) ?
polyCurve.DuplicateSegments() : new Curve[] { loop };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ ARDB.Opening Reconstruct(ARDB.Opening opening, ARDB.Document doc, ARDB.HostObjec
{
var hostPlane = sketch.SketchPlane.GetPlane().ToPlane();
normal = hostPlane.Normal;
boundary = boundary.Select(x => Curve.ProjectToPlane(x, hostPlane)).ToArray();
boundary = boundary.Select(x => x.ProjectToPlane(hostPlane)).ToArray();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ [Optional] bool flipped
new Point3d(0.0, 0.0, level.Value.GetElevation() * GeometryDecoder.ModelScaleFactor),
Vector3d.ZAxis
);
curve = Curve.ProjectToPlane(curve, levelPlane);
curve = curve.ProjectToPlane(levelPlane);
curve = curve.Simplify(CurveSimplifyOptions.All & ~CurveSimplifyOptions.Merge, tol.VertexTolerance, tol.AngleTolerance) ?? curve;

// Type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ namespace RhinoInside.Revit.GH.Components.Families
using Convert.Geometry;
using External.DB.Extensions;
using Kernel.Attributes;
using ERDB = External.DB;

public class FormByGeometry : ReconstructElementComponent
public class AddForm : ReconstructElementComponent
{
public override Guid ComponentGuid => new Guid("D2FDF2A0-1E48-4075-814A-685D91A6CD94");
public override GH_Exposure Exposure => GH_Exposure.quarternary;

public FormByGeometry() : base
public AddForm() : base
(
name: "Add Form",
nickname: "Form",
Expand All @@ -26,7 +27,17 @@ public FormByGeometry() : base
)
{ }

void ReconstructFormByGeometry
static readonly ARDB.BuiltInParameter[] ExcludeUniqueProperties =
{
ARDB.BuiltInParameter.IS_VISIBLE_PARAM,
ARDB.BuiltInParameter.GEOM_VISIBILITY_PARAM,
ARDB.BuiltInParameter.MATERIAL_ID_PARAM,
ARDB.BuiltInParameter.FAMILY_ELEM_SUBCATEGORY,
ARDB.BuiltInParameter.ELEMENT_IS_CUTTING,
ARDB.BuiltInParameter.OFFSETFACES_SHOW_SHAPE_HANDLES,
};

void ReconstructAddForm
(
[Optional, NickName("DOC")]
ARDB.Document document,
Expand Down Expand Up @@ -55,16 +66,14 @@ Brep brep
foreach (var curve in brep.Faces[0].OuterLoop.To3dCurve().ToCurveMany())
referenceArray.Append(new ARDB.Reference(document.FamilyCreate.NewModelCurve(curve, sketchPlane)));

ReplaceElement
(
ref form,
document.FamilyCreate.NewFormByCap
(
!cutting,
referenceArray
)
);
ReplaceElement(ref form, document.FamilyCreate.NewFormByCap(!cutting, referenceArray), ExcludeUniqueProperties);

form.get_Parameter(ARDB.BuiltInParameter.IS_VISIBLE_PARAM)?.Update(true);
form.get_Parameter(ARDB.BuiltInParameter.GEOM_VISIBILITY_PARAM).Update(ERDB.FamilyElementVisibility.DefaultModel);
form.get_Parameter(ARDB.BuiltInParameter.MATERIAL_ID_PARAM)?.Update(ElementIdExtension.Invalid);
form.get_Parameter(ARDB.BuiltInParameter.FAMILY_ELEM_SUBCATEGORY)?.Update(ElementIdExtension.Invalid);
form.get_Parameter(ARDB.BuiltInParameter.ELEMENT_IS_CUTTING)?.Update(0);
form.get_Parameter(ARDB.BuiltInParameter.OFFSETFACES_SHOW_SHAPE_HANDLES)?.Update(true);
return;
}
catch (Autodesk.Revit.Exceptions.InvalidOperationException)
Expand All @@ -73,37 +82,6 @@ Brep brep
}
}
}
else if (document.OwnerFamily.IsConceptualMassFamily)
{
if (brep.TryGetExtrusion(out var extrusion) && (extrusion.CapCount == 2 || !extrusion.IsClosed(0)))
{
using (var sketchPlane = ARDB.SketchPlane.Create(document, extrusion.GetProfilePlane(0.0).ToPlane()))
using (var referenceArray = new ARDB.ReferenceArray())
{
try
{
foreach (var curve in extrusion.Profile3d(new ComponentIndex(ComponentIndexType.ExtrusionBottomProfile, 0)).ToCurveMany())
referenceArray.Append(new ARDB.Reference(document.FamilyCreate.NewModelCurve(curve, sketchPlane)));

ReplaceElement
(
ref form,
document.FamilyCreate.NewExtrusionForm
(
!cutting,
referenceArray,
extrusion.PathLineCurve().Line.Direction.ToXYZ(GeometryEncoder.ModelScaleFactor)
)
);
return;
}
catch (Autodesk.Revit.Exceptions.InvalidOperationException)
{
document.Delete(referenceArray.OfType<ARDB.Reference>().Select(x => x.ElementId).ToArray());
}
}
}
}
}

// Else we try with a DB.FreeFormElement
Expand All @@ -112,22 +90,19 @@ Brep brep
ctx.RuntimeMessage = (severity, message, invalidGeometry) =>
AddGeometryConversionError((GH_RuntimeMessageLevel) severity, message, invalidGeometry);

var solid = brep.ToSolid();
if (solid != null)
if (brep.ToSolid() is ARDB.Solid solid)
{
if (form is ARDB.FreeFormElement freeFormElement)
{
freeFormElement.UpdateSolidGeometry(solid);
}
else
{
ReplaceElement(ref form, ARDB.FreeFormElement.Create(document, solid));

if (document.OwnerFamily.IsConceptualMassFamily)
form.get_Parameter(ARDB.BuiltInParameter.FAMILY_ELEM_SUBCATEGORY).Update(new ARDB.ElementId(ARDB.BuiltInCategory.OST_MassForm));
}
ReplaceElement(ref form, ARDB.FreeFormElement.Create(document, solid), ExcludeUniqueProperties);

form.get_Parameter(ARDB.BuiltInParameter.ELEMENT_IS_CUTTING)?.Update(cutting ? 1 : 0);
form.get_Parameter(ARDB.BuiltInParameter.IS_VISIBLE_PARAM)?.Update(true);
form.get_Parameter(ARDB.BuiltInParameter.GEOM_VISIBILITY_PARAM).Update(ERDB.FamilyElementVisibility.DefaultModel);
form.get_Parameter(ARDB.BuiltInParameter.MATERIAL_ID_PARAM)?.Update(ElementIdExtension.Invalid);
form.get_Parameter(ARDB.BuiltInParameter.FAMILY_ELEM_SUBCATEGORY)?.Update(ElementIdExtension.Invalid);
form.get_Parameter(ARDB.BuiltInParameter.ELEMENT_IS_CUTTING)?.Update(0);
form.get_Parameter(ARDB.BuiltInParameter.OFFSETFACES_SHOW_SHAPE_HANDLES)?.Update(true);
}
else AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Failed to convert Brep to Form");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ namespace RhinoInside.Revit.GH.Components.Families
using Convert.Geometry;
using Kernel.Attributes;
using External.DB.Extensions;
using ERDB = External.DB;

public class FormByCurves : ReconstructElementComponent
public class AddMassLoft : ReconstructElementComponent
{
public override Guid ComponentGuid => new Guid("42631B6E-505E-4091-981A-E7605AE5A1FF");
public override GH_Exposure Exposure => GH_Exposure.quarternary;

public FormByCurves() : base
public AddMassLoft() : base
(
name: "Add Mass Loft",
nickname: "MassLoft",
Expand All @@ -25,7 +26,17 @@ public FormByCurves() : base
)
{ }

void ReconstructFormByCurves
static readonly ARDB.BuiltInParameter[] ExcludeUniqueProperties =
{
ARDB.BuiltInParameter.IS_VISIBLE_PARAM,
ARDB.BuiltInParameter.GEOM_VISIBILITY_PARAM,
ARDB.BuiltInParameter.MATERIAL_ID_PARAM,
ARDB.BuiltInParameter.FAMILY_ELEM_SUBCATEGORY,
ARDB.BuiltInParameter.ELEMENT_IS_CUTTING,
ARDB.BuiltInParameter.OFFSETFACES_SHOW_SHAPE_HANDLES,
};

void ReconstructAddMassLoft
(
[Optional, NickName("DOC")]
ARDB.Document document,
Expand Down Expand Up @@ -60,7 +71,7 @@ void ReconstructFormByCurves
foreach (var curve in profile.ToCurveMany())
referenceArray.Append(new ARDB.Reference(document.FamilyCreate.NewModelCurve(curve, sketchPlane)));

ReplaceElement(ref form, document.FamilyCreate.NewFormByCap(true, referenceArray));
ReplaceElement(ref form, document.FamilyCreate.NewFormByCap(true, referenceArray), ExcludeUniqueProperties);
}
}
else
Expand All @@ -81,9 +92,16 @@ void ReconstructFormByCurves
}
}

ReplaceElement(ref form, document.FamilyCreate.NewLoftForm(true, referenceArrayArray));
ReplaceElement(ref form, document.FamilyCreate.NewLoftForm(true, referenceArrayArray), ExcludeUniqueProperties);
}
}

form.get_Parameter(ARDB.BuiltInParameter.IS_VISIBLE_PARAM)?.Update(true);
form.get_Parameter(ARDB.BuiltInParameter.GEOM_VISIBILITY_PARAM).Update(ERDB.FamilyElementVisibility.DefaultModel);
form.get_Parameter(ARDB.BuiltInParameter.MATERIAL_ID_PARAM)?.Update(ElementIdExtension.Invalid);
form.get_Parameter(ARDB.BuiltInParameter.FAMILY_ELEM_SUBCATEGORY)?.Update(ElementIdExtension.Invalid);
form.get_Parameter(ARDB.BuiltInParameter.ELEMENT_IS_CUTTING)?.Update(0);
form.get_Parameter(ARDB.BuiltInParameter.OFFSETFACES_SHOW_SHAPE_HANDLES)?.Update(true);
}
}
}
2 changes: 1 addition & 1 deletion src/RhinoInside.Revit.GH/Components/Model/AddModelLine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ protected override void TrySolveInstance(IGH_DataAccess DA)
var plane = sketchPlane.Location;
var tol = GeometryTolerance.Model;

if (Curve.ProjectToPlane(curve.ToNurbsCurve(), plane) is Curve projectedCurve)
if (curve.ProjectToPlane(plane) is Curve projectedCurve)
curve = projectedCurve;
else
throw new Exceptions.RuntimeArgumentException("Curve", "Failed to project 'Curve' into 'Work Plane'", curve);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ protected override void TrySolveInstance(IGH_DataAccess DA)
var normal = default(ARDB.XYZ);
if (plane.HasValue)
{
curve = Curve.ProjectToPlane(curve, plane.Value) ?? curve;
curve = curve.ProjectToPlane(plane.Value) ?? curve;
normal = plane.Value.Normal.ToXYZ();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ protected override void TrySolveInstance(IGH_DataAccess DA)
is3D = true;

if (!boundary[i].IsInPlane(sketchPlane.Location, tol.VertexTolerance))
boundary[i] = Curve.ProjectToPlane(boundary[i], sketchPlane.Location);
boundary[i] = boundary[i].ProjectToPlane(sketchPlane.Location);

boundaryElevation = Interval.FromUnion(boundaryElevation, new Interval(sketchPlane.Location.OriginZ, sketchPlane.Location.OriginZ));
}
Expand Down
2 changes: 1 addition & 1 deletion src/RhinoInside.Revit.GH/Components/Structure/AddTruss.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ protected override void TrySolveInstance(IGH_DataAccess DA)
var tol = GeometryTolerance.Model;
var plane = sketchPlane.Location;

if (Curve.ProjectToPlane(curve.ToNurbsCurve(), plane) is Curve projectedCurve)
if (curve.ProjectToPlane(plane) is Curve projectedCurve)
curve = projectedCurve;
else
throw new Exceptions.RuntimeArgumentException("Curve", "Failed to project 'Curve' into 'Work Plane'", curve);
Expand Down
Loading

0 comments on commit 7f17441

Please sign in to comment.