question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PolyLine.GetPoints() returns 4 points for a rectangular, closed polyline

See original GitHub issue

Revit ConvertOpening expects PolyLine.GetPoints() to return 5 points:

if (poly == null || poly.GetPoints().Count != 5)
            throw new SpeckleException($"Curve outline for wall opening must be a rectangle-shaped polyline.");

Either this needs to become

if (poly == null || poly.GetPoints().Count != 4 || !poly.closed))

or PolyLine.GetPoints() has to return 5 points if polyline is closed.

Or is the approach here that for some reason start and end point of a rectangle are not unique?

Happy to create a PR for that 😃

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
tlmnrnhrdtcommented, Apr 19, 2022

Revit API has a IsRectBoundary property on Opening, checking that the boundary is in fact an actual rectangle, rather than just a 4 sided closed curve.

In Speckle the test below is only checking that the polyline has 5 points and assuming that means it’s rectangular. But it could be trapezoidal? Is the intention to handle the conversion of rectangular and non-rectangular openings differently?

if (poly == null || poly.GetPoints().Count != 5)
            throw new SpeckleException($"Curve outline for wall opening must be a rectangle-shaped polyline.");

If I understand correctly that type of opening is always rectangular in Revit. That said, when I create a rectangular polyline myself it has by definition only 4 points:

namespace Objects.Geometry
{
  public class Polyline : Base, ICurve, IHasArea, IHasBoundingBox, IConvertible, ITransformable
  {
    [DetachProperty]
    [Chunkable(31250)]
    public List<double> value { get; set; } = new List<double>();

    /// <summary>
    /// If true, do not add the last point to the value list. Polyline first and last points should be unique.
    /// </summary>
    public bool closed { get; set; }

So either the check in the Revit converter or the definition of how polylines are stored is wrong…

1reaction
AlanRynnecommented, Apr 21, 2022

Hi @tlmnrnhrdt and @d3ssy!

You are right! And if I hadn’t made a gif of it working (commits included) I would have been doubting myself if it ever worked 😓

Not sure what happened there but I did some tests yesterday and that condition needs changing. Since we’re releasing a new version i’m going to push it in myself so this change get’s included.

As for the RevitWallOpening constructor, I agree it is currently “too generic” and should be more specific. I’m working on a fix for the upcoming release too. This is already tracked here https://github.com/specklesystems/speckle-sharp/issues/1199 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Polyline (JavaFX 8)
Creates a polyline, defined by the array of the segment points. ... class is similar to the Polygon class, except that it is...
Read more >
extract rectangle points - AutoCAD Community
I know you know this; I'm just explaining to the OP and any lurkers... A LWPOLYLINE (aka "AcDbPolyline") returns coordinates as (x1 y1...
Read more >
JavaFX | Polyline with examples
getPoints(), gets the points of the polyline segments. toString(), Returns a string representation of this Polyline object.
Read more >
creating continuous spline curve in javafx
Now the only way I found is to implement a polyline with joint points, calculate the points of catmull curve after getting three...
Read more >
how to check if every entity/polyline on your drawing is ...
You have 4 single 2-Point lines building a closed rectangle. The result is a closed polyline, no matter what is selected first. On...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found