Macro Solid Sweep/es: Difference between revisions
m (Created page with "Esta macro crea un sólido barriendo un perfil 2D a lo largo de una trayectoria previamente seleccionada en la vista 3D. Los elementos 2D se pueden crear con las herramientas ...") |
(Updating to match new version of source page) |
||
(32 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
⚫ | |||
⚫ | |||
{{Macro/es |
|||
|Name=Solid Sweep |
|||
|Icon=Macro_Solid_Sweep.png |
|||
|Translate=Solid Sweep |
|||
⚫ | |||
|Author=Normandc |
|||
|Version=1.0 |
|||
|Date=2011-12-03 |
|||
|FCVersion=All |
|||
|Download=[https://www.freecadweb.org/wiki/images/6/6d/Macro_Solid_Sweep.png ToolBar Icon] |
|||
}} |
|||
==Descriptivo== |
|||
Esta macro crea un sólido barriendo un perfil 2D a lo largo de una trayectoria previamente seleccionada en la vista 3D. Los elementos 2D se pueden crear con las herramientas habituales de FreeCAD. |
Esta macro crea un sólido barriendo un perfil 2D a lo largo de una trayectoria previamente seleccionada en la vista 3D. Los elementos 2D se pueden crear con las herramientas habituales de FreeCAD. |
||
El sólido resultante no es paramétrico. Si cambias el perfil o la trayectoria, necesitarás ejecutar la macro de nuevo. |
|||
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. |
|||
[[File:Solid_sweep.png|500px|A few examples of sweeping all using the same oblong section and three kinds of trajectory.]] |
[[File:Solid_sweep.png|500px|A few examples of sweeping all using the same oblong section and three kinds of trajectory.]] |
||
<div class="mw-translate-fuzzy"> |
|||
=== How to use === |
|||
== Como se utiliza == |
|||
* 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. |
|||
* Crea dos elementos 2D, uno para la sección y otro para la trayectoria, de los tipos indicados abajo. |
|||
=== Supported 2D elements === |
|||
* Selecciona, en el árbol del Proyecto o en la vista 3D, primero la trayectoria y después el perfil. El orden es importante! |
|||
* Wires |
|||
* Abre el gestor de macros, selecciona la macro y pulsa en "Ejecutar". |
|||
⚫ | |||
* Se creará un sólido '''barrido''' en el árbol del Proyecto. |
|||
⚫ | |||
</div> |
|||
* 2D primitives from the ''Parametric → Create Primitives...'' menu (circle, helix) |
|||
<div class="mw-translate-fuzzy"> |
|||
⚫ | |||
== Elementos 2D soportados == |
|||
* 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. |
|||
* Contornos |
|||
=== The script === |
|||
⚫ | |||
⚫ | |||
* Primitivas 2D del menú ''Parametricas → [[Image:Part_CreatePrimitives.png|32px]] [[Part_CreatePrimitives/es|Crear Primitivas]] ...'' (circunferencia, hélice) |
|||
</div> |
|||
⚫ | |||
<syntaxhighlight> |
|||
* La sección debe ser un perfil cerrado o el resultado no será un sólido. |
|||
* La sección no necesita ubicarse en la trayectoria, pero es preferible que sea normal a ella. |
|||
* La trayectoria puede ser un perfil abierto o cerrado (circunferencias, o líneas y arcos) pero todos los elementos deben ser tangentes o la forma resultante será inesperada. Por ejemplo, una trayectoria con esquinas rectas como un rectángulo no producirá un sólido. |
|||
* Si el sólido se retuerce, edita la macro para cambiar el valor de ''isFrenet'' a cero y prueba de nuevo. |
|||
* Configurar la variable ''makeSolid'' a cero en la macro producirá una colección de superficies con finales abiertos. |
|||
== 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. |
|||
== Créditos == |
|||
⚫ | |||
⚫ | |||
Dos ejemplo de uso se pueden ver en [http://forum.freecadweb.org/viewtopic.php?f=8&t=1222&start=50#p11120 este hilo del foro], así como enlaces para descargar archivos FCStd. Utilizando una hélice como trayectoria, un sólido barrido se puede utilizar para crear un tornillo. |
Latest revision as of 11:20, 23 May 2020
Descripción |
---|
Crea un sólido barriendo un perfil a lo largo de una trayectoria. Versión macro : 1.0 Fecha última modificación : 2011-12-03 Versión FreeCAD : All Descargar : ToolBar Icon Autor : Normandc |
Autor |
Normandc |
Descargar |
ToolBar Icon |
Enlace |
Macros recipes How to install macros How to customize toolbars |
Versión Macro |
1.0 |
Fecha última modificación |
2011-12-03 |
Versión(es) FreeCAD |
All |
Acceso directo predeterminado |
None |
Ver también |
None |
Descriptivo
Esta macro crea un sólido barriendo un perfil 2D a lo largo de una trayectoria previamente seleccionada en la vista 3D. Los elementos 2D se pueden crear con las herramientas habituales de FreeCAD.
El sólido resultante no es paramétrico. Si cambias el perfil o la trayectoria, necesitarás ejecutar la macro de nuevo.
Como se utiliza
- Crea dos elementos 2D, uno para la sección y otro para la trayectoria, de los tipos indicados abajo.
- Selecciona, en el árbol del Proyecto o en la vista 3D, primero la trayectoria y después el perfil. El orden es importante!
- Abre el gestor de macros, selecciona la macro y pulsa en "Ejecutar".
- Se creará un sólido barrido en el árbol del Proyecto.
Elementos 2D soportados
- Contornos
- Croquis
- BSplines
- Primitivas 2D del menú Parametricas → Crear Primitivas ... (circunferencia, hélice)
Trucos
- La sección debe ser un perfil cerrado o el resultado no será un sólido.
- La sección no necesita ubicarse en la trayectoria, pero es preferible que sea normal a ella.
- La trayectoria puede ser un perfil abierto o cerrado (circunferencias, o líneas y arcos) pero todos los elementos deben ser tangentes o la forma resultante será inesperada. Por ejemplo, una trayectoria con esquinas rectas como un rectángulo no producirá un sólido.
- Si el sólido se retuerce, edita la macro para cambiar el valor de isFrenet a cero y prueba de nuevo.
- Configurar la variable makeSolid a cero en la macro producirá una colección de superficies con finales abiertos.
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
Créditos
Gracias a Wmayer por su ayuda al escribir esta macro.
Dos ejemplo de uso se pueden ver en este hilo del foro, así como enlaces para descargar archivos FCStd. Utilizando una hélice como trayectoria, un sólido barrido se puede utilizar para crear un tornillo.