Parametric Curve FP discussion board

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
edwilliams16
Veteran
Posts: 3111
Joined: Thu Sep 24, 2020 10:31 pm
Location: Hawaii
Contact:

Re: Parametric Curve FP discussion board

Post by edwilliams16 »

I had an error that because of the particular parameters I tested gave the right result. Then I thought I saved the correction, but didn't. Sigh.

Code: Select all

{"helix": {"a": "1  #pitch", "b": "5 #height", "c": "1 #base radius", "d": ["20 #angle deg", "1  # 1= RH  0 = LH", "t*b/a", "c + b*t*sin(rad(d1))/(2*pi)", "ternary(d2, 1, -1)"], "X": "d4*cos(d3*d5)", "Y": "d4*sin(d3*d5)", "Z": "b*t/(2*pi)", "t_min": "0", "t_max": "2*pi", "interval": "0.1"}}

Ellipse tomorrow.
TheMarkster
Veteran
Posts: 5505
Joined: Thu Apr 05, 2018 1:53 am

Re: Parametric Curve FP discussion board

Post by TheMarkster »

New version 2022.03.12

Added helix formula. Will update revised formula tomorrow, along with ellipse.
Changed around the dialog some. Save, Import, and Append (formerly Save All, Import All, and Append All) now have selection dialogs that allow for multiple selections. Previously it was all or one, but now can be any arbitrarily selected formulas. Moved Import up to the top box and Rename down to the bottom box.
edwilliams16
Veteran
Posts: 3111
Joined: Thu Sep 24, 2020 10:31 pm
Location: Hawaii
Contact:

Re: Parametric Curve FP discussion board

Post by edwilliams16 »

I have to try your newer version. I kept stepping on my foot with the file handling, trying to sync saved and in-memory formula revisions. Trying to keep all the formulae in one file was problematic, as I was unsuccessful revising one formula at a time. Another way I found to get in trouble was to change a formula (like add a comment) and do a Save One, without first doing an Apply - the revisions don't get saved.

I added comments to earlier formulae.

Code: Select all

{"helix": {"a": "1  #pitch", "b": "5 #height", "c": "1 #base radius", "d": ["20 #angle deg", "1  # 1= RH  0 = LH", "t*b/a", "c + b*t*sin(rad(d1))/(2*pi)", "ternary(d2, 1, -1)"], "X": "d4*cos(d3*d5)", "Y": "d4*sin(d3*d5)", "Z": "b*t/(2*pi)", "t_min": "0", "t_max": "2*pi", "interval": "0.1"}}

Code: Select all

{"ellipse": {"a": "20 #major radius", "b": "10 #minor radius (ignored if c != 0)", "c": "0.5 #eccentricity (0 to ignore and use a and b, else b^2 = a^2*(1 - c^2)", "d": ["0 #d1: x center", "0 #d2: y center", "20 #d3: angle from x-axis to major axis (deg)", "ternary(c, a*(1-c*c)^0.5, b) #d4", "a * cos(t) #d5: x -unrotated ellipse", "d4 * sin(t) #d6 y- unrotated ellipse", "radians(d3) #d7 angle in radians"], "X": "d1 + d5 * cos(d7) - d6 * sin(d7)", "Y": "d2 + d5 * sin(d7) + d6 * cos(d7)", "Z": "0", "t_min": "0.0", "t_max": "2*pi", "interval": "0.1"}}

Code: Select all

{"holesaw": {"a": "12  # radius", "b": "6 #no of teeth", "c": "5.000000 #sine amplitude", "d": [""], "X": "cos(t)*a", "Y": "sin(t)*a", "Z": "c*sin(b*t)", "t_min": "0.0", "t_max": "2*pi", "interval": "0.1"}}

Code: Select all

