Bevel gear - module/script/tutorial

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
Jill Kitten
Posts: 3
Joined: Sat Jan 30, 2016 8:50 am

Re: Bevel gear - module/script/tutorial

Post by Jill Kitten »

Concerning the installation of FCGear:
=>1st: The instructions state to only copy the "gear" folder but there is no folder in the entire ZIP file called "gear", this is the folder structure after unpacking the ZIP file:

Code: Select all

FCGear-Master
  FCGear-Master
    examples
    gearfunc
    Resources
      icons
Were the file and folder names changed without updating the wiki [or the internal file references]?
The best supposition I can make is the SECOND [sub] folder named "FCGear-Master" is the intended target as I doubt the "gearfunc" folder would be the appropriate one since it would have no references to the icon resources and all the others don't even have the word 'gear' in the names.

=>2nd: When I do copy the folder "...\FCGear-Master\FCGear-Master\" to the "C:\Program Files\FreeCAD\v0.15\Mod\" folder [with admin prvldgs] and then run FreeCAD I get the error:
"During initialization the error 'module' object has no attribute 'Workbench' occurred in C:\Program Files\FreeCAD\v0.15\Mod\FCGear-Master\InitGui.py"
So I then change the name of the folder "C:\Program Files\FreeCAD\v0.15\Mod\FCGear-Master\" to C:\Program Files\FreeCAD\v0.15\Mod\Gear\" and close and restart FreeCAD then I still get a similar error:
"During initialization the error 'module' object has no attribute 'Workbench' occurred in C:\Program Files\FreeCAD\v0.15\Mod\Gear\InitGui.py"
So I am guessing that the folder name is not the issue here and there is something else going on.

In any case the bloody thing doesn't show up, so what can I do to get this working? I am not a python coder but I use several others [including assembly] and I understand its bad use of indentation as ending constructs [along w/other issues], so is there some tweek I can make in one [or more] of the files to fix this?

-Jill-

P.S. A constructive criticism: At first I wasn't sure what it was showing a graphic of but after closer inspection I noticed it was just a badly drawn and very hard to read word of "rack" in an icon, maybe you could have an icon that shows a rack gear graphic [similar to the others] instead to make it less confusing? :? e.g.:
InvoluteRack.png
InvoluteRack.png (3.37 KiB) Viewed 3360 times
OS: Windows 7
Word size of OS: 32-bit
Word size of FreeCAD: 32-bit
Version: 0.15.4671 (Git)
Branch: releases/FreeCAD-0-15
Hash: 244b3aef360841646cbfe80a1b225c8b39c8380c
Python version: 2.7.8
Qt version: 4.8.6
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17
FYI: Win7 and FreeCAD [v0.15.4671] word size is 32b, Python v2.7.8, Qt v4.8.6, Coin v4.0.0a, OCC v6.8.0.oce-0.17
User avatar
sgrogan
Veteran
Posts: 6499
Joined: Wed Oct 22, 2014 5:02 pm

Re: Bevel gear - module/script/tutorial

Post by sgrogan »

Jill Kitten wrote:The best supposition I can make is the SECOND [sub] folder named "FCGear-Master" is the intended target
This is correct. I can confirm the error on 0.15.4761 x64 installed.
The module works though with the latest 0.16-pre snapshot un-installed. I don't what is the difference yet.
You can get the latest snapshot here:https://github.com/freecad/freecad/releases
direct download link to the version you need:https://github.com/FreeCAD/FreeCAD/rele ... dev_bin.7z
Simply unzip anywhere on your sytem (do not overwrite the 0.15 installed version) and start FreeCAD by double clicking FreeCAD.exe from the bin folder inside the un-zipped folder. If you extract to a user directory (like the desktop or documents folder) you will not need admin priviledges to add extra modules. The installed and uninstalled versions are independent, only sharing your preferences file, so you will need to copy any extra modules to the Mod directory of the un-zipped folder.
Post back if you have further difficulties.
"fight the good fight"
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: Bevel gear - module/script/tutorial

