Macro WireXYZ/fr: Difference between revisions

From FreeCAD Documentation
mNo edit summary
(Updating to match new version of source page)
Line 1: Line 1:
<languages/>
<languages/>
<div class="mw-translate-fuzzy">
{{Macro/fr
{{Macro/fr
|Name=WireXYZ
|Name=WireXYZ
Line 7: Line 8:
|Date=2016-09-06
|Date=2016-09-06
}}
}}
</div>


==Description==
==Description==
Line 23: Line 25:
{{Code|code=
{{Code|code=
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
# created a wire with coordinate x y z separated (in the file)
# created a wire with coordinate x y z separated (in the file without coma)
__title__= "Macro_WireXYZ"
__author__= "Mario52"
__date__= "2019/07/02"
__version__= "00.02"
##
#EX:
#EX:
#0 0 0
#0 0 0
Line 30: Line 38:
#. . . .
#. . . .


from __future__ import unicode_literals
from FreeCAD import Base
from FreeCAD import Base
import Draft, Part
import Draft, Part


fichier = "C:\yourPath\cloud.asc" # path and name of file.txt
fichier = "C:\yourPath\cloud.asc" # path and name of file.txt

file = open(fichier, "r") # open the file read
file = open(fichier, "r") # open the file read
wire = []
wire = []
Line 44: Line 50:
X,Y,Z = coordinates # separate the coordinates
X,Y,Z = coordinates # separate the coordinates
# Draft.makePoint(float(X),float(Y),float(Z)) # create points (uncomment for use)
# Draft.makePoint(float(X),float(Y),float(Z)) # create points (uncomment for use)
print X," ",Y," ",Z
print(X," ",Y," ",Z)
wire.append(FreeCAD.Vector(float(X),float(Y),float(Z))) # append the coordinates
wire.append(FreeCAD.Vector(float(X),float(Y),float(Z))) # append the coordinates


Line 50: Line 56:
Draft.makeWire(wire,closed=False,face=False,support=None) # create the wire open
Draft.makeWire(wire,closed=False,face=False,support=None) # create the wire open
#Draft.makeWire(wire,closed=True,face=False,support=None) # create the wire closed (uncomment for use)
#Draft.makeWire(wire,closed=True,face=False,support=None) # create the wire closed (uncomment for use)
App.ActiveDocument.recompute()



}}
}}
Line 94: Line 102:
==Liens==
==Liens==
La discussion sur le forum [http://forum.freecadweb.org/viewtopic.php?f=3&t=7828 How do I transform a point cloud to a line?]
La discussion sur le forum [http://forum.freecadweb.org/viewtopic.php?f=3&t=7828 How do I transform a point cloud to a line?]

==Version==

00.02 02/07/2019 :

00.01 21/02/2015

Revision as of 18:18, 2 July 2019

Other languages:

Generic macro icon WireXYZ

Description
Crée un wire avec les coordonnées x y z séparées par un espace. Les données sont extraites d'un fichier.

Version macro : 0.1
Date dernière modification : 2016-09-06
Auteur: Mario52
Auteur
Mario52
Téléchargement
None
Liens
Version Macro
0.1
Dernière modification
2016-09-06
Version(s) FreeCAD
None
Raccourci clavier
None
Voir aussi
None

Description

Cette macro crée un wire (ou points) avec les coordonnées XYZ extraites d'un fichier. Les coordonnées X Y Z sont séparées par un espace.

Utilisation

Le fichier doit avoir les coordonnées X Y Z au ASCII sans entête.

Script

Macro_WireXYZ.FCMacro

# -*- coding: utf-8 -*-
from __future__ import unicode_literals
# created a wire with coordinate x y z separated (in the file without coma)
__title__= "Macro_WireXYZ"
__author__= "Mario52"
__date__= "2019/07/02"
__version__= "00.02"
##
#EX:
#0 0 0
#10 10 10
#15 20 25
#. . . .

from FreeCAD import Base
import Draft, Part

fichier = "C:\yourPath\cloud.asc"                          # path and name of file.txt
file = open(fichier, "r")                                  # open the file read
wire = []
X=Y=Z = 0.0

for ligne in file:
    coordinates = ligne.split()
    X,Y,Z = coordinates                                     # separate the coordinates
#    Draft.makePoint(float(X),float(Y),float(Z))            # create points (uncomment for use)
    print(X," ",Y," ",Z)
    wire.append(FreeCAD.Vector(float(X),float(Y),float(Z))) # append the coordinates

file.close()
Draft.makeWire(wire,closed=False,face=False,support=None)   # create the wire open
#Draft.makeWire(wire,closed=True,face=False,support=None)   # create the wire closed (uncomment for use)
App.ActiveDocument.recompute()

Exemples

0 240.42686 0

20 243.83054 0

40 247.33677 0

60 250.94702 0

80 254.66283 0

100 258.48575 0

...

Modifiez le chemin et nom du fichier, sauvez la macro, rechargez la macro et lancez la.

fichier = "C:\yourPath\cloud.asc"                          # path and name of file.txt

Si vous voulez un wire fermé, modifiez le code (closed=False):

Draft.makeWire(wire,closed=False,face=False,support=None)   # create the wire open


et remplacez le par (closed=True)

Draft.makeWire(wire,closed=True,face=False,support=None)   # create the wire closed

même procédure pour la face, False ou True (face=True).


Liens

La discussion sur le forum How do I transform a point cloud to a line?

Version

00.02 02/07/2019 :

00.01 21/02/2015