{"sawtooth": {"a": "40 #radius", "b": "5 #number teeth", "c": "0.8 # tooth parameter between 0 and 1", "d": ["10 #amplitude", "mod(b*t, 1)", "# best with polygon"], "X": "a*cos(2*pi*t)", "Y": "a*sin(2*pi*t)", "Z": "d1*(lt(d2,c)*d2/c + gte(d2,c)*(1-d2)/(1-c))", "t_min": "0.0", "t_max": "1.0", "interval": "0.01"}}
TheMarkster
Veteran
Posts: 5505
Joined: Thu Apr 05, 2018 1:53 am

Re: Parametric Curve FP discussion board

Post by TheMarkster »

edwilliams16 wrote: Sun Mar 13, 2022 4:31 pm I have to try your newer version. I kept stepping on my foot with the file handling, trying to sync saved and in-memory formula revisions. Trying to keep all the formulae in one file was problematic, as I was unsuccessful revising one formula at a time. Another way I found to get in trouble was to change a formula (like add a comment) and do a Save One, without first doing an Apply - the revisions don't get saved.
That's a bug. I think I have it fixed now. I have also added a new style of comments:

{this is a comment}

This will enable adding {d3} to the beginning of a line instead of after the # symbol.

I'll update to 2022.03.13, and then I'll be putting this on the back burner for a bit as I work on a PR.

Edit: 2022.03.13 now in addon manager
edwilliams16
Veteran
Posts: 3111
Joined: Thu Sep 24, 2020 10:31 pm
Location: Hawaii
Contact:

Re: Parametric Curve FP discussion board

Post by edwilliams16 »

I loaded the macro, switched to Amoeba, applied, and started adding a comment and got an error message.
Screen Shot 2022-03-13 at 9.37.42 AM.png
Screen Shot 2022-03-13 at 9.37.42 AM.png (167.33 KiB) Viewed 4567 times
TheMarkster
Veteran
Posts: 5505
Joined: Thu Apr 05, 2018 1:53 am

Re: Parametric Curve FP discussion board

Post by TheMarkster »

Okay. Another bug. I need to strip the comments there.
TheMarkster
Veteran
Posts: 5505
Joined: Thu Apr 05, 2018 1:53 am

Re: Parametric Curve FP discussion board

Post by TheMarkster »

latest version: 2022.03.13.rev2

Instead of updating the memory in the editor each time a line edit changes, I will update only when certain buttons are clicked or when changing selection in formula list box.
User avatar
hammax
Veteran
Posts: 1985
Joined: Thu Jan 19, 2017 5:03 pm
Location: Ammersee DE

Re: Parametric Curve FP discussion board

Post by hammax »

... helix between bottom and top diameter (not angle).
https://forum.freecadweb.org/viewtopic. ... 41#p580063
(got trouble by inside copy/paste of parametric_curve)
Attachments
PC_Helix_2.FCStd
FC.19.4
(138.48 KiB) Downloaded 48 times
TheMarkster
Veteran
Posts: 5505
Joined: Thu Apr 05, 2018 1:53 am

Re: Parametric Curve FP discussion board

Post by TheMarkster »

hammax wrote: Wed Mar 16, 2022 12:50 pm ... helix between bottom and top diameter (not angle).
https://forum.freecadweb.org/viewtopic. ... 41#p580063
(got trouble by inside copy/paste of parametric_curve)
What happened with copy/paste?

Maybe Paste should create a new formula and paste into it rather than paste into the current formula?
TheMarkster
Veteran
Posts: 5505
Joined: Thu Apr 05, 2018 1:53 am

Re: Parametric Curve FP discussion board

Post by TheMarkster »

New version: 2022.03.16

When copying to clipboard include also the name of the formula that was copied.
When pasting from clipboard rather than overwrite current formula, create a new one and paste into it. The name in the clipboard is used unless there is a conflict, in which case a default name (formula1, formula2, etc.) is selected for the new formula name and a warning is shown in the report view.
Fix a regression: after deleting formula, select the next row instead of row 0.
Post Reply