What's new

TXT to Reference-Points

ruesve

Member
Hello Everybody,
I want to import my txt with xyz coordinates into alibre design as Reference Points:
ZJj6epd.png


this is how i tested this:

Code:
inputfile = r"C:\Users\Sven\Downloads\3D_20190829_095023_pt.txt"

f = open(inputfile)

for line in f:
  cords = line.split(',')
  cords[0] = float(cords[0])
  cords[1] = float(cords[1])
  cords[2] = float(cords[2].rstrip())
  #Part.AddPoint(cords[0],cords[1],cords[2])
  #SketchPoint3D(cords[0],cords[1],cords[2], True)
f.close()


This is what my txt looks like:
Code:
0.00000,0.00000,0.00000
64.61156,21.20283,-41.10192
8.08571,6.92229,-279.95572
17.68998,135.43602,-450.01097
668.77743,-1890.88657,-384.42378
286.98575,-707.45653,-1337.80650
1106.99920,-1918.56924,-362.13512
988.89547,-1953.16159,-491.35581
345.73289,-422.30554,-358.78444
1691.74661,-2532.03828,-361.87043
2801.75353,-407.41589,-368.36579
222.15515,-43.59231,-21.77737
451.41220,29.26722,-21.95582
54.82811,63.20793,10.76991
31.75105,61.14198,788.43944

or how do i add Reference Points to the active 3D Area?

Best regards,
Sven
 

idslk

Alibre Super User
Hello Sven,

a lunch break forum search shows:
https://www.alibreforum.com/forum/i...set-a-referencesketchpoint.20883/#post-133741
:);)

If it's ok to have "standard" points:
Code:
cp = CurrentPart()

textpoints = cp.Add3DSketch('Text_Points')

inputfile = r"C:\Users\Sven\Downloads\3D_20190829_095023_pt.txt"

Number = 0

f = open(inputfile)

for line in f:
  Number += 1
  cords = line.split(',')
  cords[0] = float(cords[0])
  cords[1] = float(cords[1])
  cords[2] = float(cords[2].rstrip())
  cp.AddPoint('Svenpoint_' + str(Number), cords[0],cords[1],cords[2])
f.close()

Then you can do a paint by numbers like "draw a line from Svenpoint_1 to Svenpoint_2 ..."

Regards
Stefan
 

ruesve

Member
Hi Stefan,
Thank you very much for your answer and your solution, it works really great.

Best Regards,
Sven
 
Top