Macro FlattenWire

From FreeCAD Documentation
Revision as of 18:05, 24 December 2013 by FuzzyBot (talk | contribs) (Updating to match new version of source page)

File:Text-x-python FlattenWire

Description
This macro flattens draft wires that are not plane to their median Z coordinate

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 flattens draft wires that are not plane to their median Z coordinate

 import FreeCAD
 obj = FreeCAD.ActiveDocument.ActiveObject
 z = 0
 for p in obj.Points: z += p.z
 z = z/len(obj.Points)
 newpoints = []
 for p in obj.Points: newppoints.append(FreeCAD.Vector(p.x,p.y,z))
 obj.Points = newppoints