Macro Wiki Object Properties List Generator

Description
This macro generates lists of properties of the selected object of the selected object in different forms in Wiki format. The list is printed to the "view Report" panel of FreeCAD. This macro can be used to simplify working with this Wiki with some restrictions. The property lists published in Wiki usually contain only unique parameters. Parameters inherited from parent objects are not published.

This script automatically removes inherited parameters from the list. But due to the software limitations of FreeCAD, it cannot delete absolutely all inherited parameters, so the lists generated by this script should be carefully checked before publishing. Link to previous version

Indroduction
Each object created in FreeCAD is inherited from the parent object. The structure of these relationships is shown in the diagram below. You can read more about this on the page: Part Feature



How To Use

 * Preparing:
 * Copy code of Macro from this page and place it new *.FCMacro file.
 * Save FCMacro file. And place it to FreeCAD Macros folder.
 * Disable Include a time code for each entry checkbox in Preferences -> General -> Output window (Tab).


 * First using:
 * Select (or create and select) only one object in tree view the type of you need.
 * Select Macro -> Macros... item in main menu.
 * In opened window find *.FCMacro file what you save letter and press Execute Button.
 * In the dialog that opens, select the type of report that you want to get by pressing button:
 * Only Main - prints only unique properties of base (parent) classes.
 * All Properties - prints absolutly all properties of selected object.
 * Inherits+Unique Properties - prints only unique properties with included inherits report.
 * Only Unique Properties - prints only unique properties.


 * How to use again:
 * To quickly run this macro again, you can use keyboard shortcut Shift+Ctrl+1 (on Windows) it will launch the last runned macro.

Recommendations
Do not delete spaces between lines. This is necessary to simplify the translation. Each line separated by a space will be considered a separate part for translation. When creating texts, always remember that large monolithic fragments of text are difficult for translators to translate.

Examples of using

 * For example open Part Worckbench
 * Create Sphere object.
 * Select created Sphere objcet.
 * Run macros.
 * Select All Properties in opened dialog

Macro will generate this text:

...

Generates properties of all parent base classes
...

Script
"+re.sub(r"[\[\]\']","",str(atr))    else:         atr = ""      if blacklist == None or (blacklist != None and pr not in blacklist):         prop[str(i)] = pr,obj.getGroupOfProperty(pr),tp.replace("App::Property",""),obj.getDocumentationOfProperty(pr),atr         i+=1      else:         inherits += pr + " inherited from class" + blacklist[pr] + "\n"

if inherits != "" and show_inherits: print("\n\x3C!--\n"+inherits+"--\x3E") sorted_prop = sorted(prop.items, key=lambda x: x[1][1])

title="" for pr in sorted_prop: if title != pr[1][1]: title = pr[1][1] print("\n"+"") print("\n"+"* : "+pr[1][3])

def add_to_blacklist(data_blacklist,view_blacklist,obj_type,temp_obj_name,show_report): printsr("Class: '"+obj_type+"'",show_report) # Make tempory object obj = FreeCAD.activeDocument.addObject(obj_type,temp_obj_name) name = obj.Name # Get Data parametrs printsr("Data parameters list:",show_report) for pr in obj.PropertiesList: if not show_report or pr not in data_blacklist: data_blacklist[pr]=obj_type atr = str(obj.getTypeOfProperty(pr)).replace("[]","") typeid = (obj.getTypeIdOfProperty(pr) or "").replace("App::Property","") printsr(pr+" ("+typeid+") "+atr,show_report) # Get View parameters if it is possible obj = Gui.activeDocument.getObject(name) try: test = obj.PropertiesList printsr("View parameters list:",show_report) for pr in obj.PropertiesList: if not show_report or pr not in view_blacklist: view_blacklist[pr]=obj_type atr = str(obj.getTypeOfProperty(pr)).replace("[]","") typeid = (obj.getTypeIdOfProperty(pr) or "").replace("App::Property","") printsr(pr+" ("+typeid+") "+atr,show_report) except: printsr("This class not support View parameters.",show_report) # Remove object FreeCAD.activeDocument.removeObject(name) printsr("",show_report) return data_blacklist,view_blacklist
 * 1) Add propertyes to blacklist if it not presentet in it yet

def fill_blacklists(show_report): data_blacklist={} view_blacklist={} # Interfaces are not supported #data_blacklist,view_blacklist = add_to_blacklist(data_blacklist,view_blacklist,"App::OriginGroupExtension","Temp",show_report) #data_blacklist,view_blacklist = add_to_blacklist(data_blacklist,view_blacklist,"Part::AttachExtension","Temp",show_report) #data_blacklist,view_blacklist = add_to_blacklist(data_blacklist,view_blacklist,"Sketcher::PropertyConstrainList","Temp",show_report) data_blacklist,view_blacklist = add_to_blacklist(data_blacklist,view_blacklist,"App::DocumentObject","Temp",show_report) data_blacklist,view_blacklist = add_to_blacklist(data_blacklist,view_blacklist,"App::GeoFeature","Temp",show_report) data_blacklist,view_blacklist = add_to_blacklist(data_blacklist,view_blacklist,"App::Part","Temp",show_report) data_blacklist,view_blacklist = add_to_blacklist(data_blacklist,view_blacklist,"Mesh::Feature","Temp",show_report) data_blacklist,view_blacklist = add_to_blacklist(data_blacklist,view_blacklist,"Fem::FemMeshObject","Temp",show_report) data_blacklist,view_blacklist = add_to_blacklist(data_blacklist,view_blacklist,"Path::Feature","Temp",show_report) data_blacklist,view_blacklist = add_to_blacklist(data_blacklist,view_blacklist,"Part::Part2DObject","Temp",show_report) # Part::Primitive is not possible to create #data_blacklist,view_blacklist = add_to_blacklist(data_blacklist,view_blacklist,"Part::Primitive","Temp",show_report) data_blacklist,view_blacklist = add_to_blacklist(data_blacklist,view_blacklist,"PartDesign::Feature","Temp",show_report) data_blacklist,view_blacklist = add_to_blacklist(data_blacklist,view_blacklist,"Part::BodyBase","Temp",show_report) data_blacklist,view_blacklist = add_to_blacklist(data_blacklist,view_blacklist,"PartDesign::Body","Temp",show_report) if show_report: print("List of all not unique properties of Data:\n"+str(data_blacklist)+"\n\nList of all not unique properties of View:\n"+str(view_blacklist)+"\n") return data_blacklist,view_blacklist

sel = FreeCADGui.Selection.getSelection if len(sel) != 1: msgbox = QtGui.QMessageBox(QtGui.QMessageBox.Question, u'Properties Generator', """You must select only one object in tree view!""") msgbox.exec_ else: # Show dialog for select type of report msgbox = QtGui.QMessageBox(QtGui.QMessageBox.Question, u'Properties Generator', """Select type of report Only Main - print only unique properties of main classes with types. All Properties - print all properties of selected object. Inherits+Unique Properties - print unique properties with inherits report. Only Unique Properties - print only unique properties of selected object. """) msgbox.setStandardButtons(QtGui.QMessageBox.Cancel) #

Links
The discussion on the forum []