Structure_Engine: Add Query Geometry Line Method
- Dominant language
- C#
- Stars
- 30
- Forks
- 13
- Avg merge
- 7d 10h
- Merged PRs (30d)
- 5
Description
#### Description:
Pulling bars with the Robot_Adapter returns a warnings in ORCA "Cannot query length as geometry is null". This warning is derived as follows;
The full chain, from source
`Structure_Engine/Query/Geometry.cs` has `Geometry(this RigidLink)`, `Geometry(this Pile)`, `Geometry(this PileFoundation)`, `Geometry(this RetainingWall)` — but no `Geometry(this Bar)`. `Spatial_Engine.Query.IGeometry(IElement1D)` finds it via `Base.Compute.RunExtensionMethod(element1D, "Geometry")` — a reflection search across every loaded engine for a method named exactly `Geometry` matching the runtime type. For `Bar`, nothing matches, so it returns `null`, and `Length()` correctly reports "cannot query length as the geometry is null." This is a genuine gap in `BHoM_Engine` itself, not a stale install.
`Robot_Toolkit`'s `IsVerticalRobot(Bar)` is entirely reasonable code — it calls the documented `bar.Length()`, gets `NaN` back, and `projLength < (NaN * 0.001)` is always false under IEEE-754 (any comparison against NaN is false). So `IsVerticalRobot` always reports "not vertical," for every bar, regardless of truth.
The real defect, though, is what happens next in `FromRobotOrientationAngle`:
`bool bhomVertical = bhomBar.IsVertical(); // via Centreline() — built directly from Start/End, UNAFFECTED`
`bool robotVertical = bhomBar.IsVerticalRobot(); // via Length() — ALWAYS false, due to the gap above`
`if (bhomVertical == robotVertical)`
`orientationAngle = robotOrientation; // pass-through, correct`
`else`
`// mismatched-branch trig transform`
`IsVertical()` builds its `Line` directly (`Centreline(): new Line { Start = bar.Start.Position, End = bar.End.Position }`) — it never touches the broken dispatch, so it's correct. So for a truly vertical bar: `bhomVertical=true`, `robotVertical=false` (wrong) → mismatch → the else branch runs `Vector.ZAxis.Rotate(robotOrientation, tan)`, where tan is the bar's own tangent — which, for a vertical bar, is parallel to `Vector.ZAxis`. Rotating a vector about an axis parallel to itself is a no-op for any angle. That's exactly why I measured a constant output regardless of the input Robot angle — the maths degenerates to a fixed, wrong answer.
For a horizontal bar: `bhomVertical=false`, `robotVertical=false` (also wrong, but coincidentally matches) → equal → `orientationAngle = robotOrientation` unchanged, correct by accident.
So: the error fires on every bar, but it only silently corrupts `OrientationAngle` for genuinely vertical members. Horizontal and inclined bars pass their orientation through untouched despite raising the same event.
Separatley; Grasshopper does not show this set of warnings, even thought it should. Not all events are being logged it seems.
#### Steps to reproduce:
#### Expected behaviour:
#### Test file(s):
Contributor guide
Research direction
Start in Structure_Engine/Query/Geometry.cs by comparing the existing Geometry methods for RigidLink, Pile, PileFoundation, and RetainingWall with the missing Bar case. Trace Spatial_Engine.Query.IGeometry(IElement1D) and validate the Robot_Adapter reproduction for vertical and horizontal bars; done means Bar geometry and length queries no longer return null or produce the described incorrect vertical orientation result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100