Distance between two points over X and Y axes

Hi everybody, first timer poster here!

I am looking for a script to help me improve a tedious task at my work.

What I am currently doing is measuring the distance between a base point and an areacentroid point over the X and Y axes (In top view) using Dims in Rhino, then manually inputting those values into Excel.

What I would like the script to do is let me input a number and store it in an array as (1)

Then, allow me to select a point to serve as basepoint and then another point as target and store the distance over X axis as (2) and Y axis as (0)

The desired outcome of the script is: I insert an integer like 5, the script measures X = 350 and Y = 500. The array is 500,5,350. Then it splits those values up and adds them to my clipboard with vbTab inbetween so i can paste those values into excel.

I have been reading into the rhinoscript guide on developer.rhino3d.com but I am a total rookie and I can’t figure this problem out… If anybody could help me out or point me in the right direction as to how I can measure the distance between two points over the axes like that it would help me out a ton.

import rhinoscriptsyntax as rs
import csv
def CSVwrite():
    outputs = []
    while True:
        n = rs.GetInteger("Number")
        if n is None: break
        b = rs.GetPoint("Base Point")
        if b is None: break
        t = rs.GetPoint("Target Point")
        if t is None: break
        outputs.append([t[1]-b[1], n, t[0]-b[0]])
    if len(outputs) == 0: return
    filter = "CSV File (*.csv)|*.csv|*.txt|All Files (*.*)|*.*||"
    filename = rs.SaveFileName("Save as", filter)
    if(filename is None): return
    with open(filename, "wb") as csvfile:
        csvwriter = csv.writer(csvfile,  delimiter=',')
        print "Outputs written sucessfully to file"
if( __name__ == "__main__" ):

CSVWrite.py (773 Bytes)

@Mahdiyar, should’t this be absolute values eg. abs(t[1] - b[1]) ?

Below copies to clipboard using tab seperator:

import rhinoscriptsyntax as rs

def DoSomething():
    number = rs.GetInteger("Number")
    if number is None: return
    pt0 = rs.GetPoint("Base point")
    if not pt0: return
    pt1 = rs.GetPoint("Target point")
    if not pt1: return
    dx = abs(pt0.X - pt1.X)
    dy = abs(pt0.Y - pt1.Y)
    text = "{0:.5f}\t{1}\t{2:.5f}".format(dy, number, dx)
    print text


This solved the problem I was having perfectly, thanks so much!! Python is wild