Essencially, I want to be able to get the geometry of a polyline and reverse it or not depending on the user inputs. Then, I want to recreate it with this geometry, inverting the start and end points necessarily when needed.
In fact, I used Curve.Reverse in its PolyCurve geometry and it did work. But as I attempted to use the PolylineExtensions.ObjectByGeometry node to recreate it, the geometry got reverted back in some cases.
From what I’ve tested, it appears to necessarily sort the curves by coordinates, going from lower to higher, but I might be mistaken. Is this a known feature? Is there any known way to contour this?
Can you show this in action with a screenshot and all the node previews pinned?
1 Like
Hello @apegaia,
When drawing any arbitrary line in an application such as Revit or Civil 3D the geometry kernel needs to give that line direction but typically does not have any context to surrounding objects. In this case, say a sketch boundary for a Revit floor or an Alignment in Civil 3D, there are two options to give directionality;
- Arbitrarily, which doesn’t help anyone.
- Or based on the way you drew the line, with your first click demarcating the “start point” and your second click demarcating the “end point” which gives direction. The calculation of normals off these curves (i.e. how they offset) will be based off this too, will be consistent, but will essentially ‘pick a side’ per application.
So the reason you are most likely seeing a series of lines seem to have arbitrary directions is most likely due to the above.
Unfortunately this makes it difficult to automate unless you know this and draw them “the same way every time”, so a form of reorientation is needed. That reorientation is entirely dependent on your drawing and intention.
1 Like
I can’t share much of it, as I’m creating it in python and I don’t think it would help that much as it is a very long code.
But I’m using the code line bellow to create it and the output of the python code block is the “polyCurve”
DA.PolylineExtensions.ObjectByGeometry(polyCurve, layer, modelSpace)
So basically I’m comparing the geometry I’m sending to the function to the geometry of the polyline created.
Also, thanks for the interest!
Thanks for the explanation!
I’m considering creating them all automatically and reversing only the desiderd polylines calling the Reverse command or any similar method (instead of trying to create them with the right direction).
1 Like
So, the solution for me was creating my own polyline from ground, point by point.
Essencially, I got the start point of the first curve, then got the end points of the lines/arcs one by one. If the curve in question wan an arc, I recreated the last point with a bulge equivalent to the arc.
The question remaining was: is the bulge positive or negative?
For this, I got the geometry of the arc I created with positive bulge and compared it with the geometry of the original curve. Specifically, I got the mid point of them both and compared them.
As they don’t match exactly (even when they are right), I prefered to create the other arc possibility - with negative bulge - and then get the best arc by finding the minimum distance between the arcs’ mid points and the curve’s mid point.
I believe you could filter them by a maximum value (like 1m), but I prefered to make sure I was getting the best and right option - instead of optimizing the program.
So far, it seemed to work fine and it saved my life, as I’m finally able to create my polylines without their geometry being reverted. Couldn’t find the pattern or the reason why it happened with ObjectByGeometry(), but it also started giving me arcs with the inverse angles, so I gave up of this approach.
Thanks for all the help!
2 Likes