Macro SuperWire: Difference between revisions

From FreeCAD Documentation
m (Languages spanish)
(MacroCode)
 
(27 intermediate revisions by 6 users not shown)
Line 1: Line 1:
<languages/>
{{Macro|Name=SuperWire|Description=This macro creates a wire from selected objects (lines and arcs) even where normal wire creation methods (for example the upgrade tool) fail|Author=Yorik}}
<translate>


<!--T:1-->
{{Macro
|Name=SuperWire
|Icon=Macro_SuperWire.png
|Description=This macro creates a wire from selected objects (lines and arcs) even where normal wire creation methods (for example the upgrade tool) fail. Attention, you need a recent version of FreeCAD for this to work
|Author=Yorik
|Version=0.1
|Date=2012-05-22
|FCVersion=All
|Download=[https://www.freecadweb.org/wiki/images/e/e3/Macro_SuperWire.png ToolBar Icon]
}}

==Description== <!--T:5-->

<!--T:2-->
This macro creates a wire from selected objects (lines and arcs) even where normal wire creation methods (for example the upgrade tool) fail.

<!--T:4-->
Attention, you need a recent version of FreeCAD for this to work
Attention, you need a recent version of FreeCAD for this to work


==Script== <!--T:3-->
import FreeCAD,FreeCADGui,Part

from draftlibs import fcgeo
<!--T:6-->
ToolBar Icon
sel = FreeCADGui.Selection.getSelection()
</translate>
if not sel:
[[Image:Macro_SuperWire.png]]
FreeCAD.Console.PrintWarning("Select something first!")

else:
'''Macro_SuperWire.FCMacro'''
elist = []

for obj in sel:
{{MacroCode|code=
if hasattr(obj,"Shape"):
import FreeCAD,FreeCADGui,Part
elist.append(obj.Shape.Edges[0])
try:
wire = fcgeo.superWire(elist)
import DraftGeomUtils as fcgeo
if wire:
except:
Part.show(wire)
from draftlibs import fcgeo
else:
FreeCAD.Console.PrintError("SuperWire operation failed!")


sel = FreeCADGui.Selection.getSelection()
{{languages | {{es|Macro_SuperWire/es}} }}
if not sel:
FreeCAD.Console.PrintWarning("Select something first!")
else:
elist = []
for obj in sel:
if hasattr(obj,"Shape"):
elist.append(obj.Shape.Edges[0])
wire = fcgeo.superWire(elist)
if wire:
Part.show(wire)
else:
FreeCAD.Console.PrintError("SuperWire operation failed!")
}}

Latest revision as of 10:41, 21 December 2021

SuperWire

Description
This macro creates a wire from selected objects (lines and arcs) even where normal wire creation methods (for example the upgrade tool) fail. Attention, you need a recent version of FreeCAD for this to work

Macro version: 0.1
Last modified: 2012-05-22
FreeCAD version: All
Download: ToolBar Icon
Author: Yorik
Author
Yorik
Download
ToolBar Icon
Links
Macro Version
0.1
Date last modified
2012-05-22
FreeCAD Version(s)
All
Default shortcut
None
See also
None

Description

This macro creates a wire from selected objects (lines and arcs) even where normal wire creation methods (for example the upgrade tool) fail.

Attention, you need a recent version of FreeCAD for this to work

Script

ToolBar Icon

Macro_SuperWire.FCMacro

import FreeCAD,FreeCADGui,Part
try:
    import DraftGeomUtils as fcgeo
except:
    from draftlibs import fcgeo

sel = FreeCADGui.Selection.getSelection()
if not sel:
   FreeCAD.Console.PrintWarning("Select something first!")
else:
   elist = []
   for obj in sel:
       if hasattr(obj,"Shape"):
           elist.append(obj.Shape.Edges[0])
   wire = fcgeo.superWire(elist)
   if wire:
       Part.show(wire)
   else:
       FreeCAD.Console.PrintError("SuperWire operation failed!")