How to reference document/global properties?

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
naasking
Posts: 26
Joined: Tue Sep 28, 2021 12:28 pm

How to reference document/global properties?

Post by naasking »

I typically use spreadsheets to setup dimensions and some computed values, but I thought I'd give properties a try. I have a number of dimensions that I want shared across a few different parts in a project, so I thought I'd define them as properties on the document root:

Freecad props 2022-09-29 085430.png
Freecad props 2022-09-29 085430.png (27.45 KiB) Viewed 664 times

But I can't seem to figure out how to reference those properties when working on an actual part in part design, and the autocomplete doesn't seem to produce anything useful here:

FreeCAD props 2022-09-29 085512.png
FreeCAD props 2022-09-29 085512.png (33.77 KiB) Viewed 664 times

Obviously I can define these properties on the part itself and then reference them as DIMS_WallThickness, etc. but since many of these properties will be shared across multiple parts, I wanted to add them to an object that wasn't connected to any particular part in case that part gets removed as I iterate. What is the right pattern here if I want to do this with properties and not spreadsheets?

Code: Select all

OS: Windows 10 Version 2009
Word size of FreeCAD: 64-bit
Version: 0.20.1.29410 (Git)
Build type: Release
Branch: releases/FreeCAD-0-20
Hash: f5d13554ecc7a456fb6e970568ae5c74ba727563
Python 3.8.10, Qt 5.15.2, Coin 4.0.1, Vtk 8.2.0, OCC 7.6.3
Locale: English/Canada (en_CA)
Installed mods: 
  * fcgear 1.0.0
User avatar
Shalmeneser
Veteran
Posts: 5744
Joined: Wed Dec 23, 2020 12:04 am
Location: Fr

Re: How to reference document/global properties?

Post by Shalmeneser »

*SpreadSheet
* Master Sketch
* DynamicData Workbench
naasking
Posts: 26
Joined: Tue Sep 28, 2021 12:28 pm

Re: How to reference document/global properties?

Post by naasking »

Thanks, but a big reason I'm trying to avoid spreadsheet is that it becomes unbearably slow after I add about 20 entries. I mean it takes 5-10 seconds for every change to complete.
vm4dim
Posts: 97
Joined: Tue Nov 23, 2021 1:05 am

Re: How to reference document/global properties?

Post by vm4dim »

May use dedicated blank element (for example Group) in root as "Property Keeper"
chrisb
Veteran
Posts: 45735
Joined: Tue Mar 17, 2015 9:14 am

Re: How to reference document/global properties?

Post by chrisb »

vm4dim wrote: Fri Sep 30, 2022 10:24 pm May use dedicated blank element (for example Group) in root as "Property Keeper"
It may not be relevant, but such models are rather difficult to understand by others. As DynamicData does exactly this, I'd prefer that, because it clearly states what i is.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
drmacro
Veteran
Posts: 6540
Joined: Sun Mar 02, 2014 4:35 pm

Re: How to reference document/global properties?

Post by drmacro »

chrisb wrote: Fri Sep 30, 2022 10:58 pm
vm4dim wrote: Fri Sep 30, 2022 10:24 pm May use dedicated blank element (for example Group) in root as "Property Keeper"
It may not be relevant, but such models are rather difficult to understand by others. As DynamicData does exactly this, I'd prefer that, because it clearly states what i is.
I'll second what chrisb says. DD is way under appreciated and underutilized. It is lightweight compared to spreadsheets.
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
kisolre
Veteran
Posts: 4070
Joined: Wed Nov 21, 2018 1:13 pm

Re: How to reference document/global properties?

Post by kisolre »

Still the question remains: You can define properties. How do you access them?
chrisb
Veteran
Posts: 45735
Joined: Tue Mar 17, 2015 9:14 am

Re: How to reference document/global properties?

Post by chrisb »

kisolre wrote: Sat Oct 01, 2022 10:15 pm can define properties. How do you access them?
You can use them in Expressions.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
kisolre
Veteran
Posts: 4070
Joined: Wed Nov 21, 2018 1:13 pm

Re: How to reference document/global properties?

Post by kisolre »

chrisb wrote: Sat Oct 01, 2022 10:16 pm You can use them in Expressions.
We all know that :) But how? In the wiki page under "Document-wide global variables" there is a mention that there are no such variables. But those are clearly such, they can be created, modified, deleted, ... The problem is how to access them?
You can reference an object by its DataName or by its DataLabel.
What are those for the document itself? What to put between the << >>?
chrisb
Veteran
Posts: 45735
Joined: Tue Mar 17, 2015 9:14 am

Re: How to reference document/global properties?

Post by chrisb »

kisolre wrote: Sat Oct 01, 2022 10:15 pm You can define properties. How do you access them?
It seems I don't understand the question. The DynamicData documentation shows how to access the dd values.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Post Reply