[Feature Request] Built-in parametric curve creation

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!
chrisb
Veteran
Posts: 54303
Joined: Tue Mar 17, 2015 9:14 am

Re: [Feature Request] Built-in parametric curve creation

Post by chrisb »

At least the second was a bit premature. If the author doesn't want it, it sure shouldn't be done.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
NewJoker
Veteran
Posts: 3089
Joined: Sun Oct 11, 2020 7:49 pm

Re: [Feature Request] Built-in parametric curve creation

Post by NewJoker »

chrisb wrote: Thu Aug 26, 2021 6:57 pm At least the second was a bit premature. If the author doesn't want it, it sure shouldn't be done.
Let's ask:

Chris_G wrote:Chris_G
I can always delete this request if he doesn't want such thing to be done.
User avatar
Chris_G
Veteran
Posts: 2602
Joined: Tue Dec 31, 2013 4:10 pm
Location: France
Contact:

Re: [Feature Request] Built-in parametric curve creation

Post by Chris_G »

NewJoker wrote: Thu Aug 26, 2021 5:10 pm And I created one for Curves workbench as well: https://tracker.freecadweb.org/view.php?id=4736
chrisb wrote: Thu Aug 26, 2021 6:57 pm At least the second was a bit premature. If the author doesn't want it, it sure shouldn't be done.
Hi,
I will try to be short and precise :
- unfortunately, I have less free time that I would like to dedicate to FC coding.
- I am not pro developer, nor mathematician
- I have a huge lot of fun learning coding, geometry and maths by developing Curves Workbench
- I have never used ANY other CAD software but FreeCAD, so I don't know how tools similar to CurvesWB ones are working in these SW.
- I do think, considering users feedback, that some tools of Curves Wb would deserve to go in FC master
- I think that code quality is important into FC master, so, considering my own coding skills (= C++ noob), I am quite shy at adding new features into FC master
- aside from purely technical or coding consideration, the UI of a tool is also very important: what parameters should be exposed to user, what other parameters offer less gain, are less intuitive, or too complex. This is especially true in the Nurbs domain. So this needs experiments and user feedback. That's the goal of Curves workbench, as an external addon. And some CurvesWb tools are clearly not fitting the bill in that domain.
- I think I have acquired a good knowledge of Nurbs maths and algorithms during these years, but I am still a C++ noob, that would need a dedicated tutor to assist me at porting some CurvesWB python code to C++ for FC master.
- my current goal (I have just started working on this) is to get Blend surfaces to FC master.
- So I am not opposed to porting some of Curves WB tools to FC master, I am just doubtful about my own ability to do so.
- You could argue that C++ is NOT strictly required and that python is also allowed in FC master. That's true but Curves WB is adopting a "bottom-up" workflow (creating 3D curves, then creating surfaces upon these curves, then eventually shells or solids). If we want to keep all these things parametric (= with regular recomputes), then the efficiency of the code is also important.
TheMarkster
Veteran
Posts: 5513
Joined: Thu Apr 05, 2018 1:53 am

Re: [Feature Request] Built-in parametric curve creation

Post by TheMarkster »

NewJoker wrote: Sun Aug 22, 2021 3:30 pm Hi,

I know that there is a 3D Parametric Curve macro (Macro 3D Parametric Curve) for FreeCAD. But I wonder why we couldn't implement it to make a built-in functionality from it ? After all, parametric curves are one of the core functionalities of CAD programs. Macros are easy to download and use but it also shouldn't be hard to implement this too. This way users wouldn't have to look for this functionality. This would also make FreeCAD look more complete without a lot of effort. The macro already has a toolbar icon so it should be even easier to add it to FreeCAD. And it's simple enough that it shouldn't need further improvements.

What do you think about it ?

By the way, what about the parametric curves for sketcher ? Is there any solution for that ?
Edit:
The macro, like the original, uses eval(), which makes it a security risk. A malicious user could potentially put malicious code in a file and share it. Those who have run the macro and open the file would be at risk.

It's not exactly what you wanted, but I modified the macro code to create a parametric feature python object. The down side to having a feature python object in a macro is when you save the file and restart FreeCAD you no longer have the code in memory to execute the feature python code. if it were in a workbench, then the workbench code would be loaded on startup.

Therefore, you should run the macro before opening the example file.

When you change the properties, the curve updates automatically.
Snip macro screenshot-55077e.png
Snip macro screenshot-55077e.png (60.99 KiB) Viewed 1445 times
It has spreadsheet integration. Select your spreadsheet before running the macro and it will pull those values from the spreadsheet, provided the spreadsheet has a few aliases setup for this purpose. It also updates from the spreadsheet when you modify the spreadsheet. You can change the spreadsheet linkage via the Spreadsheet property using the link editor. You need these aliases in the spreadsheet: a_cell, b_cell, c_cell, X, Y, Z, min_t, max_t, and interval.
Snip macro screenshot-3fe7cf.png
Snip macro screenshot-3fe7cf.png (73.21 KiB) Viewed 1445 times
It has a spiffy icon.
Snip macro screenshot-b8d8fa.png
Snip macro screenshot-b8d8fa.png (49.59 KiB) Viewed 1445 times
Attachments
pmcurve_test.FCStd
(21.16 KiB) Downloaded 23 times
3D_Parametric_Curve_FP.FCMacro
(18.59 KiB) Downloaded 29 times
User avatar
Zolko
Veteran
Posts: 2213
Joined: Mon Dec 17, 2018 10:02 am

