Macro Alias For Table For Object: Difference between revisions

From FreeCAD Documentation
Line 21: Line 21:


== Description ==
== Description ==
The macro automatically creates aliases in a two-dimensional table using the names of the rows and columns.
The macro automatically creates alias in a two-dimensional table using the names of the rows and columns.
<br>To use the "Table to Object" function, place the name of the relevant object in the column and the name of the property in the row.<br>
<br>To be able to use the "Table to Object" function, place the name of the relevant object in the column and the name of the property in the row.<br>
<br>
<br>
The syntax for the alias is: "LabelObject_Property"<br>
The syntax for the alias create by the macro is : "LabelObject_Property"<br>
[[File:20240220.gif]]
[[File:20240220.gif]]
<br>
<br>

The macro can also automatically create the properties of objects (such as body, sketch, etc.) based on these aliases.<br>
The macro can also automatically fill a property value of objects (such as body, sketch, etc.), based on these aliases.<br>


[[File:20240220-01.gif]]
[[File:20240220-01.gif]]

Revision as of 15:10, 21 February 2024


Generic macro icon. Create your personal icon with the same name of the macro Macro Alias For Table For Object

Description
The macro automatically creates aliases in a two-dimensional table using the names of the rows and columns.


To use the "Table to Object" function, place the name of the relevant object in the column and the name of the property in the row.

The syntax for the alias is: "LabelObject_Property"

The macro can also automatically create the properties of objects (such as body, sketch, etc.) based on these aliases.


Macro version: béta
Last modified: 2024-02-20
FreeCAD version: All
Download: [https:......svg ToolBar icon]
Author: 2cv001

Author
2cv001
Download
[https:......svg ToolBar icon]
Links
Macro Version
béta
Date last modified
2024-02-20
FreeCAD Version(s)
All
Default shortcut
None
See also
None


Description

The macro automatically creates alias in a two-dimensional table using the names of the rows and columns.
To be able to use the "Table to Object" function, place the name of the relevant object in the column and the name of the property in the row.

The syntax for the alias create by the macro is : "LabelObject_Property"

The macro can also automatically fill a property value of objects (such as body, sketch, etc.), based on these aliases.

Usage

Automatic Alias creation

Fill a spreadsheet with a column containing object labels (Body, sketch,Pad, ....) and a row corresponding to properties. You will find in the code the correspondence between the properties and what to put in this line. (at dico={........
Here for example, use "posy" for property "Placement.Base.y"

Sélect cells in the table with the obects labels column and properties line and then, run the Macro and check the first option :

The macro will create alias with this syntaxe : "LabelObject_Property"
for instance : BodyRect_posy

part of the 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",

Automatic Values in properties

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 referring to 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.



Examples of uses

Pad



Constraintes in a Sketch

Give a name to the constraint (here : Width ) (Pay attention to the case.) Add a column with this constraint name at the properties line, and add a line with the label of the Sketch (here : Sketch). Run the macro