Macro Solid Sweep/es: Difference between revisions

From FreeCAD Documentation
m (Created page with "=== La macro ===")
(Updating to match new version of source page)
 
(27 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<languages/>
{{Macro/es|Icon=Text-x-python|Name=Solid Sweep|Name/es=Solid Sweep|Description=Crea un sólido barriendo un perfil a lo largo de una trayectoria.|Author=Normandc}}
{{Macro/es
|Name=Solid Sweep
|Icon=Macro_Solid_Sweep.png
|Translate=Solid Sweep
|Description=Crea un sólido barriendo un perfil a lo largo de una trayectoria.
|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.


Line 7: Line 19:
[[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">
=== Como se utiliza ===
== Como se utiliza ==


* Crea dos elementos 2D, uno para la sección y otro para la trayectoria, de los tipos indicados abajo.
* Crea dos elementos 2D, uno para la sección y otro para la trayectoria, de los tipos indicados abajo.
Line 13: Line 26:
* Abre el gestor de macros, selecciona la macro y pulsa en "Ejecutar".
* Abre el gestor de macros, selecciona la macro y pulsa en "Ejecutar".
* Se creará un sólido '''barrido''' en el árbol del Proyecto.
* Se creará un sólido '''barrido''' en el árbol del Proyecto.
</div>


<div class="mw-translate-fuzzy">
=== Elementos 2D soportados ===
== Elementos 2D soportados ==


* Contornos
* Contornos
* [[Image:Sketcher_NewSketch.png|32px]] [[Sketcher Workbench/es|Croquis]]
* [[Image:Sketcher_NewSketch.png|32px]] [[Sketcher Workbench/es|Croquis]]
* [[Image:Draft_BSpline.png]] [[Draft BSpline/es|BSplines]]
* [[Image:Draft_BSpline.png]] [[Draft BSpline/es|BSplines]]
* Primitivas 2D del menú ''Parametricas → Crear Primitivas...'' (circunferencia, hélice)
* Primitivas 2D del menú ''Parametricas → [[Image:Part_CreatePrimitives.png|32px]] [[Part_CreatePrimitives/es|Crear Primitivas]] ...'' (circunferencia, hélice)
</div>


=== Trucos ===
== Trucos ==


* La sección debe ser un perfil cerrado o el resultado no será un sólido.
* La sección debe ser un perfil cerrado o el resultado no será un sólido.
Line 29: Line 45:
* Configurar la variable ''makeSolid'' a cero en la macro producirá una colección de superficies con finales abiertos.
* Configurar la variable ''makeSolid'' a cero en la macro producirá una colección de superficies con finales abiertos.


=== La macro ===
== La macro ==


ToolBar Icon [[Image:Macro_Solid_Sweep.png]]
<syntaxhighlight>

'''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


# pick selected objects, where 1st selection is the trajectory and the 2nd is the section to sweep
# 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 a Part object into the active document
# 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
isFrenet = 1
makeSolid = True #1
isFrenet = True #1


# Create the 3D shape and set it to the Part object
# 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</pre>
myObject.Shape = Sweep
</syntaxhighlight>


}}
=== Credits ===
Thanks to [[User:Wmayer|Wmayer]] for his help in writing this script.


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 ==
<languages/>

Gracias a [[User:Wmayer|Wmayer]] por su ayuda al escribir esta macro.

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

Solid Sweep

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
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.

A few examples of sweeping all using the same oblong section and three kinds of trajectory.

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

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

ToolBar Icon

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.