Civil engineering feature implementation (Transportation Engineering)

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
User avatar
Joel_graff
Posts: 1472
Joined: Fri Apr 28, 2017 4:23 pm
Contact:

Re: Civil engineering feature implementation

Postby Joel_graff » Sun Jun 04, 2017 12:11 pm

Yeah, I sort of figured it out a week ago, I think, but it's basically what Abdullah was getting at.
You can find the FreeCAD Trails workbench for transportation engineering on my github at:
https://www.github.com/joelgraff/freecad.trails
User avatar
Joel_graff
Posts: 1472
Joined: Fri Apr 28, 2017 4:23 pm
Contact:

Re: Civil engineering feature implementation

Postby Joel_graff » Sun Jun 04, 2017 12:27 pm

Ok, So I've begun building a script to generate alignments. It's certainly fine to generate the horizontal and vertical separately, then project them to generate the 3D.

I'm reasonably sure Sketcher is the most expedient way to set up either alignment, but there are problems with using it to create alignments.

The alignment macro I'm writing really only needs three key elements: lines, arcs and tangential constraint. More complex geometries I intend on building (2-center, 3-center, and spiral curves) are simply a specific combination of tangentially-constrained lines and arcs.

The following PDF link provides a simple point of reference as to what the basic geometric requirements for alignments:

http://www.globalsecurity.org/military/ ... 33/ch3.pdf

So my plan is really pretty simple. The user simply selects one of five possible geometry types (tangent, simple curve, 2-center, 3-center, spiral) and can either append it to the end of the alignment, or insert it at a selected point. The macro then adds the desired geometry and tangentially constrains it to the surrounding geometry. From there, the user adjusts the curve / tangent either by click / drag or by manually entering data into a dialog.

The problem is, when applying a tangent constraint to two points, the result causes both objects to move. I want to ensure that the preceding geometry does not move. There is a constraint which does that, but it puts dimensions on the screen which are entirely irrelevant for my purposes.

Any way to achieve a fixed constraint without having to use that? It may be that I'm just not well-schooled enough in Sketcher's constraint system - apologies if this is an obvious question...
You can find the FreeCAD Trails workbench for transportation engineering on my github at:
https://www.github.com/joelgraff/freecad.trails
User avatar
microelly2
Posts: 4329
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Civil engineering feature implementation

Postby microelly2 » Tue Jun 06, 2017 7:53 am

Joel_graff wrote:
Sun Jun 04, 2017 12:27 pm


So my plan is really pretty simple. The user simply selects one of five possible geometry types (tangent, simple curve, 2-center, 3-center, spiral) and can either append it to the end of the alignment, or insert it at a selected point. The macro then adds the desired geometry and tangentially constrains it to the surrounding geometry. From there, the user adjusts the curve / tangent either by click / drag or by manually entering data into a dialog.

The problem is, when applying a tangent constraint to two points, the result causes both objects to move. I want to ensure that the preceding geometry does not move. There is a constraint which does that, but it puts dimensions on the screen which are entirely irrelevant for my purposes.

There is no other way to fix the position of a point. You have to pin it (Sketcher Lock)
https://www.freecadweb.org/wiki/Constraint_Lock

The problem is that the sketch will be filled with constraints.
There was a discussion to hide some of the constraints but at the moment there is no method to do this.
the only idea for a workaround is to have an other sketch in the background and connect your working sketch with external geometry constraint to it.
The macro can add the lock constraints to the background sketch. So the foreground sketch will stay slim.

linked_sketches.fcstd
(4.86 KiB) Downloaded 24 times
User avatar
Joel_graff
Posts: 1472
Joined: Fri Apr 28, 2017 4:23 pm
Contact:

Re: Civil engineering feature implementation

Postby Joel_graff » Tue Jun 06, 2017 11:18 am

I played with it and noticed that you can't edit the foreground sketch so long as it's tied to the external geometry... That's a shame - I had hoped to benefit from that external tie while editing the geometry, so that adding new geometry and constraints wouldn't shift the existing geometry