Post by looo »

You are right. I have changed some things and didn't change the Readme and the other docs.
You need a recent version of FreeCAD to get this workbench working. The problem is that the class Workbench wasn't available outside freecad some time ago. This has changed, and I changed to "Gui.Workbench". I think writing only "Workbench" should also work with older versions of freecad. See here

The directory structure has changed because someone asked for this. I have updated the Readme. Hopefully it's better now.

Thanks for the icon. I have updated this too.
commit
Jill Kitten
Posts: 3
Joined: Sat Jan 30, 2016 8:50 am

Re: Bevel gear - module/script/tutorial

Post by Jill Kitten »

looo wrote:You are right. I have changed some things and didn't change the Readme and the other docs.
You need a recent version of FreeCAD to get this workbench working.
I wasn't planning on moving up till it was indicated as "officially" stable, as it is I have found serious problems with the supposed stable version of .15 [like lockups in specific situations since no inf loop safety was implemented {and I've only been using it a couple of days and found these}]. So for now I will stick w/.15 until they have hammered .16 as official.
looo wrote:I think writing only "Workbench" should also work with older versions of freecad.
Well I changed "class gearWorkbench(GUI.Workbench):" to "class gearWorkbench(Workbench):" and it does function now, simple enough, thank you for that. :D
looo wrote:The directory structure has changed because someone asked for this. I have updated the Readme. Hopefully it's better now.
I am glad to see your response to that request, I saw that example folder which is a good idea. I am not sure who put it up or who handles these things but now the only thing left is to update the wiki instructions [http://www.freecadweb.org/wiki/index.ph ... cro_FCGear] AND clarify that it will only work with .16+, that would be handy .

looo wrote:Thanks for the icon. I have updated this too.

You are welcome, I was considering also making one for the bevel icon that was more consistent with the look of the other icons, but I figured it was recognizable and was not really an issue. However since I already had an idea how I was going to do it, if you would like I could make that icon so it has that polished consistency look, it wouldn't even be a bother and I would be happy to help with that.

Now if I could fig the places the item naming is done so I can change it to use a Proper Case naming convention like the rest of FreeCAD [sweet consistency] and not the silly 'C' style alllowercasenaming_convention [e.g.: involute_gear -> InvoluteGear or Involute Gear], would you mind pointing where I could find that stuff like which files and let me know if the name handling is consolidated or dispersed in many locations? :?:

Thank you for your help on this... :D

-Jill-

[edit] P.S. Would it not be a good idea to keep a version that works with the official stable version of FreeCAD immediately available and linked with that official stable version [instead of just the version that doesn't work w/it] since that is the version most new people will go for and use? Or maybe have that be the base and keep the latest one that only works w/the unstable version under another folder with separate instructions?
Just a thought. :idea:
FYI: Win7 and FreeCAD [v0.15.4671] word size is 32b, Python v2.7.8, Qt v4.8.6, Coin v4.0.0a, OCC v6.8.0.oce-0.17
Jill Kitten
Posts: 3
Joined: Sat Jan 30, 2016 8:50 am

Re: Bevel gear - module/script/tutorial

Post by Jill Kitten »

Well I really liked having the rack icon change, I think its purpose is much more clear now, thank you for making that change. :D Until I figure out all the user visible naming stuff all I can do is tinker, and I knew it would only take me a few minutes to do it and I figured if you wanted it you would use it and if not you won't, so here is a version for the bevel gear icon:
BevelGear.png
BevelGear.png (3.98 KiB) Viewed 3280 times
Anyway, like I said, while I am proficient in several coding languages I am not a python coder, but if I were to guess, I would suspect these as some places were the item naming visible to the user could be changed?:

in ".\Gear\gearfunc\__init__.py"

Code: Select all

a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", "item_name")
in ".\Gear\gearfunc\_Classes.py"

Code: Select all

__all__=["involute_gear",
         "cycloide_gear",
         "bevel_gear", 
         "involute_gear_rack",
         "ViewProviderGear"]
in ".\Gear\__init__.py"

Code: Select all

__All__ = [
    "CreateInvoluteRack",
    "CreateCycloideGear",
    "CreateInvoluteGear",
    "CreateBevelGear",
    "involute_rack",
    "involute_tooth",
    "bevel_tooth"
]
in ".\Gear\InitGui.py"

Code: Select all

class gearWorkbench(Gui.Workbench):
    """glider workbench"""
    MenuText = "gear"
    ToolTip = "gear workbench"
    Icon = "gearworkbench.svg"
To make them 'Proper Case' would it be something like this?:

in ".\Gear\gearfunc\__init__.py"

Code: Select all

a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", "Item Base Name")
in ".\Gear\gearfunc\_Classes.py"

Code: Select all

__all__=["Involute Gear",
         "Cycloide Gear",
         "Bevel Gear", 
         "Involute Rack Gear",
         "ViewProviderGear"]
in ".\Gear\__init__.py"

Code: Select all

__All__ = [
    "CreateInvoluteRack",
    "CreateCycloideGear",
    "CreateInvoluteGear",
    "CreateBevelGear",
    "Involute Rack",
    "involute_tooth",
    "bevel_tooth"
]
in ".\Gear\InitGui.py"

Code: Select all

class gearWorkbench(Workbench):
    """glider workbench"""
    MenuText = "Gear"
    ToolTip = "Gear Workbench"
    Icon = "gearworkbench.svg"
Any tips would be handy and would save me some time [and probably some heartache] and in turn would be greatly appreciated.

Thanks for your help so far. ;)

-Jill-
FYI: Win7 and FreeCAD [v0.15.4671] word size is 32b, Python v2.7.8, Qt v4.8.6, Coin v4.0.0a, OCC v6.8.0.oce-0.17
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: Bevel gear - module/script/tutorial

Post by looo »

I am glad to see your response to that request, I saw that example folder which is a good idea. I am not sure who put it up or who handles these things but now the only thing left is to update the wiki instructions [http://www.freecadweb.org/wiki/index.ph ... cro_FCGear] AND clarify that it will only work with .16+, that would be handy

I am sorry, I have never done anything on the wiki. Maybe someone else can respond to this. I think you have to ask for permissions and then log into the wiki on the top right of the page.

I am glad to see your response to that request, I saw that example folder which is a good idea. I am not sure who put it up or who handles these things but now the only thing left is to update the wiki instructions [http://www.freecadweb.org/wiki/index.ph ... cro_FCGear] AND clarify that it will only work with .16+, that would be handy .


I have updated this. It should work now also with older version but prints a warning at start.

Now if I could fig the places the item naming is done so I can change it to use a Proper Case naming convention like the rest of FreeCAD [sweet consistency] and not the silly 'C' style alllowercasenaming_convention [e.g.: involute_gear -> InvoluteGear or Involute Gear], would you mind pointing where I could find that stuff like which files and let me know if the name handling is consolidated or dispersed in many locations?


I like "an_object" for objects and "a_function" for a function and "AClass" for a class. I don't know what the best way is, but naming is for sure a very important thing. The gear workbench is from the days where I wasn't confident with python and FreeCAD, so there are many inconsistent things. So you are welcome to beautify the code.

__all__ isn't that important. It is used for "from a import *". All the names liststed in __all__ get imported that way, no others. I wouldn't use this anymore. A better way to import stuff is not using *. "from this import something" makes more sense, because someone who reads the code see where "something" comes from.

I think some auto-complete system use __all__ to give proposals. But the FreeCAD console shows simple everything. Also names beginning with __ which are normally like private members/functions are shown (even as first entries :shock: ).But be carefull with ranting about freecad. It is possible that this is fixed the next day ;)

I think I have changed most of your proposals. Maybe you can try using git. Then you can make changes and ask for merging this changes directly.
jmaustpc
Veteran
Posts: 11207
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: Bevel gear - module/script/tutorial

Post by jmaustpc »

Jill Kitten wrote:I wasn't planning on moving up till it was indicated as "officially" stable, as it is I have found serious problems with the supposed stable version of .15 [like lockups in specific situations since no inf loop safety was implemented {and I've only been using it a couple of days and found these}]. So for now I will stick w/.15 until they have hammered .16 as official.
Sticking to FreeCAD "stable" or "release" versions is for most a waste of time as it almost never will get any bug fixes or development, the dev version i.e. master is almost always the best most stable FreeCAD as for example right now its got over 1500 bug fix and feature update commits beyond 0.15. For example 0.15 was obsolete within a few days of release for anyone working on FEM. 0.16 has expressions ....and so much more...

