Load data from an excel file and write data to this excel file

I have two problems:

first I have to load datas from an excelfile and I wrote

import trimatic
import os
import numpy as np
from openpyxl import load_workbook

def main():
print(os.path.abspath(“D:\201110 ArbeitUlm\210411 Daten\K11\CycleExtraction_CSV”)
file = load_workbook(“K11_MC_30_3rdCycle.xlsx”)
ws = file[‘Tabelle1’]

#print(ws['A2'].value)

p1F_coord = (ws['A2'].value, ws['B2'].value, ws['C2'].value)
p2F_coord = (ws['D2'].value, ws['E2'].value, ws['F2'].value)
p3F_coord = (ws['G2'].value, ws['H2'].value, ws['I2'].value)

print(p1F_coord)
print(p2F_coord)
print(p3F_coord)

p1F = trimatic.create_point(p1F_coord)
p2F = trimatic.create_point(p2F_coord)
p3F = trimatic.create_point(p3F_coord)

new_planeF = trimatic.create_plane_3_points(p1F,p2F,p3F)
new_planeF.name = "EbeneFemurNeu"

main()

and than I need to export created datas (x,y,z) in 3-matics to this excel file: How can I address the points generated? - I can’t show a screenshot at the moment because 3-matics has said goodbye. I hope you know what I mean.

print(TKC_duplicate.Properties.Coordinates)
print(TKC_duplicate.Coordinates)
print(LandmarkenTibiaDuplikate.TKC_duplicate.Properties.Coordinates)
print(LandmarkenTibiaDuplikate.TKC_duplicate.Coordinates)

please help me

Dear Ela Ge,

Regarding the export of coordinates in 3-matic to excel, this depend on the object. If you have a point, after assigning the point to a variable, you can get the coordinates via the “coordinates” property and you can split it in the x, y and z value by indicating which element you want to use [0] for x, [1] for y and [2] for z. An example:

image001.png

These values can be directly written to a specific cell (row & column) in excel.

Your second problem is not directly clear to me, is this regarding the import of the values in excel?

Kind regards,

Marnic

Thank you, I can try tomorrow, because my SW is not available now.

Yes, I need the 3 values (x, y, z) in the second row from each marker (each 3 for femur, patella and tibia) to create a new plane

sorry, may i know how to write to an excel file?

Hi Teddy. Scripting in our software is done in Python. Marnic above described how to read the data from 3-Matic using the API, which activates tools or objects specific to MIS software. Writing to excel is independent of our software, and indeed can be done easily with this python module: XlsxWriter is a Python module for creating Excel XLSX files. I am sure there are other modules as well, but this is one of the more common ones I saw on Google. Hope this helps!