Macro SuperWire: Difference between revisions

From FreeCAD Documentation
(ajout de "|Icon=Text-x-python")
(<translate>)
Line 1: Line 1:
<translate>
{{Macro|Icon=Text-x-python|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}}
{{Macro|Icon=Text-x-python|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}}


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


</translate>

<syntaxhighlight>
import FreeCAD,FreeCADGui,Part
import FreeCAD,FreeCADGui,Part
try:
try:
Line 23: Line 28:
FreeCAD.Console.PrintError("SuperWire operation failed!")
FreeCAD.Console.PrintError("SuperWire operation failed!")


</syntaxhighlight>
{{languages | {{es|Macro_SuperWire/es}} {{fr|Macro_SuperWire/fr}} {{it|Macro_SuperWire/it}} }}
{{clear}}
<languages/>

Revision as of 18:16, 24 December 2013

File:Text-x-python 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
Author
Yorik
Download
None
Links
Macro Version
1.0
Date last modified
None
FreeCAD Version(s)
None
Default shortcut
None
See also
None

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


 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!")