Macro Wiki Object Properties List Generator Basic Version

From FreeCAD Documentation
Jump to navigation Jump to search
Other languages:
English • ‎français • ‎polski

Generic macro icon. Create your personal icon with the same name of the macro Wiki List Generator of Object Properties

Description
This macro generate properties list of selected object. List presented in wiki format into Python report view.

Macro version: 0.1
Last modified: 2021-09
Author: Evgeniy
Author
Evgeniy
Download
None
Links
Macro Version
0.1
Date last modified
2021-09
FreeCAD Version(s)
None
Default shortcut
None
See also
Macro Wiki Object Properties List Generator

Description

This simple macro generate properties list of selected object. The parameters list is printed to the Report view of FreeCAD. This example is more educational in nature and is not applicable for use without editing after generate, since it includes absolutely all the parameters of the object. The lists of properties that are published in this wiki contain, as a rule, only unique parameters. The parameters inherited from the parents objects are not published.

How To Use

  • Preparing:
    • Copy code of Macro from this page and place it in a new *.FCMacro file.
    • Save FCMacro file, and place it in the FreeCAD Macros folder.
    • Disable Include a timecode for each entry checkbox in Preferences -> General -> Output window (Tab).
  • First using:
    • Select (or create and select) object the type of you need in tree view.
    • Select Macro -> Macros... item in main menu.
    • In opened window find *.FCMacro file what you save letter and press Execute Button.
  • 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 run 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.

Example of using

  • For example open the Arch Workbench
  • Create a Structure object.
  • Select the created Structure object.
  • Run the macro.
  • Copy the text from the report view and paste it in a wiki page and check the result.

Results of using

The results may look like this:

Properties

View

  • ViewProxy (PythonObject):

Component

  • ViewUseMaterialColor (Bool): Use the material color as this object's shape color, if available

Display Options

  • ViewBoundingBox (Bool): Display object bounding box
  • ViewDisplayMode (Enumeration): Set the display mode
  • ViewShowInTree (Bool): Show the object in the tree view
  • ViewVisibility (Bool): Show the object in the 3d view

Nodes

  • ViewNodeColor (Color): The color of the nodes line
  • ViewNodeLine (Float): The width of the nodes line
  • ViewNodeSize (Float): The size of the node points
  • ViewNodeType (Enumeration): The type of structural node
  • ViewShowNodes (Bool): If the nodes are visible or not

Object Style

  • ViewAngularDeflection (Angle): Specify how finely to generate the mesh for rendering on screen or when exporting.

The default value is 28.5 degrees, or 0.5 radians. The smaller the value the smoother the appearance in the 3D view, and the finer the mesh that will be exported.

  • ViewDeviation (FloatConstraint): Sets the accuracy of the polygonal representation of the model

in the 3D view (tessellation). Lower values indicate better quality. The value is in percent of object's size.

  • ViewDiffuseColor (ColorList): Object diffuse color.
  • ViewDrawStyle (Enumeration): Defines the style of the edges in the 3D view.
  • ViewLighting (Enumeration): Set object lighting.
  • ViewLineColor (Color): Set object line color.
  • ViewLineColorArray (ColorList): Object line color array.
  • ViewLineMaterial (Material): Object line material.
  • ViewLineWidth (FloatConstraint): Set object line width.
  • ViewPointColor (Color): Set object point color
  • ViewPointColorArray (ColorList): Object point color array.
  • ViewPointMaterial (Material): Object point material.
  • ViewPointSize (FloatConstraint): Set object point size.
  • ViewShapeColor (Color): Set shape color
  • ViewShapeMaterial (Material): Shape material
  • ViewTransparency (Percent): Set object transparency

Selection

  • ViewOnTopWhenSelected (Enumeration): Enabled: Display the object on top of any other object when selected

Object: On top only if the whole object is selected Element: On top only if some sub-element of the object is selected

  • ViewSelectable (Bool): Set if the object is selectable in the 3d view
  • ViewSelectionStyle (Enumeration): Set the object selection style

