CurveLoop.Transform no longer working after upgrading from Revit 2019 to Revit 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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!