# Macro Delta xyz

Other languages:
čeština • ‎Deutsch • ‎English • ‎français • ‎italiano

Macro Delta xyz

Description
Gives the Delta values and distance between 2 points.
Start the macro
Select the first point in 3D view
Select the second point in 3D view
One click in the ComboView quit the macro

Macro version : 0.1
Date last modification : 2013-11-29
FreeCAD version : All
Author
Mario52
ToolBar Icon
Macro Version
0.1
Date last modification
2013-11-29
All
Default shortcut
None
Part Measure Toggle Delta

## Description

Gives the Delta values and distance between 2 points.

## How to use

1. Start the macro
2. Select the first point in 3D view
3. Select the second point in 3D view
4. Click in ComboView to quit

## Script

ToolBar Icon

Macro_Delta_xyz.FCMacro

```# -*- coding: utf-8 -*-
#Delta x y z Click in ComboView to quit
import Draft, Part
from FreeCAD import Base

global positionX1 ;positionX1 = 0.0
global positionY1 ;positionY1 = 0.0
global positionZ1 ;positionZ1 = 0.0
global positionX2 ;positionX2 = 0.0
global positionY2 ;positionY2 = 0.0
global positionZ2 ;positionZ2 = 0.0
global pas        ;pas        = 0

def sub(first, other):
"sub(Vector,Vector) - subtracts second vector from first one"
return FreeCAD.Vector(first.x-other.x, first.y-other.y, first.z-other.z)
def length(first):
"lengh(Vector) - gives vector length"
return math.sqrt(first.x*first.x + first.y*first.y + first.z*first.z)
def dist(first, other):
"dist(Vector,Vector) - returns the distance between both points/vectors"
return length(sub(first,other))

class SelObserver:
def addSelection(self,document, object, element, position):  # Selection
global pas
global positionX1
global positionY1
global positionZ1
global positionX2
global positionY2
global positionZ2
pas+=1
if pas==1:
positionX1 = position[0]
positionY1 = position[1]
positionZ1 = position[2]
App.Console.PrintMessage("Begin    : X1 "+str(positionX1)+" Y1: "+str(positionY1)+" Z1: "+str(positionZ1)+"\n")
else:
positionX2 = position[0]
positionY2 = position[1]
positionZ2 = position[2]
App.Console.PrintMessage("End      : X2 "+str(positionX2)+" Y2: "+str(positionY2)+" Z2: "+str(positionZ2)+"\n")
App.Console.PrintMessage("Delta X  : "+str(abs(positionX1-positionX2))+"\n")
App.Console.PrintMessage("Delta Y  : "+str(abs(positionY1-positionY2))+"\n")
App.Console.PrintMessage("Delta Z  : "+str(abs(positionZ1-positionZ2))+"\n")