119 lines
7.7 KiB
HTML
119 lines
7.7 KiB
HTML
<html><head><title>Macro Solid Sweep</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><link type='text/css' href='wiki.css' rel='stylesheet'></head><body><h1>Macro Solid Sweep</h1></div>
|
|
|
|
<div id="mw-content-text" lang="en" dir="ltr" class="mw-content-ltr"><div class="mw-parser-output"><table class="fcinfobox wikitable ct" width="100%" style="float: right; width: 230px; margin-left: 10px;">
|
|
<tr>
|
|
<td class="ctTitle">
|
|
<h3><span class="mw-headline" id="Solid_Sweep"><a href="https://www.freecadweb.org/wiki/index.php?title=File:Text-x-python.png" class="image"><img alt="Text-x-python.png" src="32px-Text-x-python.png" width="32" height="32" srcset="/wiki/images/2/2c/Text-x-python.png 1.5x" /></a> Solid Sweep</span></h3>
|
|
</td></tr>
|
|
<tr>
|
|
<th class="ctOdd">Description
|
|
</th></tr>
|
|
<tr>
|
|
<td class="ctEven left macro-description">Creates a solid by sweeping a profile from a trajectory.
|
|
</td></tr>
|
|
<tr>
|
|
<th class="ctOdd">Author
|
|
</th></tr>
|
|
<tr>
|
|
<td class="ctEven macro-author"><a href="https://www.freecadweb.org/wiki/index.php?title=User:Normandc" title="User:Normandc">Normandc</a>
|
|
</td></tr>
|
|
<tr>
|
|
<th class="ctOdd">Links
|
|
</th></tr>
|
|
<tr>
|
|
<td class="ctEven"><a href="Macros_recipes.html" title="Macros recipes">Macros recipes</a><br /><a href="How_to_install_macros.html" title="How to install macros">How to install macros</a><br /><a href="Customize_Toolbars.html" title="Customize Toolbars">How to customize toolbars</a>
|
|
</td></tr>
|
|
<tr>
|
|
<th class="ctOdd">Version
|
|
</th></tr>
|
|
<tr>
|
|
<td class="ctEven macro-version">1.0
|
|
</td></tr>
|
|
<tr>
|
|
<th class="ctOdd">Date last modification
|
|
</th></tr>
|
|
<tr>
|
|
<td class="ctEven macro-date">2011-12-03
|
|
</td></tr>
|
|
<tr>
|
|
<th class="ctOdd">
|
|
</th></tr>
|
|
<tr>
|
|
<td class="ctToc"><br /><div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
|
|
<ul>
|
|
<li class="toclevel-1"><a href="#Solid_Sweep"><span class="tocnumber">1</span> <span class="toctext">Solid Sweep</span></a></li>
|
|
<li class="toclevel-1 tocsection-1"><a href="#How_to_use"><span class="tocnumber">2</span> <span class="toctext">How to use</span></a></li>
|
|
<li class="toclevel-1 tocsection-2"><a href="#Supported_2D_elements"><span class="tocnumber">3</span> <span class="toctext">Supported 2D elements</span></a></li>
|
|
<li class="toclevel-1 tocsection-3"><a href="#Tips"><span class="tocnumber">4</span> <span class="toctext">Tips</span></a></li>
|
|
<li class="toclevel-1 tocsection-4"><a href="#The_script"><span class="tocnumber">5</span> <span class="toctext">The script</span></a></li>
|
|
<li class="toclevel-1 tocsection-5"><a href="#Credits"><span class="tocnumber">6</span> <span class="toctext">Credits</span></a></li>
|
|
</ul>
|
|
</div>
|
|
|
|
</td></tr>
|
|
</table>
|
|
<p><br />
|
|
</p><p>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.
|
|
</p><p>It should be noted that the resulting solid will <b>not</b> be parametric. If you decide to change your profile or trajectory, you'll need to run the macro again.
|
|
</p><p><a href="https://www.freecadweb.org/wiki/index.php?title=File:Solid_sweep.png" class="image" title="A few examples of sweeping all using the same oblong section and three kinds of trajectory."><img alt="A few examples of sweeping all using the same oblong section and three kinds of trajectory." src="500px-Solid_sweep.png" width="500" height="331" srcset="/wiki/images/thumb/f/fd/Solid_sweep.png/750px-Solid_sweep.png 1.5x, /wiki/images/f/fd/Solid_sweep.png 2x" /></a>
|
|
</p>
|
|
<h3><span class="mw-headline" id="How_to_use">How to use</span></h3>
|
|
<ul><li> Create two 2D elements, one for the section and one for the trajectory, of the types listed below.</li>
|
|
<li> Select, either in the Project tree or in the 3D view, first the trajectory, then the profile. The order is important!</li>
|
|
<li> Open the Macro manager, select the macro and click "Execute".</li>
|
|
<li> A <b>Sweep</b> object will be created in the Project tree.</li></ul>
|
|
<h3><span class="mw-headline" id="Supported_2D_elements">Supported 2D elements</span></h3>
|
|
<ul><li> Wires</li>
|
|
<li> <a href="https://www.freecadweb.org/wiki/index.php?title=File:Sketcher_NewSketch.png" class="image"><img alt="Sketcher NewSketch.png" src="32px-Sketcher_NewSketch.png" width="32" height="32" srcset="/wiki/images/thumb/4/46/Sketcher_NewSketch.png/48px-Sketcher_NewSketch.png 1.5x, /wiki/images/4/46/Sketcher_NewSketch.png 2x" /></a> <a href="Sketcher_Workbench.html" title="Sketcher Workbench">Sketches</a></li>
|
|
<li> <a href="https://www.freecadweb.org/wiki/index.php?title=File:Draft_BSpline.png" class="image"><img alt="Draft BSpline.png" src="Draft_BSpline.png" width="64" height="64" /></a> <a href="Draft_BSpline.html" title="Draft BSpline">Draft BSpline</a></li>
|
|
<li> 2D primitives from the <i>Part → <a href="https://www.freecadweb.org/wiki/index.php?title=File:Part_CreatePrimitives.png" class="image"><img alt="Part CreatePrimitives.png" src="32px-Part_CreatePrimitives.png" width="32" height="32" srcset="/wiki/images/thumb/8/8a/Part_CreatePrimitives.png/48px-Part_CreatePrimitives.png 1.5x, /wiki/images/8/8a/Part_CreatePrimitives.png 2x" /></a> <a href="Part_CreatePrimitives.html" title="Part CreatePrimitives">Create Primitives</a> ...</i> menu (circle, helix)</li></ul>
|
|
<h3><span class="mw-headline" id="Tips">Tips</span></h3>
|
|
<ul><li> The section has to be a closed profile or the result will not be a solid.</li>
|
|
<li> The section does not need to be located on the trajectory, but it's preferable that it be normal (perpendicular) to the trajectory.</li>
|
|
<li> 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.</li>
|
|
<li> If the solid gets twisted, edit the macro to change the <i>isFrenet</i> value to 0 (zero) and try again.</li>
|
|
<li> Setting the <i>makeSolid</i> variable to 0 (zero) in the macro will produce a set of surfaces with open ends.</li></ul>
|
|
<h3><span class="mw-headline" id="The_script">The script</span></h3>
|
|
<pre>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 </pre>
|
|
<h3><span class="mw-headline" id="Credits">Credits</span></h3>
|
|
<p>Thanks to <a href="https://www.freecadweb.org/wiki/index.php?title=User:Wmayer" title="User:Wmayer">Wmayer</a> for his help in writing this script.
|
|
</p><p>Two examples of uses can be found in <a rel="nofollow" class="external text" href="http://forum.freecadweb.org/viewtopic.php?f=8&t=1222&start=50#p11120">this forum topic</a>, along with download links to the FCStd files. Using a helix as trajectory, a solid sweep can be used to create a bolt thread.
|
|
</p>
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div><div class="printfooter">
|
|
Online version: "<a dir="ltr" href="https://www.freecadweb.org/wiki/index.php?title=Macro_Solid_Sweep&oldid=240619">http://www.freecadweb.org/wiki/index.php?title=Macro_Solid_Sweep&oldid=240619</a>"</div>
|
|
<div id="catlinks" class="catlinks" data-mw="interface"></div><div class="visualClear"></div>
|
|
</div>
|
|
</div>
|
|
<div id="mw-navigation">
|
|
<h2>Navigation menu</h2>
|
|
|
|
</body></html> |