Macro FlattenWire

From FreeCAD Documentation
Jump to: navigation, search
Other languages:
čeština • ‎Deutsch • ‎English • ‎español • ‎français • ‎italiano • ‎svenska

Macro FlattenWire.png FlattenWire

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

Macro version : 1.0
Date last modification : 2011-08-01
FreeCAD version : All
Download : ToolBar Icon
Author
Yorik
Download
ToolBar Icon
Links
Macro Version
1.0
Date last modification
2011-08-01
FreeCAD Version(s)
All
Default shortcut
None
See also
None


Description

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

Script

ToolBar Icon Macro FlattenWire.png

Macro_FlattenWire.FCMacro

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