Macro Solid Sweep

From FreeCAD Documentation
Revision as of 10:18, 26 December 2013 by Mario52 (talk | contribs) (Created page with "=== 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 l...")

File:Text-x-python Solid Sweep

Descripción
Crea un sólido barriendo un perfil a lo largo de una trayectoria.

Autor : Normandc
Autor
Normandc
Descargar
None
Enlace
Versión Macro
1.0
Fecha última modificación
None
Versión(es) FreeCAD
None
Acceso directo predeterminado
None
Ver también
None

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.

Supported 2D elements

  • Wires
  • Sketches
  • Draft BSpline
  • 2D primitives from the Parametric → Create Primitives... menu (circle, helix)

Tips

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

The script

import Part, FreeCAD, math, PartGui, FreeCADGui
from FreeCAD import Base

# pick selected objects, where 1st selection is the trajectory and the 2nd is the section to sweep
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 a Part object into the active document
myObject=App.ActiveDocument.addObject("Part::Feature","Sweep")

makeSolid = 1
isFrenet = 1

# Create the 3D shape and set it to the Part object
Sweep = Part.Wire(traj).makePipeShell([section],makeSolid,isFrenet)
myObject.Shape = Sweep</pre>

Credits

Thanks to Wmayer for his help in writing this script.

Two examples of uses can be found in 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.