Macro Solid Sweep/it: Difference between revisions
m (Created page with "{{Macro/it|Icon=Text-x-python|Name=Solid Sweep|Name/it=Solid Sweep|Description=Crea un solido estrudendo un profilo lungo un percorso.|Author=Normandc}}") |
No edit summary |
||
(39 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
⚫ | |||
⚫ | |||
{{Macro/it |
|||
|Name=Solid Sweep |
|||
|Icon=Macro_Solid_Sweep.png |
|||
|Translate=Sweep solido |
|||
⚫ | |||
|Author=Normandc |
|||
|Version=1.0 |
|||
|Date=2011-12-03 |
|||
|FCVersion=Tutte versione |
|||
|Download=[https://www.freecadweb.org/wiki/images/6/6d/Macro_Solid_Sweep.png Icona per la ToolBar] |
|||
}} |
|||
==Descrizione== |
|||
This macro creates a solid by sweeping a 2D profile along a trajectory previously selected in the 3D view. The 2D elements can be created through the regular tools in FreeCAD's GUI. |
|||
Questa macro crea un solido estrudendo un profilo 2D lungo una traiettoria precedentemente selezionata nella vista 3D. |
|||
Gli elementi 2D possono essere creati attraverso i normali strumenti della GUI di FreeCAD. |
|||
It should be noted that the resulting solid will '''not''' be parametric. If you decide to change your profile or trajectory, you'll need to run the macro again. |
|||
Notare che il solido risultante non è parametrico. Se si decide di modificare il profilo o il percorso, si deve nuovamente eseguire la macro. |
|||
[[File:Solid_sweep.png|500px|A few examples of sweeping all using the same oblong section and three kinds of trajectory.]] |
|||
Nella seguente figura tutte le estrusioni sono realizzate utilizzando la stessa sagoma, ma tre percorsi diversi. |
|||
=== How to use === |
|||
* Create two 2D elements, one for the section and one for the trajectory, of the types listed below. |
|||
* Select, either in the Project tree or in the 3D view, first the trajectory, then the profile. The order is important! |
|||
* Open the Macro manager, select the macro and click "Execute". |
|||
* A '''Sweep''' object will be created in the Project tree. |
|||
[[File:Solid_sweep.png|500px|Alcuni esempi di estrusioni, tutte sono realizzate utilizzando la stessa sezione, ma su tre diverse traiettorie.]] |
|||
=== Supported 2D elements === |
|||
* Wires |
|||
⚫ | |||
⚫ | |||
* 2D primitives from the ''Parametric → Create Primitives...'' menu (circle, helix) |
|||
== Utilizzo == |
|||
* The section has to be a closed profile or the result will not be a solid. |
|||
* The section does not need to be located on the trajectory, but it's preferable that it be normal (perpendicular) to the trajectory. |
|||
* The trajectory can either be an open or closed profile (circle, or line and arc segments) but all elements need to be tangent or the resulting shape will be unexpected. For example, a trajectory with straight corners like a rectangle will not produce a solid. |
|||
* If the solid gets twisted, edit the macro to change the ''isFrenet'' value to 0 (zero) and try again. |
|||
* Setting the ''makeSolid'' variable to 0 (zero) in the macro will produce a set of surfaces with open ends. |
|||
# Creare due elementi 2D del tipo indicato sotto, uno per la sezione e uno per la traiettoria. |
|||
=== The script === |
|||
# Selezionare, nella [[Tree view/it|Vista ad albero]] del progetto o nella [[3D view/it|Vista 3D]], prima la traiettoria e poi il profilo. ('''L'ordine è importante!'''): |
|||
## La traiettoria |
|||
## Poi il profilo |
|||
* Aprire il [[Macros/it|Gestore Macro]] |
|||
# Selezionare la '''Solid Sweep''' macro |
|||
# Cliccare {{Button|Esegui}} |
|||
'''Risultato:''' Un oggetto '''Sweep''' viene creato nella struttura del progetto |
|||
== Elementi 2D supportati == |
|||
<syntaxhighlight> |
|||
* Contorni polilinee |
|||
⚫ | |||
⚫ | |||
* Primitive 2D del menu ''Part → [[Image:Part_Primitives.svg|24px]] [[Part_Primitives/it|Crea Primitive]]...'' (circonferenza, elica) |
|||
== Avvertenze == |
|||
* La '''sezione''' deve essere un profilo chiuso altrimenti il risultato non sarà un solido. |
|||
* Non è necessario che la sezione sia posizionata sulla traiettoria, ma è preferibile che sia normale (perpendicolare) alla traiettoria. |
|||
* La '''traiettoria''' può essere sia un profilo aperto che chiuso (cerchi, o segmenti e archi), ma tutti gli elementi devono essere tangenti o la forma risultante è inaspettata. Ad esempio, una traiettoria con angoli retti (come un rettangolo) non produce un solido. |
|||
* Se il solido diventa contorto, modificare la macro e impostare il valore ''isFrenet'' a 0 (zero) e riprovare. |
|||
* Impostando nella macro la variabile ''makeSolid'' a 0 (zero) si produce un insieme di superfici con le estremità aperte. |
|||
== La macro == |
|||
ToolBar Icon [[Image:Macro_Solid_Sweep.png]] |
|||
'''Macro_Solid_Sweep.FCMacro''' |
|||
{{MacroCode|code= |
|||
import Part, FreeCAD, math, PartGui, FreeCADGui |
import Part, FreeCAD, math, PartGui, FreeCADGui |
||
from FreeCAD import Base |
from FreeCAD import Base |
||
# |
# get the selected objects, with first selection for the trajectory and second for the section |
||
s = FreeCADGui.Selection.getSelection() |
s = FreeCADGui.Selection.getSelection() |
||
try: |
try: |
||
shape1=s[0].Shape |
shape1=s[0].Shape |
||
shape2=s[1].Shape |
shape2=s[1].Shape |
||
except: |
except: |
||
print "Wrong selection" |
print "Wrong selection" |
||
traj = Part.Wire([shape1]) |
traj = Part.Wire([shape1]) |
||
section = Part.Wire([shape2]) |
section = Part.Wire([shape2]) |
||
# create |
# create Part objec in the current document |
||
myObject=App.ActiveDocument.addObject("Part::Feature","Sweep") |
myObject=App.ActiveDocument.addObject("Part::Feature","Sweep") |
||
makeSolid = 1 |
# variable makeSolid = 1 to create solid, 0 to create surfaces |
||
makeSolid = True #1 |
|||
isFrenet = True #1 |
|||
# |
# create a 3D shape and assigh it to the current document |
||
Sweep = Part.Wire(traj).makePipeShell([section],makeSolid,isFrenet) |
Sweep = Part.Wire(traj).makePipeShell([section],makeSolid,isFrenet) |
||
myObject.Shape = Sweep |
myObject.Shape = Sweep |
||
</syntaxhighlight> |
|||
}} |
|||
=== Credits === |
|||
⚫ | |||
Two examples of uses can be found in [http://forum.freecadweb.org/viewtopic.php?f=8&t=1222&start=50#p11120 this forum topic], along with download links to the FCStd files. Using a helix as trajectory, a solid sweep can be used to create a bolt thread. |
|||
== Crediti == |
|||
⚫ | |||
⚫ | |||
In [https://forum.freecadweb.org/viewtopic.php?f=8&t=1222&start=50#p11120 questa sezione del forum] si trovano due esempi di utlizzo e si trovano anche i collegamenti per scaricare i file FCStd. |
|||
Lo stesso argomento viene trattato anche in [http://forum.freecadweb.org/viewtopic.php?f=3&t=1461 questa discussione] con ragguagli su [http://en.wikipedia.org/wiki/Frenet%E2%80%93Serret_formulas Frenet]. |
|||
Utilizzando una elica come traiettoria, tramite uno sweep solido si può creare la filettatura di un bullone. |
Latest revision as of 18:18, 23 December 2022
Descrizione |
---|
Crea un solido estrudendo un profilo lungo un percorso. Versione macro: 1.0 Ultima modifica: 2011-12-03 Versione FreeCAD: Tutte versione Download: Icona per la ToolBar Autore: Normandc |
Autore |
Normandc |
Download |
Icona per la ToolBar |
Link |
Raccolta di macro Come installare le macro Personalizzare la toolbar |
Versione macro |
1.0 |
Data ultima modifica |
2011-12-03 |
Versioni di FreeCAD |
Tutte versione |
Scorciatoia |
Nessuna |
Vedere anche |
Nessuno |
Descrizione
Questa macro crea un solido estrudendo un profilo 2D lungo una traiettoria precedentemente selezionata nella vista 3D.
Gli elementi 2D possono essere creati attraverso i normali strumenti della GUI di FreeCAD.
Notare che il solido risultante non è parametrico. Se si decide di modificare il profilo o il percorso, si deve nuovamente eseguire la macro.
Nella seguente figura tutte le estrusioni sono realizzate utilizzando la stessa sagoma, ma tre percorsi diversi.
Utilizzo
- Creare due elementi 2D del tipo indicato sotto, uno per la sezione e uno per la traiettoria.
- Selezionare, nella Vista ad albero del progetto o nella Vista 3D, prima la traiettoria e poi il profilo. (L'ordine è importante!):
- La traiettoria
- Poi il profilo
- Aprire il Gestore Macro
- Selezionare la Solid Sweep macro
- Cliccare Esegui
Risultato: Un oggetto Sweep viene creato nella struttura del progetto
Elementi 2D supportati
- Contorni polilinee
- Schizzi
- BSpline
- Primitive 2D del menu Part → Crea Primitive... (circonferenza, elica)
Avvertenze
- La sezione deve essere un profilo chiuso altrimenti il risultato non sarà un solido.
- Non è necessario che la sezione sia posizionata sulla traiettoria, ma è preferibile che sia normale (perpendicolare) alla traiettoria.
- La traiettoria può essere sia un profilo aperto che chiuso (cerchi, o segmenti e archi), ma tutti gli elementi devono essere tangenti o la forma risultante è inaspettata. Ad esempio, una traiettoria con angoli retti (come un rettangolo) non produce un solido.
- Se il solido diventa contorto, modificare la macro e impostare il valore isFrenet a 0 (zero) e riprovare.
- Impostando nella macro la variabile makeSolid a 0 (zero) si produce un insieme di superfici con le estremità aperte.
La macro
Macro_Solid_Sweep.FCMacro
import Part, FreeCAD, math, PartGui, FreeCADGui from FreeCAD import Base # get the selected objects, with first selection for the trajectory and second for the section s = FreeCADGui.Selection.getSelection() try: shape1=s[0].Shape shape2=s[1].Shape except: print "Wrong selection" traj = Part.Wire([shape1]) section = Part.Wire([shape2]) # create Part objec in the current document myObject=App.ActiveDocument.addObject("Part::Feature","Sweep") # variable makeSolid = 1 to create solid, 0 to create surfaces makeSolid = True #1 isFrenet = True #1 # create a 3D shape and assigh it to the current document Sweep = Part.Wire(traj).makePipeShell([section],makeSolid,isFrenet) myObject.Shape = Sweep
Crediti
Grazie a Wmayer per il suo aiuto nella stesura di questo script.
In questa sezione del forum si trovano due esempi di utlizzo e si trovano anche i collegamenti per scaricare i file FCStd.
Lo stesso argomento viene trattato anche in questa discussione con ragguagli su Frenet.
Utilizzando una elica come traiettoria, tramite uno sweep solido si può creare la filettatura di un bullone.