Macro FlattenWire: Difference between revisions
No edit summary |
(MacroCode) |
||
(One intermediate revision by the same user not shown) | |||
Line 28: | Line 28: | ||
'''Macro_FlattenWire.FCMacro''' |
'''Macro_FlattenWire.FCMacro''' |
||
{{ |
{{MacroCode|code= |
||
import FreeCAD |
import FreeCAD |
||
obj = FreeCAD.ActiveDocument.ActiveObject |
obj = FreeCAD.ActiveDocument.ActiveObject |
||
Line 35: | Line 35: | ||
z = z/len(obj.Points) |
z = z/len(obj.Points) |
||
newpoints = [] |
newpoints = [] |
||
for p in obj.Points: newpoints.append(FreeCAD.Vector(p.x,p.y,z)) |
for p in obj.Points: newpoints.append(FreeCAD.Vector(p.x, p.y, z)) |
||
obj.Points = newpoints |
obj.Points = newpoints |
||
}} |
}} |
Latest revision as of 10:22, 21 December 2021
Description |
---|
This macro flattens draft wires that are not planar to their median Z coordinate Macro version: 1.1 Last modified: 2021-10-27 FreeCAD version: All Download: ToolBar Icon Author: Yorik |
Author |
Yorik |
Download |
ToolBar Icon |
Links |
Macros recipes How to install macros How to customize toolbars |
Macro Version |
1.1 |
Date last modified |
2021-10-27 |
FreeCAD Version(s) |
All |
Default shortcut |
None |
See also |
None |
Description
This macro flattens draft wires that are not planar to their median Z coordinate.
Script
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: newpoints.append(FreeCAD.Vector(p.x, p.y, z)) obj.Points = newpoints