Code: Select all
Selection = FreeCADGui.Selection.getSelectionEx()
TargetReferencePoint = Selection[1].SubObjects[0].CenterOfMass
BasePoint = Selection[0].SubObjects[0].CenterOfMass
BaseNormal = Selection[0].SubObjects[0].normalAt(0,0)
TargetPoint = Selection[0].SubObjects[0].CenterOfMass.projectToPlane(TargetReferencePoint,BaseNormal)
Difference = TargetReferencePoint.distanceToPlane(BasePoint,BaseNormal)
TargetVector = TargetPoint.sub(BasePoint)
if Selection[0].SubElementNames[0] == 'Face1':
Selection[0].Object.Length = Selection[0].Object.Length.Value + Difference
Selection[0].Object.Placement.Base = Selection[0].Object.Placement.Base.add(TargetVector)
elif Selection[0].SubElementNames[0] == 'Face2':
Selection[0].Object.Length = Selection[0].Object.Length.Value + Difference
elif Selection[0].SubElementNames[0] == 'Face3':
Selection[0].Object.Width = Selection[0].Object.Width.Value + Difference
Selection[0].Object.Placement.Base = Selection[0].Object.Placement.Base.add(TargetVector)
elif Selection[0].SubElementNames[0] == 'Face4':
Selection[0].Object.Width = Selection[0].Object.Width.Value + Difference
elif Selection[0].SubElementNames[0] == 'Face5':
Selection[0].Object.Height = Selection[0].Object.Height.Value + Difference
Selection[0].Object.Placement.Base = Selection[0].Object.Placement.Base.add(TargetVector)
else: Selection[0].Object.Height = Selection[0].Object.Height.Value + Difference
1. Select BOTH the face you want to change, THEN the target thing
2. Run the macro
Limitations:
-Only works on standard cubes
-First object selected must be a face. The second object can be a face or an edge, but not a vertex