Macro SuperWire: Difference between revisions

From FreeCAD Documentation
(Use {{MacroCode}})
(MacroCode)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<languages/>
<languages/>
<translate>
<translate>

<!--T:1-->
<!--T:1-->
{{Macro
{{Macro
Line 13: Line 14:
}}
}}


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


Line 20: Line 23:


==Script== <!--T:3-->
==Script== <!--T:3-->
</translate>


<!--T:6-->
ToolBar Icon [[Image:Macro_SuperWire.png]]
ToolBar Icon
</translate>
[[Image:Macro_SuperWire.png]]


'''Macro_SuperWire.FCMacro'''
'''Macro_SuperWire.FCMacro'''


{{MacroCode|code=
{{MacroCode|code=

import FreeCAD,FreeCADGui,Part
import FreeCAD,FreeCADGui,Part
try:
try:
Line 47: Line 51:
else:
else:
FreeCAD.Console.PrintError("SuperWire operation failed!")
FreeCAD.Console.PrintError("SuperWire operation failed!")

}}
}}
{{clear}}

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