FreeCAD Module Part List Generator

From Open Source Ecology
Jump to: navigation, search

Goal

Create a macro that generates a parts list from the object list labels in a module file. Also, separate the module objects into individual, separate FCStd files with unique names based on the object list labels. This automation will significantly speed up the generation of module parts lists such as for File:8footwall.FCStd

Estimated Time Savings

Modules with a dozen parts might take 1-2 hours to separate into parts gallery and associated FCStd files on the wiki. With a macro to generate the parts, this time could be reduced by nearly half.

Work in Progress

Developing a script based off of Macro Dump Objects Script

File:List All Objects.FCMacro.zip

List all objects

Use the code listed at FreeCAD Code Snippets to simply list the objects and manipulate the labels to remove part totals.

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")

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)
    try:
        c = obj.LabelText                                    # list the LabeText of the text (modifiable)
        App.Console.PrintMessage(str(a) +" "+ str(b) +" "+ str(c) + "\n") # Displays the Name the Label and the text
    except:
        App.Console.PrintMessage(str(a) +" "+ str(b) + "\n") # Displays the Name and the Label of the object

#doc.removeObject("Box") # Clears the designated object