Data

  • DataPlacement (Placement):
  • DataProxy (PythonObject):
  • DataShape (Part::PropertyPartShape):
  • DataVisibility (Bool):

Base

  • Data (Hidden)ExpressionEngine (ExpressionEngine): Property expressions
  • DataLabel (String): User name of the object (UTF8)
  • Data (Hidden)Label2 (String): User description of the object (UTF8)

Component

  • DataAdditions (LinkList): Other shapes that are appended to this object
  • DataAxis (Link): An optional axis or axis system on which this object should be duplicated
  • DataBase (Link): The base object this component is built upon
  • DataCloneOf (Link): The object this component is cloning
  • DataHiRes (Link): An optional higher-resolution mesh or shape for this object
  • DataHorizontalArea (Area): The area of the projection of this object onto the XY plane
  • DataMaterial (Link): A material for this object
  • DataMoveBase (Bool): Specifies if moving this object moves its base instead
  • DataMoveWithHost (Bool): Specifies if this object must move together when its host is moved
  • DataPerimeterLength (Length): The perimeter length of the horizontal area
  • DataStandardCode (String): An optional standard (OmniClass, etc...) code for this component
  • DataSubtractions (LinkList): Other shapes that are subtracted from this object
  • DataVerticalArea (Area): The area of all vertical faces of this object

IFC

  • DataIfcData (Map): IFC data
  • DataIfcProperties (Map): IFC properties of this object
  • DataIfcType (Enumeration): The type of this object

IFC Attributes

  • DataDescription (String): Description of IFC attributes are not yet implemented
  • DataGlobalId (String): Description of IFC attributes are not yet implemented
  • DataObjectType (String): Description of IFC attributes are not yet implemented
  • DataPredefinedType (Enumeration): Description of IFC attributes are not yet implemented
  • DataTag (String): Description of IFC attributes are not yet implemented

Structure

  • DataFaceMaker (Enumeration): The facemaker type to use to build the profile of this object
  • DataHeight (Length): The height or extrusion depth of this element. Keep 0 for automatic
  • DataLength (Length): The length of this element, if not based on a profile
  • DataNodes (VectorList): The structural nodes of this element
  • DataNodesOffset (Distance): Offset distance between the centerline and the nodes line
  • DataNormal (Vector): The normal extrusion direction of this object (keep (0,0,0) for automatic normal)
  • DataProfile (String): A description of the standard profile this element is based upon
  • DataTool (Link): An optional extrusion path for this element
  • DataWidth (Length): The width of this element, if not based on a profile

Script

#! python
# -*- coding: utf-8 -*-
# (c) 2021 <Evgeniy> LG
from FreeCAD import Qt

def print_obj_properties(obj,typ):
   prop={}
   i=1
   for pr in obj.PropertiesList:
      tp = obj.getTypeIdOfProperty(pr) or ""
      atr = obj.getTypeOfProperty(pr) or ("")
      # Wiki template supports only Hidden type of property. But it can be as: Hidden,Output,Readonly etc...
      if atr != "" and atr[0] == "Hidden":
         atr = "|"+atr[0]
      else:
         atr = ""      
      prop[str(i)] = pr,obj.getGroupOfProperty(pr),tp.replace("App::Property",""),obj.getDocumentationOfProperty(pr),atr
      i+=1
   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"+"{{TitleProperty{"+title+"}}")
      print("\n"+"* {{Property"+typ+"{"+pr[1][0]+"{"+pr[1][2]+pr[1][4]+"}}: "+pr[1][3])

print("\n"+"==Properties==")
print("\n"+"===View===")
obj = Gui.activeDocument().ActiveObject
print_obj_properties(obj,"View")
print("\n"+"===Data===")
obj = FreeCAD.activeDocument().ActiveObject
print_obj_properties(obj,"Data")

Links

The discussion on the forum: https://forum.freecadweb.org/viewtopic.php?f=21&t=61998