looooo / freecad.gears

a gear module for freecad
GNU General Public License v3.0
252 stars 95 forks source link

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

Open uDude opened 2 years ago

uDude commented 2 years ago

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

jbaehr commented 2 years ago

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.

uDude commented 2 years ago

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.

jbaehr commented 2 years ago

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?

Crimson-Yeti commented 2 years ago

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,

luzpaz commented 1 year ago

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