Scripted Parts: Ball Bearing - Part 1/it: Difference between revisions
Renatorivo (talk | contribs) (Created page with "===Link=== Script di oggetti: La pagina wiki che spiega i principi fondamentali di scripting<br /> Topological data scripting/it|Script di dati topol...") |
(Updating to match new version of source page) |
||
(5 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
⚫ | |||
{{TutorialInfo/it |
{{TutorialInfo/it |
||
|Topic= Parti con script - Cuscinetto a sfere #1 |
|Topic= Parti con script - Cuscinetto a sfere #1 |
||
Line 18: | Line 19: | ||
=== |
===Flusso di lavoro=== |
||
Il flusso di lavoro è quasi identico a quello che si dovrebbe usare per creare la parte nell'ambiente Part. |
|||
The workflow is more or less identical how you would create the part in part workbench.<br /> |
|||
Solo alcune piccole differenze. |
|||
Just some small differences.<br /> |
|||
*Creare un nuovo documento vuoto e renderlo attivo |
|||
*Create a new empty document and make it the active document |
|||
*Inserire un Cilindro |
|||
*Insert Cylinder |
|||
*Inserire un Cilindro |
|||
*Insert Cylinder |
|||
*Fare un taglio booleano per ottenere la forma di base dell'anello interno |
|||
*Do boolean cut to get basic shape of inner ring |
|||
*Selezionare tutti i bordi e applicare un raccordo |
|||
*Select all edges and apply a fillet |
|||
*Inserire un Toro |
|||
*Insert torus |
|||
*Spostare il toro in posizione e fare un taglio booleano per creare la scanalatura per le sfere |
|||
*Move torus into position and do a boolean cut to create the groove for the balls |
|||
*Ripetere tutti i passaggi per ottenere la forma per l'anello esterno |
|||
*Repeat all steps for getting the shape for the outer ring |
|||
*Inserire prima sfera |
|||
*Insert first ball |
|||
*Inserire le altre sfere usando math per calcolare la loro posizione |
|||
*Insert other balls using math to calculate the position of the balls |
|||
*Impostare la vista assonometrica |
|||
*Set view to axometric |
|||
*Zoom per adattare la vista alla finestra |
|||
*Zoom to fit all |
|||
=== |
===Raccordare i bordi=== |
||
Nell'ambiente Part utilizzando la GUI, è necessario selezionare i raccordi nella vista 3D o nel menu per i raccordi e poi applicare i raccordi.<br /> |
|||
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.<br /> |
|||
Qui si selezionano tutti i bordi di una forma e poi si applicano i raccordi.<br /> |
|||
Here we select all edges of a shape and apply fillets.<br /> |
|||
Quindi bisogna selezionare i bordi prima di creare la scanalatura. |
|||
Therefore we need to select the edges BEFORE creating the groove. |
|||
=== |
===Note=== |
||
Questo tutorial utilizza le primitive di Parte e le Operazioni booleane, che consumano molte risorse.<br /> |
|||
This tutorial is using part primitives and boolean operations, which can be performance consuming.<br /> |
|||
Per fare un script di Part usando degli schizzi rivoluzionati vedere il tutorial [[Scripted Parts: Ball Bearing - Part 2/it|Parti con script: Cuscinetto a sfere - Parte 2 ]]. |
|||
Line 53: | Line 54: | ||
=== |
===Codice=== |
||
{{Code|code= |
{{Code|code= |
||
## Ball-bearing script |
## Ball-bearing script |
||
Line 136: | Line 137: | ||
{{Powerdocnavi{{#translation:}}}} |
|||
[[Category:Developer Documentation{{#translation:}}]] |
|||
[[Category:Python Code{{#translation:}}]] |
|||
{{clear}} |
{{clear}} |
||
⚫ |
Latest revision as of 21:33, 23 August 2020
Tutorial |
Argomento |
---|
Parti con script - Cuscinetto a sfere #1 |
Livello di difficoltà |
Base |
Tempo di esecuzione |
30 min |
Autori |
r-frank |
Versione di FreeCAD |
0.16.6706 |
Files di esempio |
Vedere anche |
Nessuno |
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 CSG.
Il codice produrrà un nuovo documento di FreeCAD con 12 forme (anello interno, anello esterno e 10 sfere).
Esso sarà simile a questo:
Flusso di lavoro
Il flusso di lavoro è quasi identico a quello che si dovrebbe usare per creare la parte nell'ambiente Part. Solo alcune piccole differenze.
- Creare un nuovo documento vuoto e renderlo attivo
- Inserire un Cilindro
- Inserire un Cilindro
- Fare un taglio booleano per ottenere la forma di base dell'anello interno
- Selezionare tutti i bordi e applicare un raccordo
- Inserire un Toro
- Spostare il toro in posizione e fare un taglio booleano per creare la scanalatura per le sfere
- Ripetere tutti i passaggi per ottenere la forma per l'anello esterno
- Inserire prima sfera
- Inserire le altre sfere usando math per calcolare la loro posizione
- Impostare la vista assonometrica
- Zoom per adattare la vista alla finestra
Raccordare i bordi
Nell'ambiente Part utilizzando la GUI, è necessario selezionare i raccordi nella vista 3D o nel menu per i raccordi e poi applicare i raccordi.
Qui si selezionano tutti i bordi di una forma e poi si applicano i raccordi.
Quindi bisogna selezionare i bordi prima di creare la scanalatura.
Note
Questo tutorial utilizza le primitive di Parte e le Operazioni booleane, che consumano molte risorse.
Per fare un script di Part usando degli schizzi rivoluzionati vedere il tutorial Parti con script: Cuscinetto a sfere - Parte 2 .
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 2: Costruirlo con degli schizzi
Bearing Script 1: Base per questo tutorial, grazie a JMG ...
Codice
## 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")
- FreeCAD scripting: Python, Introduction to Python, Python scripting tutorial, FreeCAD Scripting Basics
- Modules: Builtin modules, Units, Quantity
- Workbenches: Workbench creation, Gui Commands, Commands, Installing more workbenches
- Meshes and Parts: Mesh Scripting, Topological data scripting, Mesh to Part, PythonOCC
- Parametric objects: Scripted objects, Viewproviders (Custom icon in tree view)
- Scenegraph: Coin (Inventor) scenegraph, Pivy
- Graphical interface: Interface creation, Interface creation completely in Python (1, 2, 3, 4, 5), PySide, PySide examples beginner, intermediate, advanced
- Macros: Macros, How to install macros
- Embedding: Embedding FreeCAD, Embedding FreeCADGui
- Other: Expressions, Code snippets, Line drawing function, FreeCAD vector math library (deprecated)
- Hubs: User hub, Power users hub, Developer hub