how add custom properties to any object?

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
jtm2020hyo
Posts: 578
Joined: Wed Aug 12, 2020 1:24 am

how add custom properties to any object?

Post by jtm2020hyo »

Something like AutoCAD blocks and Attribute properties, how can I add custon properties any object and introduce expressions, and if possible introduce scripts?
chrisb
Posts: 37828
Joined: Tue Mar 17, 2015 9:14 am

Re: how add custom properties to any object?

Post by chrisb »

Don't know AutoCAD blocks.

Additional properties can be added, by right clicking in the Properties section and then "Show All". Then you can edit custom properties.

Expressions are possible, scripts are forbidden due to security risks.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
jtm2020hyo
Posts: 578
Joined: Wed Aug 12, 2020 1:24 am

Re: how add custom properties to any object?

Post by jtm2020hyo »

nice feature, but when I added my custom property appears nothing.


Image

chrisb wrote: Thu Jan 28, 2021 12:05 pm Expressions are possible, scripts are forbidden due to security risks.
how can I unlock the script inside properties?
hmk
Posts: 123
Joined: Tue Sep 29, 2020 1:19 pm
Location: Berlin, Germany

Re: how add custom properties to any object?

Post by hmk »

jtm2020hyo wrote: Thu Jan 28, 2021 12:20 pm nice feature, but when I added my custom property appears nothing.
It works for me. I created a group "Params" with names "Height" and "Diameter" for a Body. The group shows up at the very end.

Screenshot from 2021-02-02 13-33-34.png
Screenshot from 2021-02-02 13-33-34.png (68.46 KiB) Viewed 985 times
OS: PureOS (GNOME/gnome)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.23756 (Git) AppImage
Build type: Release
Branch: master
Hash: 9c6e9184930a52b165a0b7274e3a45d1006bfe67
Python version: 3.8.6
Qt version: 5.12.5
Coin version: 4.0.0
OCC version: 7.4.0
Locale: English/United States (en_US)
jtm2020hyo
Posts: 578
Joined: Wed Aug 12, 2020 1:24 am

Re: how add custom properties to any object?

Post by jtm2020hyo »

thanks for the answer, I noticed than is possible add properties, but not all properties.

a link to any documentation could be great, but I am more interested in add custom properties and add custom properties with scripts.


for example, in a Circle Draft Object, How can I calculate the perimeter? until I know it needs scripts.
hmk
Posts: 123
Joined: Tue Sep 29, 2020 1:19 pm
Location: Berlin, Germany

Re: how add custom properties to any object?

Post by hmk »

jtm2020hyo wrote: Tue Feb 02, 2021 2:49 pm for example, in a Circle Draft Object, How can I calculate the perimeter? until I know it needs scripts.
Have a careful look at the screenshot.

You have limited ability to "script" things with expressions. Most importantly, you have the ?:-Operator, which gives you basically If-Then-Else. I have only tried little examples so far. These expression can easily break, I believe.

Note: You have to pick the right return type: For first expression I did use String, for the second Float.

Have a look at this thread: https://forum.freecadweb.org/viewtopic.php?f=27&t=38974

Screenshot from 2021-02-02 18-56-10.png
Screenshot from 2021-02-02 18-56-10.png (122.99 KiB) Viewed 914 times
jtm2020hyo
Posts: 578
Joined: Wed Aug 12, 2020 1:24 am

Re: how add custom properties to any object?

Post by jtm2020hyo »

Look cool

... Just for be clear, then is not possible add a python script to properties right?
jtm2020hyo
Posts: 578
Joined: Wed Aug 12, 2020 1:24 am

Re: how add custom properties to any object?

Post by jtm2020hyo »

I find another method:

Image

look like in "Shape" Property has stored all values that we wish.

Image
chrisb
Posts: 37828
Joined: Tue Mar 17, 2015 9:14 am

Re: how add custom properties to any object?

Post by chrisb »

jtm2020hyo wrote: Wed Feb 03, 2021 7:48 am ... Just for be clear, then is not possible add a python script to properties right?
As mentioned above: arbitrary Python scripts are forbidden due to security risks.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
ifohancroft
Posts: 98
Joined: Fri May 31, 2019 11:25 pm
Location: Sofia, Bulgaria
Contact:

Re: how add custom properties to any object?

Post by ifohancroft »

Can you access custom properties of a parent object?

Like if I have a Sketch, inside of a Body inside of a Part, can I add a custom property to the Part then access that as a dimension constraint in the Sketch? How?
I like to make, break & modify stuff via a soldering iron, code or both. https://ifohancroft.com
Post Reply