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

Re: Civil engineering feature implementation

Post by Joel_graff »

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....
FreeCAD Trails workbench for transportation engineering: https://www.github.com/joelgraff/freecad.trails

pivy_trackers 2D coin3D library: https://www.github.com/joelgraff/pivy_trackers
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Civil engineering feature implementation

Post by Kunda1 »

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?
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Civil engineering feature implementation

Post by abdullah »

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
Veteran
Posts: 2566
Joined: Tue Jun 16, 2015 10:32 am
Location: Netherlands

Re: Civil engineering feature implementation

Post by Jee-Bee »

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
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Civil engineering feature implementation

Post by microelly2 »

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
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Civil engineering feature implementation

Post by microelly2 »

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 127 times
curves.fcstd
(8.51 KiB) Downloaded 117 times
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Civil engineering feature implementation

Post by abdullah »

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
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Civil engineering feature implementation

Post by abdullah »

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
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Civil engineering feature implementation

Post by microelly2 »

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
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Civil engineering feature implementation

Post by Kunda1 »

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?
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Post Reply