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: 1492
Joined: Fri Apr 28, 2017 4:23 pm
Contact:

Re: Civil engineering feature implementation

Postby Joel_graff » Sat May 27, 2017 3:08 pm

I should pont out that I'm slowly figuring out how to interact with the Sketcher module - it's a solvable problem, but it'd be nice to find a few good python examples apart from what's on the github repo.

What I'm most interested in is solving the problem of using the sketcher geometry directly in an actual model, or finding a way to convert it to a 3D curvelinear object....
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: 5481
Joined: Thu Jan 05, 2017 9:03 pm

Re: Civil engineering feature implementation

Postby Kunda1 » Tue May 30, 2017 11:34 am

Joel_graff wrote: With an alignment object, this poses a couple of problems:

1. The alignment object is a real object that must exist in the final model, though it is never more than curvelinear.
2. The alignment object is the superposition of two curvelinear objects in orthogonal planes (horizontal and vertical)

Meeting these requirements seems to be complicated using Sketcher...

Can anyone perhaps fill in the gaps in my understanding that might make this easier to visualize?
Abdullah wrote:ping
Any feedback you can offer to this discussion?
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
abdullah
Posts: 3174
Joined: Sun May 04, 2014 3:16 pm

Re: Civil engineering feature implementation

Postby abdullah » Tue May 30, 2017 1:06 pm

Joel_graff wrote:While the fact that the core functionality is so readily demonstrated in Sketcher is really encouraging, it appears to me that Sketcher is implemented almost entirely in C++. Further, there doesn't appear to be any API documentation, (nor much of an API so far as I can tell). Is there more information on how to interact with Sketcher via Python?
I know little about documentation. However, every time you execute a command in the UI a line is written to the Python console. That is my API documentation (together with looking in the pyImp.cpp files in the source, SketchObjectPyImp.cpp should be a right point to look into sketcher commands).
Joel_graff wrote:Also, one of the things that I noticed in the documentation is that the sketcher objects are intended to generate a 3D object and that the sketcher geometry exists in only the sketcher design stage.
I would not say that is right. Sketches are "wires". You just define them with constraints. They can be used for other purposes not necessarily for 3D.
Joel_graff wrote:With an alignment object, this poses a couple of problems:

1. The alignment object is a real object that must exist in the final model, though it is never more than curvelinear.
2. The alignment object is the superposition of two curvelinear objects in orthogonal planes (horizontal and vertical)

Meeting these requirements seems to be complicated using Sketcher...
Needless to say (it will be apparent anyway) I know nothing about Civil engineering. I will try to fill some of the blanks though:
1. A sketch defines a curve constrained to a plane. If your curves are not constrained to a plane they can not be contained in a Sketch.
2. However, several sketches can provide several curves, each of them constrained to a (potentially different) plane.
3. Additionally, it is possible to create a 3D object/Face out of one or more purposefully created sketches, so as to produce a 3D shape having a wire meeting some constraint and them downgrade the 3D solid, so as to extract that specific wire.

Note: Downgrade tool is present in Draft WB.

Of course, it is always possible to define your objects directly in python. I can imagine a python Feature that uses two sketches to construct such 3D curve (from two orthogonal sketches), by for example adding the endpoint coordinates of segments of both sketches. There may even be some OCC function to help here. Just throwing some food for thought.
Jee-Bee
Posts: 1950
Joined: Tue Jun 16, 2015 10:32 am
Location: Netherlands

Re: Civil engineering feature implementation

Postby Jee-Bee » Tue May 30, 2017 2:28 pm

abdullah wrote:
Tue May 30, 2017 1:06 pm
Of course, it is always possible to define your objects directly in python. I can imagine a python Feature that uses two sketches to construct such 3D curve (from two orthogonal sketches), by for example adding the endpoint coordinates of segments of both sketches. There may even be some OCC function to help here. Just throwing some food for thought.
[off topic] it would be great to have a optional 3d curve availeble! very nice together with the sweep function :D
but off course it can wait to 0.18 :lol: .[/off topic]
User avatar
microelly2
Posts: 4354
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Civil engineering feature implementation

Postby microelly2 » Tue May 30, 2017 4:08 pm

The simplest way to get a 3D curve on a surface (example terrain) is have a mapping between the 3D Space and the 2D Sketcher world.

We do this for painting on the shoe surfaces

I monitor the mouse clicks on the surface, calculate the uv-coordinates and map it down to the plan
there I can replace the points by bspline curves and other components as sketcher objects and then I go back to the 3D surface.

https://youtu.be/FSHfrSuvo-A
https://youtu.be/MEcLXgn1rJ8


I think there can be other mappings too , simple projection (x,y,z)-> (x,y)
the backward direction can be done with scipy.interpolate.interp2d and scipy.interpolate.Rbf

creating and maintaining real 3D curves from scratch is hard, working with two projections or a projection and a surface is much simpler.
User avatar
microelly2
Posts: 4354
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Civil engineering feature implementation

Postby microelly2 » Tue May 30, 2017 4:47 pm

here an example to create a 3D curve from two 2D projections
it works with a DraftBSpline and a Sketcher curve too.
Attachments
combine_curves.py
(696 Bytes) Downloaded 47 times
curves.fcstd
(8.51 KiB) Downloaded 31 times
abdullah
Posts: 3174
Joined: Sun May 04, 2014 3:16 pm

Re: Civil engineering feature implementation

Postby abdullah » Tue May 30, 2017 5:28 pm

microelly2 wrote:We do this for painting on the shoe surfaces
Very cool... I am not sure I like the actual drawings on the shoes though ;)
abdullah
Posts: 3174
Joined: Sun May 04, 2014 3:16 pm

Re: Civil engineering feature implementation

Postby abdullah » Tue May 30, 2017 5:32 pm

microelly2 wrote:
Tue May 30, 2017 4:47 pm
here an example to create a 3D curve from two 2D projections
it works with a DraftBSpline and a Sketcher curve too.
See, there is nothing like asking for it. Nice python script. I love the first line that forces the user to use FC 0.17 or better :twisted:
User avatar
microelly2
Posts: 4354
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Civil engineering feature implementation

Postby microelly2 » Tue May 30, 2017 6:14 pm

abdullah wrote:
Tue May 30, 2017 5:28 pm
microelly2 wrote:We do this for painting on the shoe surfaces
Very cool... I am not sure I like the actual drawings on the shoes though ;)
So we need flowers or butterflies as generic sketcher objects :lol:

abdullah wrote:
Tue May 30, 2017 5:32 pm
I love the first line that forces the user to use FC 0.17 or better :twisted:
I have some ideas how to check the dependencies between packages
to hide functionality and give a smart warning if the prerequisites are not satisfied.
this was the first attempt.
User avatar
Kunda1
Posts: 5481
Joined: Thu Jan 05, 2017 9:03 pm

Re: Civil engineering feature implementation

Postby Kunda1 » Fri Jun 02, 2017 10:42 am

Joel_graff wrote:
Sat May 27, 2017 3:08 pm
I should pont out that I'm slowly figuring out how to interact with the Sketcher module - it's a solvable problem, but it'd be nice to find a few good python examples apart from what's on the github repo.
Did the feedback from @Abdullah help?
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features