It's rough but I think it works...
In TechDraw, select multiple Horizontal or Vertical dimensions, this will then set their position the same
*set where you want the label before using script!
Code: Select all
import FreeCAD
from FreeCAD import Base
import math, collections
from PySide import QtGui, QtCore
print("\nDIMENSION ALIGN\n")
def get_selection():
View = []
if Gui.Selection.getCompleteSelection():
View = Gui.Selection.getCompleteSelection()
return View
o = get_selection()
#print(o)
#print(dir(o[2]))
#print(o[2].Type)
#print(o[2].X)
if len(o) > 0:
if len(o) == 1:
print("Select multiple objects (of same type)")
else:
# GET FIRST TYPE
o_type = o[0].Type
#print(o_type)
if o_type == "DistanceY":
a = []
# ADD FIRST OBJECT
a.append(o[0])
#print(a)
# ADD OTHERS OF SAME TYPE
for i in range(1, len(o)):
#print(o[i].ID)
if o[i].Type == o_type:
a.append(o[i])
# DUMP
#print(a)
for e in a:
#print("Label: ", e.Label)
#print("Label2: ", e.Label2)
print("Name: ", e.Name)
#print("FullName: ", e.FullName)
print("ID: ", e.ID)
# ALIGN X
n = o[0].X
for i in range(1, len(o)):
o[i].X = n
elif o_type == "DistanceX":
a = []
# ADD FIRST OBJECT
a.append(o[0])
#print(a)
# ADD OTHERS OF SAME TYPE
for i in range(1, len(o)):
#print(o[i].ID)
if o[i].Type == o_type:
a.append(o[i])
# DUMP
#print(a)
for e in a:
#print("Label: ", e.Label)
#print("Label2: ", e.Label2)
print("Name: ", e.Name)
#print("FullName: ", e.FullName)
print("ID: ", e.ID)
# ALIGN Y
n = o[0].Y
for i in range(1, len(o)):
o[i].Y = n
else:
print("First selected object is not either DistanceY or DistanceX type")