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!
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 »

... OK, calling a "fresh" parametric-curve, renaming it and delete the surplus formulas, seems to be the save way!

Spring_2.PNG
Spring_2.PNG (52.06 KiB) Viewed 10524 times
Attachments
PC_Helix_3.FCStd
FC.19.4
(178.29 KiB) Downloaded 69 times
TheMarkster
Veteran
Posts: 5505
Joined: Thu Apr 05, 2018 1:53 am

Re: Parametric Curve FP discussion board

Post by TheMarkster »

hammax wrote: Thu Mar 17, 2022 10:15 am ... OK, calling a "fresh" parametric-curve, renaming it and delete the surplus formulas, seems to be the save way!


Spring_2.PNG
What is an unsafe way? I want them all to be safe.
TheMarkster
Veteran
Posts: 5505
Joined: Thu Apr 05, 2018 1:53 am

Re: Parametric Curve FP discussion board

Post by TheMarkster »

New version 0.2022.05.04

Fixes a bug where if the previously active object is deleted, then the fc() function fails. fc() uses DocumentObject.evalExpression(), but for some reason the static function fails, and it's not compatible with earlier versions anyway, so I was using FreeCAD.ActiveDocument.ActiveObject.evalExpression(), but if the active object is deleted then evalExpression fails. The workaround is to use FreeCAD.ActiveDocument.Objects[0].evalExpression() instead.
User avatar
Vincent B
Veteran
Posts: 4713
Joined: Sun Apr 05, 2015 9:02 am
Location: La Rochelle, France

Re: Parametric Curve FP discussion board

Post by Vincent B »

Need a comma here and a point here...? should have both choices isn't it?
other thinking: it need have more precision like 4 or 5 beyond the comma. And can use "pi" expression with t parameter.
Attachments
Capture.JPG
Capture.JPG (23.76 KiB) Viewed 10005 times
TheMarkster
Veteran
Posts: 5505
Joined: Thu Apr 05, 2018 1:53 am

Re: Parametric Curve FP discussion board

Post by TheMarkster »

Updated to version 2022.12.16

There was a bug in updating from spreadsheet function when using d1, d2, d3, etc.
AndrewCSP
Posts: 45
Joined: Sun Jun 02, 2019 8:02 pm

Re: Parametric Curve FP discussion board

Post by AndrewCSP »

Finally got the macro to do what I want. It seems that t_max cannot refer to a previous [fixed] value and must be numeric. I am laying out a 2D cam profile, so I had a #pitch and #base radius as the built-in example, but instead of #height I had a value for the arc angle of the cam (75 degrees) in b. I tried to use that as the t-max limit (ie. "=b"), but it throws an error.
The error can be reproduced by simply replacing the t-max value in the built-in example by "=b" instead of 6.28. I know its a slightly different value but its just to demonstrate the point.

In other words, I wanted to have all my user accessible parameters in the Equation1(a,b,c) fields. Can t_max and t_min not refer to the Equation1 values or the Floats?
TheMarkster
Veteran
Posts: 5505
Joined: Thu Apr 05, 2018 1:53 am

Re: Parametric Curve FP discussion board

Post by TheMarkster »

The T params are floating point property types whereas the others are string property types that are interpreted during the loop. In the editor dialog (double click the Parametric Curve object) you can use something like 2*pi for the t_max value, which gets evaluated when the dialog closes. But I don't think you can refer to a, b, c, etc. from there. It's been a while since I worked on this and the code is not as fresh in my mind.
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 »

... trying to calculate the lifting force of a hydrofoil, dependent of speed (quadratic) and area,
by using Parametric_Curve and a FreeCAD presentation.
https://de.wikipedia.org/wiki/Dynamischer_Auftrieb

For e.g.: https://forum.freecadweb.org/viewtopic. ... 84#p655384

First using only a series of parabola in Parametric_Curve,
than trying to do that with the Link feature - but that didn't work (???).
Finding that this also could be done with only 1 Parametric_Curve and an edge in Ruled_Surface.

Better using plane, array => section AND approximate = true

Lifting_Force_Map_2.png
Lifting_Force_Map_2.png (126.3 KiB) Viewed 9413 times
Attachments
Lifting_Force_Map.FCStd
FC.20.1
(246.15 KiB) Downloaded 46 times
TheMarkster
Veteran
Posts: 5505
Joined: Thu Apr 05, 2018 1:53 am

Re: Parametric Curve FP discussion board

Post by TheMarkster »

New version: 2023.05.06

Thanks to Ed for adding the copysign() function and for documenting previously undocumented sgn() function in the readme.
edwilliams16
Veteran
Posts: 3106
Joined: Thu Sep 24, 2020 10:31 pm
Location: Hawaii
Contact:

Re: Parametric Curve FP discussion board

Post by edwilliams16 »

hammax wrote: Sat Jan 28, 2023 3:25 pm ... trying to calculate the lifting force of a hydrofoil, dependent of speed (quadratic) and area,
by using Parametric_Curve and a FreeCAD presentation.
Cool. Takes advantage of the linearity with Area, so you can construct with a Ruled Surface. viewtopic.php?t=75242 is a more general but related method, where the second variable dependence is non-linear - say with angle of attack. Using Sections is a nice way to get the coordinate lines! Curves|isoLines would also do it as long as even spacing is OK.
Post Reply