Scripted Parts: Ball Bearing - Part 2/it

Introduzione
Questo tutorial si propone di introdurre i principianti alla creazione di parti con script python all'interno di FreeCAD.

Questo tutorial descrive come costruire un cuscinetto a sfere con un flusso di lavoro che consiste nel creare degli schizzi e rivoluzionarli.

Il codice produrrà un nuovo documento di FreeCAD con 12 forme (anello interno, anello esterno e 10 sfere).

Esso sarà simile a questo:



Workflow
The workflow is more or less identical how you would create the part in part design workbench.

Just some small differences.


 * Create a new empty document and make it the active document
 * Draw the basic shape of the outer ring consisting of four straight lines and four arcs
 * Connect the lines and arcs and upgrade them to one single wire
 * Upgrade the wire to a face
 * Revolve the face to get a shape
 * Draw a circle
 * Upgrade circle to wire
 * Upgrade wire to face
 * Revolve face and apply boolean cut to obtain groove in outer ring
 * Draw the basic shape of the inner ring consisting of four straight lines and four arcs
 * Connect the lines and arcs and upgrade them to one single wire
 * Upgrade the wire to a face
 * Revolve the face to get a shape
 * Draw a circle
 * Upgrade circle to wire
 * Upgrade wire to face
 * Revolve face and apply boolean cut to obtain groove in inner ring
 * Insert balls with same workflow as in part 1 (because of effectiveness)
 * Set view to axometric
 * Zoom to fit all

Making the groove
Drawing an arc needs either three points or a start angle and an end angle.

In the sketcher we would use constraints to define the start point and the end point of the arc.

Since we can't do this in scripting, we draw a rounded rectangle and revolve it to get a basic "ring shape".

Then we draw a circle and revolve it to get the geometry of the groove.

Then we apply a boolean cut to the two revolved shapes and we have the complete shape of the inner/outer ring.

Inserting the balls
The correct sketcher-based workflow of inserting the balls would be:


 * Draw an arc (semi-circle) with center being identical with the origin and draw a line closing the "open" side of the arc
 * Convert the two elements to a wire, upgrade to a face, revolve around z-axis to get a ball shape
 * Use "translate" command to move the ball into correct position
 * Repeat the above steps nine times involving math function to create and position the other balls
 * This repeat-operation could be programmed with a loop

Now this is not effective, inserting primitives and positioning them is easier and faster in this case.

So we use the same method as in "Scripted Parts: Ball Bearing - Part 1".

Link
Script di oggetti: La pagina wiki che spiega i principi fondamentali di scripting

Script di dati topologici: Un tutorial per fornire le basi di scripting

Parti con script: Cuscinetto a sfere - Parte 1: Costruirlo con primitive di Parte

Bearings from scripted sketches: Base per questo tutorial, grazie a JMG ...