Macro HealArcs: Difference between revisions

From FreeCAD Documentation
(Marked this version for translation)
(py2 print to py3)
 
Line 43: Line 43:
removeList.append(obj.Name)
removeList.append(obj.Name)
FreeCAD.ActiveDocument.recompute()
FreeCAD.ActiveDocument.recompute()
print "removing ",removeList
print("removing", removeList)
for n in removeList:
for n in removeList:
FreeCAD.ActiveDocument.removeObject(n)
FreeCAD.ActiveDocument.removeObject(n)

Latest revision as of 22:34, 5 June 2022

HealArcs

Description
Sometimes arcs are transformed into BSplines, for example when scale operations have been applied to them. This macro recreates valid arcs from them. Useful before exporting to dxf. Useful before exporting to dxf.

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

Description

Sometimes arcs are transformed into BSplines, for example when scale operations have been applied to them. This macro recreates valid arcs from them. Useful before exporting to dxf

Script

ToolBar Icon Macro_HealArcs.FCMacro

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

sel = FreeCADGui.Selection.getSelection()
if not sel:
    FreeCAD.Console.PrintWarning("Select something first!")
else:
    removeList = []
    for obj in sel:
        ed = obj.Shape.Edges[0]
        arc = fcgeo.arcFromSpline(ed)
        if arc:
            Part.show(arc)
            removeList.append(obj.Name)
    FreeCAD.ActiveDocument.recompute()
    print("removing", removeList)
    for n in removeList:
        FreeCAD.ActiveDocument.removeObject(n)