Scripted Parts: Ball Bearing - Part 1/de: Difference between revisions

From FreeCAD Documentation
(Created page with "===Einleitung=== Dieses Tutorial ist gedacht als Einführung wie man Modelle erstellt mit Hilfe von Python Skripten innerhalb von FreeCAD.<br /> Dieses Tutorial erklärt wie m...")
(Created page with "===Arbeitsablauf=== Der Arbeitsablauf ist mehr oder weniger identisch mit dem Ablauf, mit dem Sie ein Modell im Arbeitsbereich "Part" erstellen würden.<br /> Es gibt nur weni...")
Line 18: Line 18:




===Workflow===
===Arbeitsablauf===
Der Arbeitsablauf ist mehr oder weniger identisch mit dem Ablauf, mit dem Sie ein Modell im Arbeitsbereich "Part" erstellen würden.<br />
The workflow is more or less identical how you would create the part in part workbench.<br />
Just some small differences.<br />
Es gibt nur wenige Unterschiede.<br />
*Erstelle ein neues leeres Dokument und mache es zum aktiven Dokument
*Create a new empty document and make it the active document
*Einfügen eines Zylinders
*Insert Cylinder
*Einfügen eines Zylinders
*Insert Cylinder
*Durchführung einer boolschen Verschneidung um die grundlegende Form des inneren Ringes zu bekommen
*Do boolean cut to get basic shape of inner ring
*Alle Kanten auswählen und einen Radius anbringen
*Select all edges and apply a fillet
*Einfügen eines Torus
*Insert torus
*Bewege den Torus in die korrekte Position und führe eine boolsche Verschneidung durch um die Rille für die Kugeln zu bekommen
*Move torus into position and do a boolean cut to create the groove for the balls
*Wiederhole alle Schritte um den äußeren Ring zu erstellen
*Repeat all steps for getting the shape for the outer ring
*Einfügel der ersten Kugel
*Insert first ball
*Einfügen der restlichen Kugeln und benutzen von Formeln um die korrekten Positionen der Kugeln zu berechnen
*Insert other balls using math to calculate the position of the balls
*Wechsle in die axometrische Ansicht
*Set view to axometric
*Zoom to fit all
*Zoom auf Alles





Revision as of 21:11, 28 August 2016

Tutorium
Thema
Part Scripting - Ball Bearing #1
Niveau
Beginner
Zeit zum Abschluss
30 min
Autoren
r-frank
FreeCAD-Version
0.16.6706
Beispieldateien
Siehe auch
None


Einleitung

Dieses Tutorial ist gedacht als Einführung wie man Modelle erstellt mit Hilfe von Python Skripten innerhalb von FreeCAD.
Dieses Tutorial erklärt wie man ein Kugellager erstellt mittels eines CSG-Arbeitsablaufes.
Der Code wird ein neues FreeCAD-Dokument erstellen mit 12 einzelnen Körpern (Innerer Ring, äußerer Ring und 10 Kugeln).
Da Ergebnis sieht so aus:


Arbeitsablauf

Der Arbeitsablauf ist mehr oder weniger identisch mit dem Ablauf, mit dem Sie ein Modell im Arbeitsbereich "Part" erstellen würden.
Es gibt nur wenige Unterschiede.

  • Erstelle ein neues leeres Dokument und mache es zum aktiven Dokument
  • Einfügen eines Zylinders
  • Einfügen eines Zylinders
  • Durchführung einer boolschen Verschneidung um die grundlegende Form des inneren Ringes zu bekommen
  • Alle Kanten auswählen und einen Radius anbringen
  • Einfügen eines Torus
  • Bewege den Torus in die korrekte Position und führe eine boolsche Verschneidung durch um die Rille für die Kugeln zu bekommen
  • Wiederhole alle Schritte um den äußeren Ring zu erstellen
  • Einfügel der ersten Kugel
  • Einfügen der restlichen Kugeln und benutzen von Formeln um die korrekten Positionen der Kugeln zu berechnen
  • Wechsle in die axometrische Ansicht
  • Zoom auf Alles


Filleting edges

In part workbench using the GUI, you would select chamfers in the 3D view or in the menu for fillets and then apply the fillets.
Here we select all edges of a shape and apply fillets.
Therefore we need to select the edges BEFORE creating the groove.


Notes

This tutorial is using part primitives and boolean operations, which can be performance consuming.
For doing a scripted part with revolved sketches have a look at the tutorial Scripted Parts: Ball Bearing - Part 2.


Links

Scripted objects: The wiki page explaing the basics of scripting
Topological data scripting: A tutorial for covering basics of scripting
Scripted Parts: Ball Bearing - Part 2: Doing it with sketches
Bearing Script 1: Base for this tutorial, thanks to JMG ...


Code

## Ball-bearing script
## 11.08.2016 by r-frank (BPLRFE/LearnFreeCAD on Youtube)
## based on ball bearing script by JMG
## (http://linuxforanengineer.blogspot.de/2013/08/free-cad-bearing-script.html)
#
#needed for inserting primitives
import Part
#needed for calculating the positions of the balls
import math
#needed for translation of torus
from FreeCAD import Base
#
#VALUES#
#(radius of shaft/inner radius of inner ring)
R1=15.0
#(outer radius of inner ring)
R2=25.0
#(inner radius of outer ring)
R3=30.0
#(outer radius of outer ring)
R4=40.0
#(thickness of bearing)
TH=15.0
#(number of balls)
NBall=10
#(radius of ball)
RBall=5.0
#(rounding radius for fillets)
RR=1
#first coordinate of center of ball
CBall=((R3-R2)/2)+R2
#second coordinate of center of ball
PBall=TH/2
#
#Create new document
App.newDocument("Unnamed")
App.setActiveDocument("Unnamed")
App.ActiveDocument=App.getDocument("Unnamed")
Gui.ActiveDocument=Gui.getDocument("Unnamed")
#
#Inner Ring#
B1=Part.makeCylinder(R1,TH)
B2=Part.makeCylinder(R2,TH)
IR=B2.cut(B1)
#get edges and apply fillets
Bedges=IR.Edges
IRF=IR.makeFillet(RR,Bedges)
#create groove and show shape
T1=Part.makeTorus(CBall,RBall)
T1.translate(Base.Vector(0,0,TH/2))
InnerRing=IRF.cut(T1)
Part.show(InnerRing)
#
#Outer Ring#
B3=Part.makeCylinder(R3,TH)
B4=Part.makeCylinder(R4,TH)
OR=B4.cut(B3)
#get edges and apply fillets
Bedges=OR.Edges
ORF=OR.makeFillet(RR,Bedges)
#create groove and show shape
T2=Part.makeTorus(CBall,RBall)
T2.translate(Base.Vector(0,0,TH/2))
OuterRing=ORF.cut(T2)
Part.show(OuterRing)
#
#Balls#
for i in range(NBall):
  Ball=Part.makeSphere(RBall)
  Alpha=(i*2*math.pi)/NBall
  BV=(CBall*math.cos(Alpha),CBall*math.sin(Alpha),TH/2)
  Ball.translate(BV)
  Part.show(Ball)
#
#Make it pretty#
App.activeDocument().recompute()
Gui.activeDocument().activeView().viewAxometric()
Gui.SendMsgToActiveView("ViewFit")