The only thing that is stable about the "stable" or "release" versions is that the api does not change so it helps anyone wanting a "stable" api to write extensions and add ons etc.

Developers work in branches and they pushed their code to master in generally pretty good condition.

This idea of being frighten off using a dev versions and thinking your being safe with a "stable" version is common with Windows users it would appear but is usually just a miss-understanding ....hence we discussed this some time back and stopped using the term "unstable" to describe the dev version.
User avatar
wandererfan
Veteran
Posts: 6268
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Bevel gear - module/script/tutorial

Post by wandererfan »

Jill Kitten wrote:I am glad to see your response to that request, I saw that example folder which is a good idea. I am not sure who put it up or who handles these things but now the only thing left is to update the wiki instructions [http://www.freecadweb.org/wiki/index.ph ... cro_FCGear] AND clarify that it will only work with .16+, that would be handy .


http://www.forum.freecadweb.org/viewtop ... =21&t=6830
User avatar
Zuzzuk
Posts: 9
Joined: Fri Apr 27, 2018 5:13 pm
Location: Prague, Czech Republic
Contact:

Re: Bevel gear - module/script/tutorial

Post by Zuzzuk »

Hi looo,

Thank you for this useful instrument.
I've installed FreeCAD 0.18 and installed Gear WB using Addon Manager.
The only thing I was not able to get from documentation and the this topic: if I'd set teeth number (n) to 15, and module (m) to 1mm, then I believe pitch diameter (PD) should be 15mm (PD = n*m). But I can't find this diameter at the generated gear - neither to nor bottom surfaces of the gear doesn't correspond to this PD.
Could you please help me to create a pitch with PD=15mm at its wider side?

Also I've opened your example of Bevel gear from GitHub, and there is Bevel gear generated and its cone tip matches with origin of coordinates, but if I'd create Bevel gear with the same parameters, then it's created "sitting" by its wider side at the XY plane (z=0). I haven't found any position changes at the example file.
Please see picture attached.
Image
Thank you
Regards Konstantin
// per aspera ad astra
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: Bevel gear - module/script/tutorial

Post by looo »

Zuzzuk wrote: Fri Jan 24, 2020 7:01 pm The only thing I was not able to get from documentation and the this topic: if I'd set teeth number (n) to 15, and module (m) to 1mm, then I believe pitch diameter (PD) should be 15mm (PD = n*m). But I can't find this diameter at the generated gear - neither to nor bottom surfaces of the gear doesn't correspond to this PD.
Could you please help me to create a pitch with PD=15mm at its wider side?
m is the module of the profile defined at the center of the gear (for bevel gears the module is varying, so defining a gear is a bit different from involute gears) Anyway, I suggest to use primitives (Part Cone) or Sketcher Geometry (Revolve) to create the basic geometry and then add the teeth with an overlapping gear and boolean operations. To get an overlapping gear vary the parameters hight and module.

For the base-geometry, you can have a look at the example here. In the end a ittle bit of math is unavoidable ;)
https://forum.freecadweb.org/viewtopic. ... 20#p103661

Also I've opened your example of Bevel gear from GitHub, and there is Bevel gear generated and its cone tip matches with origin of coordinates, but if I'd create Bevel gear with the same parameters, then it's created "sitting" by its wider side at the XY plane (z=0). I haven't found any position changes at the example file.
There is a property reset origin. Switching this to off will place the gear as it is placed in the example.
Post Reply