I had tested only with a dd object and its float property. It looks like fc(expr) struggles with units, such 10 mm. I'll see if I can fix it.edwilliams16 wrote: ↑Fri Mar 11, 2022 1:25 am I must be missing something because I can't make this work at all. If I have a file with nothing but a Part.Cylinder, in the Python Console I getCode: Select all
>>> App.DocumentObject.evalExpression(Cylinder.Height) Traceback (most recent call last): File "<input>", line 1, in <module> NameError: name 'Cylinder' is not defined >>> App.DocumentObject.evalExpression(<<Cylinder>>.Height) File "<input>", line 1 App.DocumentObject.evalExpression(<<Cylinder>>.Height) ^ SyntaxError: invalid syntax >>>
Parametric Curve FP discussion board
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
-
- Veteran
- Posts: 5505
- Joined: Thu Apr 05, 2018 1:53 am
Re: Parametric Curve FP discussion board
-
- Veteran
- Posts: 5505
- Joined: Thu Apr 05, 2018 1:53 am
Re: Parametric Curve FP discussion board
Add .Value to the end of line 292.
Code: Select all
# evaluated = FreeCAD.ActiveDocument.ActiveObject.evalExpression(fc_Eval).Value
-
- Veteran
- Posts: 5505
- Joined: Thu Apr 05, 2018 1:53 am
Re: Parametric Curve FP discussion board
New version: 2022.03.10.rev5
fix bug in fc(expr) so it handles unit quantities
Note: fc(expr) will always return a unitless value. For example, if fc(Cylinder.Height) is used and the height is 10 mm, the return value is 10.0.
fix bug in fc(expr) so it handles unit quantities
Note: fc(expr) will always return a unitless value. For example, if fc(Cylinder.Height) is used and the height is 10 mm, the return value is 10.0.
-
- Veteran
- Posts: 5505
- Joined: Thu Apr 05, 2018 1:53 am
Re: Parametric Curve FP discussion board
New version:
2022.03.10.rev6
After deleting formula from list, select the next item in the list instead of the first item. This way it is easier to delete multiple items.
2022.03.10.rev6
After deleting formula from list, select the next item in the list instead of the first item. This way it is easier to delete multiple items.
-
- Veteran
- Posts: 5505
- Joined: Thu Apr 05, 2018 1:53 am
Re: Parametric Curve FP discussion board
New version 0.2022.03.11
Fixed a bug in fc(expr) where now it wasn't handling well unitless expressions.
Nested fc(fc(expr)) is not supported, so check for that and report the error.
Fixed a bug in fc(expr) where now it wasn't handling well unitless expressions.
Nested fc(fc(expr)) is not supported, so check for that and report the error.
-
- Veteran
- Posts: 5505
- Joined: Thu Apr 05, 2018 1:53 am
Re: Parametric Curve FP discussion board (latest: 0.2022.03.09)
math.degrees and math.radians are both supported.edwilliams16 wrote: ↑Thu Mar 10, 2022 9:56 am Screen Shot 2022-03-09 at 11.51.49 PM.pngScreen Shot 2022-03-09 at 11.53.16 PM.png
Easy enough to rotate - but I think would be better done by playing with the attachment, which is likely going to be used anyway. Could also change the input angle to dgrees?
For example, sin(radians(30)) = sin(pi/6). Speaking just for me, I find angles in degrees are more intuitive than radians.
>>>
>>> from Parametric_Curve_FP import evaluate
>>> evaluate("sin(pi/6)")
0.49999999999999994
>>> evaluate("sin(radians(30))")
0.49999999999999994
>>> evaluate("degrees(pi/6)")
29.999999999999996
>>>
I have noticed also there is some trouble occasionally with the Part::Helix primitive due to its segmented structure, particularly when it comes to rendering sweeps along such helices. It could be useful to have a helix formula that also allows for angles.
-
- Veteran
- Posts: 3106
- Joined: Thu Sep 24, 2020 10:31 pm
- Location: Hawaii
- Contact:
Re: Parametric Curve FP discussion board
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", "a + 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.01"}}
-
- Veteran
- Posts: 3106
- Joined: Thu Sep 24, 2020 10:31 pm
- Location: Hawaii
- Contact:
Re: Parametric Curve FP discussion board
I got Part|Sweep to work nicely with the above helix - but I couldn't get Part Design|Additive Pipe to sweep a circle properly. It could be I'm not doing it right...
-
- Veteran
- Posts: 3106
- Joined: Thu Sep 24, 2020 10:31 pm
- Location: Hawaii
- Contact:
Re: Parametric Curve FP discussion board
The problem was my helix parametric curve had much too fine a resolution. Reducing interval to 0.1 Part design works fine.
Use this:
Use this:
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", "a + 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"}}
-
- Veteran
- Posts: 5505
- Joined: Thu Apr 05, 2018 1:53 am
Re: Parametric Curve FP discussion board
That looks great. I'll add it and the other modification of the angled ellipse to the default set of formulas for the next update.
Edit: Can you post the full formula for the angled ellipse?
Edit: Can you post the full formula for the angled ellipse?