Macro WireXYZ: Difference between revisions
m (version title) |
m (minor) |
||
Line 45: | Line 45: | ||
</translate> |
</translate> |
||
<syntaxhighlight> |
<syntaxhighlight> |
||
Draft.makeWire(wire,closed=False,face=False,support=None) # create the wire |
Draft.makeWire(wire,closed=False,face=False,support=None) # create the wire open |
||
</syntaxhighlight> |
</syntaxhighlight> |
||
<translate> |
<translate> |
||
Line 52: | Line 52: | ||
</translate> |
</translate> |
||
<syntaxhighlight> |
<syntaxhighlight> |
||
Draft.makeWire(wire,closed=True,face=False,support=None) # create the wire |
Draft.makeWire(wire,closed=True,face=False,support=None) # create the wire closed |
||
</syntaxhighlight> |
</syntaxhighlight> |
||
<translate> |
<translate> |
Revision as of 08:34, 6 September 2016
File:Text-x-python WireXYZ |
Description |
---|
Creates a wire with coordinate x y z. Macro version: 0.1 Author: Mario52 |
Author |
Mario52 |
Download |
None |
Links |
Macros recipes How to install macros How to customize toolbars |
Macro Version |
0.1 |
Date last modified |
None |
FreeCAD Version(s) |
None |
Default shortcut |
None |
See also |
None |
Description
This macro creates a wire (or points) with the coordinates extracted from a file. The coordinates X Y Z are separated by a space.
Use
The file must have three coordinates X Y Z in ascii format without header
Ex:
0 240.42686 0
20 243.83054 0
40 247.33677 0
60 250.94702 0
80 254.66283 0
100 258.48575 0
...
Modify your path and name of file, save and load the macro and run.
fichier = "C:\yourPath\cloud.asc" # path and name of file.txt
If you want a close wire modify this line (closed=False):
Draft.makeWire(wire,closed=False,face=False,support=None) # create the wire open
and replace with (closed=True):
Draft.makeWire(wire,closed=True,face=False,support=None) # create the wire closed
same for the face, False or True (closed=True).
Script
Macro_WireXYZ.FCMacro
# -*- coding: utf-8 -*-
# created a wire with coordinate x y z unseparated (in the file)
#EX:
#0 0 0
#10 10 10
#15 20 25
#. . . .
from __future__ import unicode_literals
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)
Links
The discussion How do I transform a point cloud to a line?