Created
July 29, 2023 19:36
-
-
Save juanpaexpedite/8a2265bc168ef50f15f72bf77633158b to your computer and use it in GitHub Desktop.
List FreeCad objects wit 'Part_'
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# List all objects | |
# -*- coding: utf-8 -*- | |
import FreeCAD,Draft | |
# List all objects of the document | |
doc = FreeCAD.ActiveDocument | |
objs = FreeCAD.ActiveDocument.Objects | |
#App.Console.PrintMessage(str(objs) + "\n") | |
#App.Console.PrintMessage(str(len(FreeCAD.ActiveDocument.Objects)) + " Objects" + "\n") | |
def clearConsole(): | |
from PySide import QtGui | |
mw=Gui.getMainWindow() | |
c=mw.findChild(QtGui.QPlainTextEdit, "Python console") | |
c.clear() | |
r=mw.findChild(QtGui.QTextEdit, "Report view") | |
r.clear() | |
clearConsole() | |
App.Console.PrintMessage("PART;Length\n") | |
for obj in objs: | |
a = obj.Name # list the Name of the object (not modifiable) | |
b = obj.Label # list the Label of the object (modifiable) | |
if 'Part_' in obj.Label: | |
try: | |
d = obj.Shape.BoundBox | |
#CSV STYLE | |
#App.Console.PrintMessage(str(b) + ";" + str(round(d.XLength)) + ";" + str(round(d.YLength)) + ";" + str(round(d.ZLength)) +"\n") | |
max_dimension = max(d.XLength, d.YLength, d.ZLength) | |
#App.Console.PrintMessage(str(b) + ";" + str(round(max_dimension)) + "\n") | |
App.Console.PrintMessage(str(round(max_dimension)) + "- 1" + "\n") | |
except: | |
App.Console.PrintMessage("ERROR IN PART\n") | |
#doc.removeObject("Box") # Clears the designated object |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment