# ZGM missions2csv powershell script
 
$d = gc mission.sqm																								# Read the incoming 3Deditor file
$rows = @() 																								# Empty array for results
#$rows += "TYPE; POSITION [X; Y; Z];AZIMUT" 											# Header row (deactivated, kept in for purposes)
for ($i=0; $i -le $d.count -2; ++$i) {										 							# Loop through the data
  if( $d[$i] -match "position" ) { 																		# positionelement, let's pick it and two next lines
     $pos = $d[$i].Replace('position[]={', '').Replace('};','').trim() 						# Replace and trim
     $typ = $d[$i+4].Replace('vehicle=', '').Replace(';', '').Replace(' ', '')
     $ori = $d[$i+1].Replace('azimut=', '').trim() 	
     $rows += $("{0};{1};{2}" -f $typ,$pos,$ori).trim() 										# Reorder
  } 
}
sc -path ZGM_viso2.csv -value $rows																# Write output to a file

