Macro Solid Sweep/cs: Difference between revisions

From FreeCAD Documentation
(Created page with "=== Použití === * Vytvořte dva 2D prvky, jeden pro profil, druhý pro trajektorii, některého z typů v seznamu níže. * Nejdříve vyberte buď ve stromu projektu nebo v...")
Line 7: Line 7:
[[File:Solid_sweep.png‎|500px|Několik příkladů vlečení, všechny s použitím stejné obloukové sekce, ale s jinou trajektorií.]]
[[File:Solid_sweep.png‎|500px|Několik příkladů vlečení, všechny s použitím stejné obloukové sekce, ale s jinou trajektorií.]]


=== How to use ===
=== Použití ===
* Vytvořte dva 2D prvky, jeden pro profil, druhý pro trajektorii, některého z typů v seznamu níže.
* Create two 2D elements, one for the section and one for the trajectory, of the types listed below.
* Nejdříve vyberte buď ve stromu projektu nebo ve 3D pohledu trajektorii a potom profil. Pořadí je důležité!
* Select, either in the Project tree or in the 3D view, first the trajectory, then the profile. The order is important!
* Otveřete Správce maker, vyberte makro a klikněte na "Spusť".
* Open the Macro manager, select the macro and click "Execute".
* Ve stromu projektu bude vytvořen objekt '''Sweep'''.
* A '''Sweep''' object will be created in the Project tree.


=== Supported 2D elements ===
=== Supported 2D elements ===

Revision as of 18:22, 6 February 2014

File:Text-x-python Solid Sweep

Description
Vytváří těleso vlečením profilu po trajektorii.

Author: Normandc
Author
Normandc
Download
None
Links
Macro Version
1.0
Date last modified
None
FreeCAD Version(s)
None
Default shortcut
None
See also
None

Toto makro vytváří těleso vlečením 2D profilu po trajektorii předem vybrané m ve 3D pohledu. 2D prvke může být vytvořen pomocí standardních nástrojů FreeCADu.

Musí být podotknuto, že výsledné těleso nebude parametrické. Jestliže se rozhodnete změnit profil nebo trajektorii, musíte spustit makro znovu.

Několik příkladů vlečení, všechny s použitím stejné obloukové sekce, ale s jinou trajektorií.

Použití

  • Vytvořte dva 2D prvky, jeden pro profil, druhý pro trajektorii, některého z typů v seznamu níže.
  • Nejdříve vyberte buď ve stromu projektu nebo ve 3D pohledu trajektorii a potom profil. Pořadí je důležité!
  • Otveřete Správce maker, vyberte makro a klikněte na "Spusť".
  • Ve stromu projektu bude vytvořen objekt Sweep.

Supported 2D elements

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.

Other languages: