Macro FlattenWire3Points/fr: Difference between revisions
(Updating to match new version of source page) |
(Created page with "Icône de la barre d'outils Image:Macro_FlattenWire3Points.png") |
||
(15 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
⚫ | |||
{{Macro|Icon=Text-x-python|Name=FlattenWire3Points|Description=This macro flattens draft wires that are not planar on a plane defined by 3 points|Author=Yorik|Version=1.0}} |
|||
{{Macro/fr |
|||
|Name=FlattenWire3Points |
|||
|Icon=Macro_FlattenWire3Points.png |
|||
|Description=Cette macro aplatit les fils (Wire) du projet qui ne sont pas plan à la médiane de leurs coordonnées z |
|||
|Author=Yorik |
|||
|Version=1.0 |
|||
|Date=2016-02-06 |
|||
|FCVersion=All |
|||
|Download=[https://www.freecadweb.org/wiki/images/1/1e/Macro_FlattenWire3Points.png ToolBar Icon] |
|||
}} |
|||
==Description== |
|||
Cette macro aplatit les fils qui ne sont pas planaires sur un plan défini par 3 points. Pour utiliser cette macro, sélectionnez les 3 premiers sommets d'un seul [[Draft Wire/fr|Draft Wire]]. |
|||
==Script== |
|||
Icône de la barre d'outils [[Image:Macro_FlattenWire3Points.png]] |
|||
'''Macro_FlattenWire3Points.FCMacro''' |
|||
This macro flattens draft wires that are not planar on a plane defined by 3 points. To use this macro, select first 3 vertices from a single [[Draft Wire]]. |
|||
{{ |
{{MacroCode|code= |
||
import FreeCAD,FreeCADGui,Draft |
import FreeCAD,FreeCADGui,Draft |
||
Line 38: | Line 55: | ||
sel.Object.Points = points |
sel.Object.Points = points |
||
}} |
}} |
||
⚫ |
Latest revision as of 19:56, 7 July 2021
Description |
---|
Cette macro aplatit les fils (Wire) du projet qui ne sont pas plan à la médiane de leurs coordonnées z Version macro : 1.0 Date dernière modification : 2016-02-06 Version FreeCAD : All Téléchargement : ToolBar Icon Auteur: Yorik |
Auteur |
Yorik |
Téléchargement |
ToolBar Icon |
Liens |
Page des macros Comment installer une macro Comment créer une barre d'outils |
Version Macro |
1.0 |
Dernière modification |
2016-02-06 |
Version(s) FreeCAD |
All |
Raccourci clavier |
None |
Voir aussi |
None |
Description
Cette macro aplatit les fils qui ne sont pas planaires sur un plan défini par 3 points. Pour utiliser cette macro, sélectionnez les 3 premiers sommets d'un seul Draft Wire.
Script
Macro_FlattenWire3Points.FCMacro
import FreeCAD,FreeCADGui,Draft # check selection sel = FreeCADGui.Selection.getSelectionEx() ok = True if len(sel) != 1: FreeCAD.Console.PrintError("Please select 3 vertices from one Draft wire\n") ok = False sel = sel[0] if Draft.getType(sel.Object) not in ["Wire","BSpline"]: FreeCAD.Console.PrintError("Please select 3 vertices from one Draft wire\n") ok = False if len(sel.SubElementNames) != 3: FreeCAD.Console.PrintError("Please select 3 vertices from one Draft wire\n") ok = False for e in sel.SubElementNames: if not "Vertex" in e: FreeCAD.Console.PrintError("Please select 3 vertices from one Draft wire\n") ok = False if ok: # define a plane p1 = getattr(sel.Object.Shape,sel.SubElementNames[0]).Point p2 = getattr(sel.Object.Shape,sel.SubElementNames[1]).Point p3 = getattr(sel.Object.Shape,sel.SubElementNames[2]).Point p4 = p2.sub(p1).cross(p3.sub(p1)) # project wire points points = [] for p in sel.Object.Points: points.append(p.projectToPlane(p1,p4)) sel.Object.Points = points