| Description |
|---|
| This macro automatically creates aliases in a two-dimensional table using the names of the rows and columns. A second function can create a link between a cell and a property value in an object. |
| Author |
| 2cv001 |
| Download |
| Links |
| Macros recipes How to install macros How to customize toolbars |
| Macro Version |
| beta |
| Date last modified |
| 2024-02-22 |
| FreeCAD Version(s) |
| All |
| Default shortcut |
| None |
| See also |
| None |
Temporary code for external macro link. Do not use this code. This code is used exclusively by Addon Manager. Link for optional manual installation: Macro
# This code is copied instead of the original macro code
# to guide the user to the online download page.
# Use it if the code of the macro is larger than 64 KB and cannot be included in the wiki
# or if the RAW code URL is somewhere else in the wiki.
from PySide import QtGui, QtCore
diag = QtGui.QMessageBox(QtGui.QMessageBox.Information,
"Information",
"This macro must be downloaded from this link\n"
"\n"
"https://raw.githubusercontent.com/2cv001/Alias_For_Table_For_Object.FCMacro/refs/heads/main/Alias_For_Table_For_Object.FCMacro" + "\n"
"\n"
"Quit this window to access the download page")
diag.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
diag.setWindowModality(QtCore.Qt.ApplicationModal)
diag.exec_()
import webbrowser
webbrowser.open("https://raw.githubusercontent.com/2cv001/Alias_For_Table_For_Object.FCMacro/refs/heads/main/Alias_For_Table_For_Object.FCMacro")
This macro automatically creates aliases in a two-dimensional table using the names of the rows and columns. A second function can create a link between a cell and a property value of an object. To be able to use this function, you just have to place the name of the relevant object in the column and the name of the property in the row.
The syntax for the alias created by the macro is: LabelObject_Property.
The macro can also automatically fill property values of objects (such as body, sketch, etc.) based on these aliases.
Fill a spreadsheet with a column containing object labels (Body, sketch, Pad, ...) and a row corresponding to properties. In the code you will find the correspondence between the properties and what to put in this row. See dico= below.
For example, use posy for property Placement.Base.y.
Select the cells in the table with the object labels column and properties row, and then run the Macro and check the first option:
The macro will create aliases with this syntax: LabelObject_Property. For instance: BodyRect_posy.
Part of the dico (check the code of the macro for the full dico):
dico={
"posx" : "Placement.Base.x",
"posy" : "Placement.Base.y",
"posz" : "Placement.Base.z",
"posX" : "Placement.Base.x",
"posY" : "Placement.Base.y",
"posZ" : "Placement.Base.z",
"angle": "Placement.Rotation.Angle",
"ang" : "Placement.Rotation.Angle",
"axisx": "Placement.Rotation.Axis.x",
"axisy": "Placement.Rotation.Axis.y",
"axisz": "Placement.Rotation.Axis.z",
"axeX" : "Placement.Rotation.Axis.x",
"axeY" : "Placement.Rotation.Axis.y",
"axeZ" : "Placement.Rotation.Axis.z",
"attachementX" : "AttachmentOffset.Base.x",
"attachementY" : "AttachmentOffset.Base.y",
"attachementZ" : "AttachmentOffset.Base.z",
"attachementAngle" : "AttachmentOffset.Rotation.Angle",
"attachementAxisX" : "AttachmentOffset.Rotation.Axis.x",
"attachementAxisY" : "AttachmentOffset.Rotation.Axis.y",
"attachementAxisZ" : "AttachmentOffset.Rotation.Axis.z",
"Length" : "Length",
"Length2": "Length2",
"Radius" : "Radius",
"Height" : "Height",
"FirstAngle" : "FirstAngle",
"SecondAngle": "SecondAngle",
"Angle1" : "Angle1",
"Angle2" : "Angle2",
"Angle3" : "Angle3",
Select some cells in the table with values and aliases created previously. Run the macro and select the second option (Both options can be selected at the same time to chain them together.)
The macro will assign values to the properties via an expression referencing the alias of the cells. From now on, if you change a value in the table, the property value will change and everything will be recalculated.
Give a name to the constraint (here: Width) (Pay attention to the case.) Add a column with this constraint name in the properties row, and add a row with the label of the Sketch (here: Sketch). Run the macro.
This macro was developed based on an idea suggested by Esprit. Also, many thanks to him for the numerous ideas and tests he has carried out.
ver 25/02/2024 by 2cv001 Alias_For_Table_For_Object.FCMacro