CurveLoop.Transform no longer working after upgrading from Revit 2019 to Revit 2023

CurveLoop.Transform no longer working after upgrading from Revit 2019 to Revit 2023

remiarchitecture
Observer Observer
1,227 Views
1 Reply
Message 1 of 2

CurveLoop.Transform no longer working after upgrading from Revit 2019 to Revit 2023

remiarchitecture
Observer
Observer

Hello, I have a simple plug-in that was working fine in Revit 2019 and then stopped working after upgrading to Revit 2023. I checked the API Documentation and as far as I know everything should work the same as it did before, so I'm not sure what's causing the issue.

 

The plug-in lets users select 3D surfaces ( such as roof surfaces, or surfaces on 3d components ) and then after clicking "finish" in the Selection.PickObjects dialog, the plug-in then creates a FilledRegion covering up 3D surface. Basically the plug-in lets you color 3D surfaces with 2D detail FilledRegion objects.

 

Here's a code snippet:

 

Element stringFillType = new FilteredElementCollector(currentDoc)
  .OfClass(typeof(FilledRegionType))
  .FirstOrDefault(x => x.Name == stringForm.stringNumber);

IList<Reference> moduleFaceReferences = sel.PickObjects(ObjectType.Face);

foreach(Reference moduleFaceRef in moduleFaceReferences)
{
  GeometryObject geoObj = currentDoc.GetElement(moduleFaceRef).GetGeometryObjectFromReference(moduleFaceRef);
  Instance moduleInstance = currentDoc.GetElement(moduleFaceRef) as Instance;
  Transform moduleTransform = moduleInstance.GetTotalTransform();
  PlanarFace moduleFace = geoObj as PlanarFace;
  IList<CurveLoop> faceEdges = moduleFace.GetEdgesAsCurveLoops();

  foreach (CurveLoop loop in faceEdges)
  {
    loop.Transform(moduleTransform);
  }
  FilledRegion fillRegion = FilledRegion.Create(currentDoc, stringFillType.Id, currentView.Id, faceEdges);

 

The error I get: "The input curve loops cannot compose a valid boundary, that means: no curve loop is contained in the given collection; these curve loops intersect with each other for some of them; or each curve loop is not closed individually; or each curve loop is not planar; or each curve loop is not in a plane parallel to the horizontal(XY) plane."

 

One thing to note- when I comment out that "loop.Transform(moduleTransform)" line the code executes without throwing errors, but creates the FilledRegion at the origin of the document- not over the top of the 3D surface like I want. So it looks like the behavior of CurveLoop.Transform is different in 2023 vs how it was in 2019, and now the transform is not creating a valid boundary.

 

Any help is appreciated, thanks!

0 Likes
1,228 Views
1 Reply
Reply (1)
Message 2 of 2

RPTHOMAS108
Mentor
Mentor

Probably more to do with the fact FilledRegion.Create overloads were updated in 2023 because they added a feature in the UI where regions could be added to model families so in the API they also updated it to include that.

 

To clarify are you saying that in older versions you were placing the filled regions in a 3D view or taking a face from a 3D object and applying filled region based on that to 2D view? It's rare the API offers a feature not inherently available in the UI.

 

When you compare the below extracts from RevitAPI.chm for 2022 and 2023 you'll note the exception condition has been updated. It now talks of the loop needing to exist in the detail sketch plane of the view.

 

2022:

"The Id typeId is invalid. -or- Thrown if the viewId or typeId is invalid, or the view does not support the detail items creation, or if the boundaries are empty, open, or self-intersecting."

 

2023:

"The document is a 3d model family. -or- The Id typeId is invalid. -or- Details can't be drawn in the view. -or- Masking regions and Filled regions can't be created in this document or view. -or- The input curve loops cannot compose a valid boundary, that means: the "curveLoops" collection is empty; or some curve loops intersect with each other; or each curve loop is not closed individually; or each curve loop is not planar; or each curve loop is not in a plane parallel to the view's detail sketch plane; or input curves contain at least one helical curve. -or- Thrown if the viewId or typeId is invalid, or the view does not support the detail items creation, or if the boundaries are empty, open, or self-intersecting."

0 Likes