Macro Solid Sweep: Difference between revisions
m (Robot: Automated text replacement (-https://sourceforge.net/apps/phpbb/free-cad +http://forum.freecadweb.org)) |
(Part_CreatePrimitives.svg -> Part_Primitives.svg) |
||
(20 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
<languages/> |
|||
⚫ | |||
<translate> |
|||
<!--T:1--> |
|||
{{Macro |
|||
|Name=Solid Sweep |
|||
|Icon=Macro_Solid_Sweep.png |
|||
⚫ | |||
|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] |
|||
}} |
|||
==Description== <!--T:2--> |
|||
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. |
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. |
||
<!--T:3--> |
|||
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. |
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. |
||
<!--T:4--> |
|||
[[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.]] |
||
== Usage == <!--T:5--> |
|||
⚫ | |||
⚫ | |||
⚫ | |||
## The trajectory |
|||
⚫ | |||
## Then the profile |
|||
* Open the Macro manager, select the macro and click "Execute". |
|||
# Open the [[Macros|Macro manager]] |
|||
⚫ | |||
# Select the '''Solid Sweep''' macro |
|||
# Click {{Button|Execute}} |
|||
⚫ | |||
⚫ | |||
⚫ | |||
* Wires |
* Wires |
||
* [[Image:Sketcher_NewSketch. |
* [[Image:Sketcher_NewSketch.svg|24px]] [[Sketcher Workbench|Sketches]] |
||
* [[Image:Draft_BSpline. |
* [[Image:Draft_BSpline.svg|24px]] [[Draft BSpline]] |
||
* 2D primitives from the '' |
* 2D primitives from the ''Part → [[Image:Part_Primitives.svg|24px]] [[Part_Primitives|Create Primitives]] ...'' menu (circle, helix) |
||
⚫ | |||
⚫ | |||
* The section has to be a closed profile or the result will not be a solid. |
* 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 section does not need to be located on the trajectory, but it's preferable that it be normal (perpendicular) to the trajectory. |
||
Line 29: | Line 45: | ||
* Setting the ''makeSolid'' variable to 0 (zero) in the macro will produce a set of surfaces with open ends. |
* Setting the ''makeSolid'' variable to 0 (zero) in the macro will produce a set of surfaces with open ends. |
||
== Script == <!--T:8--> |
|||
</translate> |
|||
ToolBar Icon [[Image:Macro_Solid_Sweep.png]] |
|||
⚫ | |||
'''Macro_Solid_Sweep.FCMacro''' |
|||
{{MacroCode|code= |
|||
⚫ | |||
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 |
||
}} |
|||
<translate> |
|||
⚫ | |||
⚫ | |||
Thanks to [[User:Wmayer|Wmayer]] for his help in writing this script. |
Thanks to [[User:Wmayer|Wmayer]] for his help in writing this script. |
||
<!--T:10--> |
|||
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. |
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. |
||
</translate> |
|||
{{languages | {{es|Macro_Solid_Sweep/es}} {{fr|Macro_Solid_Sweep/fr}} {{it|Macro_Solid_Sweep/it}} }} |
Latest revision as of 16:49, 19 November 2020
Description |
---|
Creates a solid by sweeping a profile from a trajectory. Macro version: 1.0 Last modified: 2011-12-03 FreeCAD version: All Download: ToolBar Icon Author: Normandc |
Author |
Normandc |
Download |
ToolBar Icon |
Links |
Macros recipes How to install macros How to customize toolbars |
Macro Version |
1.0 |
Date last modified |
2011-12-03 |
FreeCAD Version(s) |
All |
Default shortcut |
None |
See also |
None |
Description
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.
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.
Usage
- Create two 2D elements, one for the section and one for the trajectory, of the types listed below.
- Select, either in the Tree view or in the 3D view (The order is important!):
- The trajectory
- Then the profile
- Open the Macro manager
- Select the Solid Sweep macro
- Click Execute
Result: A Sweep object will be created in the Project tree.
Supported 2D elements
- Wires
- Sketches
- Draft BSpline
- 2D primitives from the Part → 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.
Script
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
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.