Re: [Feature Request] Built-in parametric curve creation

Post by Zolko »

Chris_G wrote: Thu Aug 26, 2021 9:38 pm - You could argue that C++ is NOT strictly required and that python is also allowed in FC master. That's true but .... then the efficiency of the code is also important.
I very much like and need both Curves and CurvedShapes WBs, and would like to see them in core FreeCAD. Actually, I'd like them merged into 1 WB (Surface WB ?) And merged into FreeCAD.

And then, if we talk about efficiency, keeping existing Python code seems like the most efficient use of developers time.
try the Assembly4 workbench for FreCAD — tutorials here and here
User avatar
Roy_043
Veteran
Posts: 8585
Joined: Thu Dec 27, 2018 12:28 pm

Re: [Feature Request] Built-in parametric curve creation

Post by Roy_043 »

The name Surface_Workbench is already taken.
LibrEars
Posts: 29
Joined: Wed Apr 14, 2021 3:43 pm

Re: [Feature Request] Built-in parametric curve creation

Post by LibrEars »

Related topic that might be relevant for this request: [Feature Request]: sketcher WB - new parametric tool - periodic wires - waveform-generator - sine function

Here I wanted to express my interest in generalize curve creation by the use of mathematical expressions (parametric out of a mathematical view ;) )
My next step was to add some explaining drawings on use-cases but I have not found the time so far.

Cheers
TheMarkster
Veteran
Posts: 5513
Joined: Thu Apr 05, 2018 1:53 am

Re: [Feature Request] Built-in parametric curve creation

Post by TheMarkster »

I did some more work on the macro. It's now on github. You can't install from the addon manager, at least not at this time.

https://github.com/mwganson/Parametric_Curve_FP

Full documentation can be found on github.

Some changes:

replaced insecure eval() with pyparsing (slower, but safer)
fixed bug where reloading file broke the fp object
add option to create a new spreadsheet and add the aliases to it
can also add aliases to existing spreadsheet (but will clobber anything in cells A1-B9)
set fp properties to readonly when using spreadsheet (they'll be overwritten anyway)
add option to push data to spreadsheet
add option to disable spreadsheet, but keep it linked
separated into 2 files (necessary, I think, to keep the code resident) 1 file has the classes, the other serves to instantiate.

Now, if you want to save a formula you can save it in a new spreadsheet. De-link the current spreadsheet, and set the Update Spreadsheet property to True. This will trigger creation of a new spreadsheet and pushing of the properties, with aliases, to it.

The object is attachable.

You can extrude/pad it directly. You can use it in part design by modifying the body's group property or by creating a shapebinder.
Snip macro screenshot-883578.png
Snip macro screenshot-883578.png (80.83 KiB) Viewed 1313 times
I am able to (to my surprise) load a file with one of the objects in it after restarting FreeCAD and the object still works. I guess it's pulling the needed information automatically from the macro without need to run the macro again.
User avatar
Pauvres_honteux
Posts: 728
Joined: Sun Feb 16, 2014 12:05 am
Location: Far side of the moon

Re: [Feature Request] Built-in parametric curve creation

Post by Pauvres_honteux »

:idea: Look what I found!
issue #4204
User avatar
onekk
Veteran
Posts: 6222
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: [Feature Request] Built-in parametric curve creation

Post by onekk »

The problem is not the parametric curve code. It is in the OCCT core and usable.

The main "concern" is the "surrounding code". i.e Chris_G has made the WB, but this WorkBench is not "yet" usable as example in a script to make other things, as it is made to be used using the GUI.

a little forweord: Many Thanks to Chrish_G to have put together the workbench (and for the help he game me many time), this is not a critics, but as a possible start of a prolific discussion.

Some of the Chris_G code is dealing with analyze the curve supplied and then feed the "surface generator" of FreeCAD (the OCCT function) with appropriate values.

This involve some maths and this math is slowing the process.

The points are:

- it will be possible to translate the "most demanding calculations" in C++ maybe leaving the interface with FreeCAD in Python.
- it will be possible to make the API scriptable, i.e supllying some "entry points" for scripting like some exposed methods. (I think this is feasible in short time but this involve some willing from Chris_G and some time to discuss some things)
- it will be possible to integrate this in FreeCAD?

Each of these points could be treated as single "problems" or as a whole bunch.

As Chris_G has tolds us that he is lacking of time and lacking of skills in C++, maybe if someone will step out and try to help in some way some of these things will be made in a relatively short time.

This involve, at least two things:

- how to pass to an external C++ program (that has to be compiled for every platform FreeCAD is supporting, at least Linux, Windows, and MacOs) the calculation that slow things, and how to obtain back the data to the passed to "surface generation code"
- alternatively, if it is feasible the C++ maybe could call directly the "OCCT function", maybe leveraging some code already in FreeCAD
- Some willing and time from Chris_G to make such things
- Someone that will take the responsibility to make and mantain the C++ Part, and maybe some people that have some MacOS machine as Windows and Linux are quite available.

Maybe I've not enough skill to help in this sort of things, my C++ knowledge is very very basic, my python skills are slightly over the beginner level.

Or I'm totally wrong on this analysis.

Regards to all and Thanks again to Chris_G.

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
Post Reply