Civil engineering feature implementation (Transportation Engineering)
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
Be nice to others! Read the FreeCAD code of conduct!
- Joel_graff
- Veteran
- Posts: 1949
- Joined: Fri Apr 28, 2017 4:23 pm
- Contact:
Re: Civil engineering feature implementation
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....
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
pivy_trackers 2D coin3D library: https://www.github.com/joelgraff/pivy_trackers
Re: Civil engineering feature implementation
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?
Any feedback you can offer to this discussion?Abdullah wrote:ping
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
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
Re: Civil engineering feature implementation
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: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 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: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.
Needless to say (it will be apparent anyway) I know nothing about Civil engineering. I will try to fill some of the blanks though: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...
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.
Re: Civil engineering feature implementation
[off topic] it would be great to have a optional 3d curve availeble! very nice together with the sweep functionabdullah 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.
but off course it can wait to 0.18 .[/off topic]
- microelly2
- Veteran
- Posts: 4688
- Joined: Tue Nov 12, 2013 4:06 pm
- Contact:
Re: Civil engineering feature implementation
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.
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.
- microelly2
- Veteran
- Posts: 4688
- Joined: Tue Nov 12, 2013 4:06 pm
- Contact:
Re: Civil engineering feature implementation
here an example to create a 3D curve from two 2D projections
it works with a DraftBSpline and a Sketcher curve too.
it works with a DraftBSpline and a Sketcher curve too.
- Attachments
-
- combine_curves.py
- (696 Bytes) Downloaded 131 times
-
- curves.fcstd
- (8.51 KiB) Downloaded 120 times
Re: Civil engineering feature implementation
Very cool... I am not sure I like the actual drawings on the shoes thoughmicroelly2 wrote:We do this for painting on the shoe surfaces
Re: Civil engineering feature implementation
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 bettermicroelly2 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.
- microelly2
- Veteran
- Posts: 4688
- Joined: Tue Nov 12, 2013 4:06 pm
- Contact:
Re: Civil engineering feature implementation
So we need flowers or butterflies as generic sketcher objects
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.
Re: Civil engineering feature implementation
Did the feedback from @Abdullah help?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.
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
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