I'm starting to think the transportation functionality might require a modified sketcher workbench to work smoothly, but I hope we can demonstrate the basic functionality in vanilla FreeCAD without having to build a lot of workaround code...
You can find the FreeCAD Trails workbench for transportation engineering on my github at:
https://www.github.com/joelgraff/freecad.trails
User avatar
microelly2
Posts: 4329
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Civil engineering feature implementation

Postby microelly2 » Tue Jun 06, 2017 12:43 pm

You can switch between the sketches
If you want to change some values in the backbone you change the constraints or work without hard constraints
The foreground sketch never can change values in the background, so once a foreground point is bound to the background you
have two opportunities
change the background sketch
or delete the external geometry constraint.
https://youtu.be/iajoWEJE7iM
User avatar
Joel_graff
Posts: 1472
Joined: Fri Apr 28, 2017 4:23 pm
Contact:

Re: Civil engineering feature implementation

Postby Joel_graff » Thu Jun 08, 2017 2:59 am

Ok, so external geometry isn't quite what I need, here, though I think it might be handy in the future. So, I'm letting that be for the moment. It may not be so big an issue, anyway.

That said, I don't suppose there's a way to expose FeaturePython objects in Sketcher? From what I can tell, they have to live at the document level (sibling to a Sketch).

I have the idea to build classes for these specific curves, since they have a lot of accompanying geometry...
You can find the FreeCAD Trails workbench for transportation engineering on my github at:
https://www.github.com/joelgraff/freecad.trails
User avatar
Kunda1
Posts: 5226
Joined: Thu Jan 05, 2017 9:03 pm

Re: Civil engineering feature implementation

Postby Kunda1 » Wed Jun 14, 2017 1:22 pm

Joel_graff wrote:
Thu Jun 08, 2017 2:59 am
Ok, so external geometry isn't quite what I need, here, though I think it might be handy in the future. So, I'm letting that be for the moment. It may not be so big an issue, anyway.

That said, I don't suppose there's a way to expose FeaturePython objects in Sketcher? From what I can tell, they have to live at the document level (sibling to a Sketch).

I have the idea to build classes for these specific curves, since they have a lot of accompanying geometry...
wmayer wrote:ping
@wmayer care to weigh in?
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
User avatar
microelly2
Posts: 4329
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Civil engineering feature implementation

Postby microelly2 » Fri Jun 16, 2017 12:14 pm

Joel_graff wrote:
Thu Jun 08, 2017 2:59 am
That said, I don't suppose there's a way to expose FeaturePython objects in Sketcher? From what I can tell, they have to live at the document level (sibling to a Sketch).

I have the idea to build classes for these specific curves, since they have a lot of accompanying geometry...
There is a way to add more intelligence to a Sketch, the SketchObjectPython.
https://forum.freecadweb.org/viewtopic. ... 10#p178192

I would build for any basic segment a special SketchObjectPython and connect them by special connector (SketchObjectPython too)
The task of the connectors is to hold the tangent conditions (direction) and placement condition
The segments read these data from the connectors and adjust the inner geometry depeding on the connectors and some internal parameters

The SketchObjectPython can then create a 3D curve using the elevation data from the underlying terrain ore some other database.
User avatar
Kunda1
Posts: 5226
Joined: Thu Jan 05, 2017 9:03 pm

Re: Civil engineering feature implementation

Postby Kunda1 » Wed Jun 21, 2017 3:59 pm

Joel_graff wrote:ping
Just checking in...any progress?
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
User avatar
Joel_graff
Posts: 1472
Joined: Fri Apr 28, 2017 4:23 pm
Contact:

Re: Civil engineering feature implementation

Postby Joel_graff » Fri Jun 23, 2017 2:28 am

I only saw the response a few days ago, so not much progress yet. I have to watch the video a couple more times I think.

Really, it's been a mental game just trying to figure out how to use Sketcher's constrained geometry to model horizontal and vertical alignments. The requirements for civil geometry are really pretty simple and Sketcher should have no problem managing it. I've got a fair idea of how to approach it, but coding Python's slow - you know.. documentation. :)

Plus, there's a weird bug it seems in sketcher's selection code...
You can find the FreeCAD Trails workbench for transportation engineering on my github at:
https://www.github.com/joelgraff/freecad.trails