Forum

Author Topic: How export the Date & time  (Read 2689 times)

SixenseLamier

  • Newbie
  • *
  • Posts: 7
    • View Profile
How export the Date & time
« on: July 18, 2019, 12:47:43 PM »
Hello !
I would like add the date and the time to my txt export file.
Below, the script, that i use to export my markers.
I want add Date&time after the Name of markers. Some help please for the script  :-\?

Code: [Select]

import Metashape, math
FILEPATH1 = 'C:/Alexandre/PFE/7.Couloir/Les_scène_refait/PYTHON/Export_donnée/Coordo_marker.txt'#lien fichier export

#Export des Markers


doc = Metashape.app.document
chunk = doc.chunk
T = chunk.transform.matrix
f = open(FILEPATH1, 'w')


for item in chunk.markers:
   if item.position == None:
      continue
   v = item.position
   v.size = 4
   v.w = 1
   if not chunk.transform:
      chunk.transform.matrix = Metashape.Matrix.Diag( (1,1,1,1) )
   T = chunk.transform.matrix
   v_t = T * v
   v_t.size = 3
   proj = chunk.crs
   v_out = proj.project(v_t)
   f.write(item.label + ',' + str(v_out[0]) + ',' + str(v_out[1]) + ',' + str(v_out[2]) +  '\n')
f.close()



Regards !
Alex  ;)

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15177
    • View Profile
Re: How export the Date & time
« Reply #1 on: July 18, 2019, 12:50:05 PM »
Hello Alex,

Do you mean current date and time?

Maybe something like that then:
Code: [Select]
import Metashape, datetime
FILEPATH1 = 'C:/Alexandre/PFE/7.Couloir/Les_scène_refait/PYTHON/Export_donnée/Coordo_marker.txt'#lien fichier export

#Export des Markers

doc = Metashape.app.document
chunk = doc.chunk
T = chunk.transform.matrix
f = open(FILEPATH1, 'w')

for item in chunk.markers:
if not item.position:
continue
if chunk.crs:
v_out = chunk.crs.project(T.mulp(item.position))
else:
v_out = T.mulp(item.position)
f.write(item.label + "," + datetime.datetime.now().strftime("%Y-%m-%d,%H:%M:%S") + ",{:.7f},{:.7f},{:.7f}\n".format(v_out.x, v_out.y, v_out.z))
f.close()
« Last Edit: July 18, 2019, 01:06:15 PM by Alexey Pasumansky »
Best regards,
Alexey Pasumansky,
Agisoft LLC

SixenseLamier

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: How export the Date & time
« Reply #2 on: July 23, 2019, 05:15:16 PM »
Thank you !
It's Perfect  8) 8) 8)