freecad.gears icon indicating copy to clipboard operation
freecad.gears copied to clipboard

Fix #84 and #63 by float conversion int(float( version_string )) >= 18

Open uDude opened this issue 2 years ago • 5 comments

Fix #63 by change version check from 19 to 18 (required for Mac users according to issue).

uDude avatar Oct 28 '21 19:10 uDude

Just changing the check from ">= 19" to ">= 18" may fall a bit short. According to this form discussion the change was made during the 0.19 release cycle. If now also 0.18 requires this check, it has to be due to the change being backported into a 0.18.x release appearing after the initial 0.19 release. This means, also the patch-level (i.e. App.Version()[2]) needs to be checked, when the minor (App.Version()[1]) is 18.

jbaehr avatar Nov 01 '21 11:11 jbaehr

Ok.

Note that the current check fails if the versionstring contains a decimal. int('19.8') --> error

hence the change from "int(version_string)" to "int(float(version_string))" is needed regardless of the RHS of the expression. Or just "float(version_string)" depend on whether or not you want ot check major or major.minor version.

uDude avatar Nov 02 '21 20:11 uDude

Note that the current check fails if the versionstring contains a decimal. int('19.8') --> error

That looks very strange, indeed (where "strange" means "completely unexpected to me"). In which version did you observe this? What is printed if you write App.Version() in FreeCAD's python console?

jbaehr avatar Nov 02 '21 21:11 jbaehr

I encountered this issue in FreeCAD 0.18.4 on Ubuntu 20.04.4 LTS, and can confirm that coercing the App.Value()[1] str to a float before coercing it to an int solved the issue. I can't speak on the 18 vs. 19 issue though, as I left that part of the statement alone.

Here's the error that I was getting before updating the code:

Running the Python command 'CreateInvoluteGear' failed:
Traceback (most recent call last):
  File "/home/crimson/.FreeCAD/Mod/freecad.gears-master/freecad/gears/commands.py", line 47, in Activated
    Gui.doCommandGui("freecad.gears.commands.{}.create()".format(
  File "<string>", line 1, in <module>
  File "/home/crimson/.FreeCAD/Mod/freecad.gears-master/freecad/gears/commands.py", line 66, in create
    cls.GEAR_FUNCTION(obj)
  File "/home/crimson/.FreeCAD/Mod/freecad.gears-master/freecad/gears/features.py", line 120, in __init__
    super(InvoluteGear, self).__init__(obj)
  File "/home/crimson/.FreeCAD/Mod/freecad.gears-master/freecad/gears/features.py", line 80, in __init__
    self.make_attachable(obj)
  File "/home/crimson/.FreeCAD/Mod/freecad.gears-master/freecad/gears/features.py", line 87, in make_attachable
    if int(App.Version()[1]) >= 19:

invalid literal for int() with base 10: '18.4'

App.Version()[1] prints 18.4 (type str) in the console,

Crimson-Yeti avatar Apr 14 '22 07:04 Crimson-Yeti

ping @looooo (just checking on this PR, any progress?)

luzpaz avatar Feb 01 '23 01:02 luzpaz