Skip to content

Instantly share code, notes, and snippets.

@Rahix
Created February 11, 2023 22:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Rahix/989c471bba6d1e33759f0fcdb91f8970 to your computer and use it in GitHub Desktop.
Save Rahix/989c471bba6d1e33759f0fcdb91f8970 to your computer and use it in GitHub Desktop.
FreeCAD macro to calculate the cumulative length of all selected edges
# inspired by https://forum.freecad.org/viewtopic.php?t=44309
from PySide import QtCore, QtGui
edges = FreeCADGui.Selection.getSelectionEx()[0].SubObjects
length = sum(e.Length for e in edges)
print(f"Length of selected edges is {length:.2f} mm.")
diag = QtGui.QMessageBox(QtGui.QMessageBox.Information, "Edge Length", f"Length of selected edges is {length:.2f} mm.")
diag.setWindowModality(QtCore.Qt.ApplicationModal)
diag.exec_()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment