## BTool is almost here!

(this version is outdated, click here to get the new BTool version)

This is, maybe, the most complex thing that I have never programmed, isn't finished yet..
Is dirty, has bugs and lacks, but will be improved in a future.

And that's all!

### How to use it:

At the moment all BTool functions are commands but when finished you will be able to place nice bearings without typing a word of code at all.

Inside the FreeCAD python console, import the libraries:

from BTool import *

### Automatic Placement

This is really what I wanted to achieve, although it works very rough at the moment,  select a circumference (cylinder edge) and then type at command line:

BTool()

The proper bearing should be placed automatically. This only works for shafts and the deep groove single row ball bearing type at the moment.

You can try to rotate and translate a cylinder and then repeat the above. The bearing will be placed on the desired position too!

...or should, if you try few positions, you will find that sometimes the bearing is not aligned with the shaft. I'm working to solve that, without success by now.

### Manual Input Placement

To place the most suitable bearing for a known dimension the command is:

BTool(dim,dimtype,btype,pos,normal)

The dim parameter equals to the magnitude you want to search.

The dimtype parameter sets which kind of dimension represents dim magnitude

A bearing has 3 main dimensions, inner radius, outer radius and width.

Possible values of dimtype and their meaning:

2 --> width

The dimtype conditions wich bearing will be selected from the list:

-If you select inner radius, the inner radius of the bearing will be equal or greater than the input magnitude, assuming you want to put a bearing in a shaft

-If you select outer radius, the outer radius of the bearing will be smaller or equal to the input magnitude, assuming you want to put a bearing in a hole.

-For the width there is no special function yet and will select the first bearing greater or equal.

The btype parameter means bearing type, at the moment 0 for the Deep Groove Single Row Ball Bearing and 1 for Deep Groove Double Row Ball Bearing.

The arguments pos and normal are optional. They contain vector coordinates, being pos the location of the bearing (x,y,z) and normal the axial direction of the bearing (x,y,z)

This way, the shortest command we need to manually create a bearing is, for example:

BTool(10)

That will find a Deep Groove Single Row Ball Bearing with inner radius greater or equal to 10 units and spawn it at (0,0,0)

### Adding more bearing dimensions and types:

I've developed this tool with the end user in mind. To add more dimensions of a existing type of bearing, just copy paste the inner diameter, outer diameter, width and description to their respective fields. That should be all.
Of course, the search method has to be improved and by the moment there is no way to add new types of bearings easily, this will be solved in a future.

And his is the current state of the project.

The dialog box is almost working, and will be out once I solve the placement problems.

1. Hi!,
I would change beginning of BSearch.py file to:
import csv
import os.path
import sys

with open(os.path.abspath(os.path.join(os.path.dirname(__file__), 'BearingsData.csv')),'Ur') as f: