Macro FlattenWire/cs: Difference between revisions

From FreeCAD Documentation
(Updating to match new version of source page)
mNo edit summary
Line 2: Line 2:
{{Macro/cs|Icon=Text-x-python|Name=FlattenWire|Name/cs=FlattenWire|Description=This macro flattens draft wires that are not plane to their median Z coordinate|Author=Yorik|Version=1.0|Date=2011-08-01}}
{{Macro/cs|Icon=Text-x-python|Name=FlattenWire|Name/cs=FlattenWire|Description=This macro flattens draft wires that are not plane to their median Z coordinate|Author=Yorik|Version=1.0|Date=2011-08-01}}


==Deskriptivní==
<div class="mw-translate-fuzzy">
Toto makro vyrovná nakreslený drát, který není vyrovnán (není v jedné rovině), do roviny, která odpovídá střední výšce nevyrovnaných drátů.
Toto makro vyrovná nakreslený drát, který není vyrovnán (není v jedné rovině), do roviny, která odpovídá střední výšce nevyrovnaných drátů.
</div>


==Script==
==Script==

Revision as of 14:11, 9 August 2018

File:Text-x-python FlattenWire

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

Version macro : 1.0
Date last modification : 2011-08-01
Autor: Yorik
Autor
Yorik
Download
None
Odkazy
Verze
1.0
Datum poslední úpravy
2011-08-01
Verze FreeCAD
None
Výchozí zástupce
None
Viz též
None

Deskriptivní

Toto makro vyrovná nakreslený drát, který není vyrovnán (není v jedné rovině), do roviny, která odpovídá střední výšce nevyrovnaných drátů.

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: newppoints.append(FreeCAD.Vector(p.x,p.y,z))
obj.Points = newppoints