Brewall Conversion to Meters for Core

/* test data:

Remove spaces and "P" using Notepad++ first.

-3846.0,-2644.0,-170.0,-3841.0,-3828.0,-179.0,0,0,255
-3545.0,2745.0,4.0,-3686.0,2569.0,4.0,65,65,65
-3545.0,2745.0,4.0,-3515.0,2710.0,4.0,199,21,133
162.0,1903.0,-127.0,162.0,1882.0,-127.0,199,21,133
-1898.0,-3348.0,-179.0,-1915.0,-3356.0,-179.0,150,150,150




*/

<!DOCTYPE html>
<html>
<body>

<p>Click the button to extract the data.</p>

<button onclick="myFunction()">Try it</button>


<textarea id="ta">INPUT</textarea>


<textarea id="demo">OUTPUT</textarea>

<script>



var res = "new Array(";
function myFunction() {
    // get single line
    var lines = document.getElementById("ta").value.split('\n');
    document.getElementById("demo").innerHTML = "";
    let _read = new Array();
    let _together = "";
    let _toggle = 0;
    let _myName = "";
    let _myName2 = "";    
    let _myX = "";
    let _myY = "";
    let _myZ = "";
    let _myX2 = "";
    let _myY2 = "";
    let _myZ2 = "";

    let _xyzdata = "";
    var myLine = "";
    var ni = false;
   for(var i = 0;i < lines.length;i++){
      //code here using lines[i] which will give you each line

      myLine = lines[i];
      if(2>1){
        myLine = lines[i];
        _myName = "point";// position 1
        _myName2 = "point2";// position 2
        // now get xyz values
        _myX = myLine.split(',')[0];
        _myY = myLine.split(',')[1];
        _myZ = myLine.split(',')[2];
        _myX2 = myLine.split(',')[3];
        _myY2 = myLine.split(',')[4];
        _myZ2 = myLine.split(',')[5];
        res += `[`+(_myX/3.281*-100).toFixed(2)+`,`+(_myY/3.281*-100).toFixed(2)+`,`+(_myZ/3.281*100).toFixed(2)+`,"`+_myName+`"],\n`;
        res += `[`+(_myX2/3.281*-100).toFixed(2)+`,`+(_myY2/3.281*-100).toFixed(2)+`,`+(_myZ2/3.281*100).toFixed(2)+`,"`+_myName2+`"],\n`;
      }
    }
    res += ");";    
    document.getElementById("demo").innerHTML = res;    
    
}//end fn


</script>
</body>
</html>

Latest Posts