app:: property link meaning?

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
ebrahim raeyat
Posts: 621
Joined: Sun Sep 09, 2018 7:00 pm
Location: Iran
Contact:

app:: property link meaning?

Post by ebrahim raeyat »

I develop punch software and convert it to "punch" object. I want to add punch faces to punch object as a property, but i don't know what kind of property i must to use for it. my faces are type of "Part.Face"

this is output error:

Code: Select all

AttributeError: Attribute (Name: facess) error: 'type in list must be 'DocumentObject', not Part.Face'
what means this properties ?!! i searched about those, it seems those are magical !!

App::PropertyLink
App::PropertyLinkChild
App::PropertyLinkGlobal
App::PropertyLinkSub
App::PropertyLinkSubChild
App::PropertyLinkSubGlobal
App::PropertyLinkList
App::PropertyLinkListChild
App::PropertyLinkListGlobal
App::PropertyLinkSubList
App::PropertyLinkSubListChild
App::PropertyLinkSubListGlobal

when the program load, i able to add faces to punch object by click on faces property and select them. thanks
User avatar
ebrahim raeyat
Posts: 621
Joined: Sun Sep 09, 2018 7:00 pm
Location: Iran
Contact:

Re: app:: property link meaning?

Post by ebrahim raeyat »

i can add those by this code, but this way when i want to use them, i must to obtain them by name from the ActiveDocument. i want to know is there an easier way to do this?

Code: Select all

faces = []
for f in intersection_faces:
    face = App.ActiveDocument.addObject("Part::Feature", "face")
    face.Shape = f
    faces.append(face.Name)
punch.faces = faces
when i want to use them:

Code: Select all

for face_name in obj.faces:
    f = FreeCAD.ActiveDocument.getObject(face_name)
intersection_faces are type of Part.Face
User avatar
ebrahim raeyat
Posts: 621
Joined: Sun Sep 09, 2018 7:00 pm
Location: Iran
Contact:

Re: app:: property link meaning?

Post by ebrahim raeyat »

This is related post:

https://forum.freecadweb.org/viewtopic.php?f=24&t=31813


punch.jpg
punch.jpg (24.73 KiB) Viewed 1994 times
User avatar
Chris_G
Veteran
Posts: 2596
Joined: Tue Dec 31, 2013 4:10 pm
Location: France
Contact:

Re: app:: property link meaning?

Post by Chris_G »

ebrahim raeyat wrote: Tue Jun 25, 2019 7:18 pm what means this properties ?!! i searched about those, it seems those are magical !!

App::PropertyLink
App::PropertyLinkChild
App::PropertyLinkGlobal
App::PropertyLinkSub
App::PropertyLinkSubChild
App::PropertyLinkSubGlobal
App::PropertyLinkList
App::PropertyLinkListChild
App::PropertyLinkListGlobal
App::PropertyLinkSubList
App::PropertyLinkSubListChild
App::PropertyLinkSubListGlobal

when the program load, i able to add faces to punch object by click on faces property and select them. thanks
I didn't know there was so many Link properties.
From what I know, if you want your featurepython object to link to subshapes (vertex, edge, face) of other objects, you have the following options :

- App::PropertyLinkSub links to a single subshape of a document object :

Code: Select all

featurepython.linkProperty = [AnotherObject, "Face1"]
- App::PropertyLinkSubList links to a list of subshapes :

Code: Select all

featurepython.linkProperty = [(AnotherObject1, ("Face1", "Edge3")), (AnotherObject2, ("Face5", ))]
User avatar
ebrahim raeyat
Posts: 621
Joined: Sun Sep 09, 2018 7:00 pm
Location: Iran
Contact:

Re: app:: property link meaning?

Post by ebrahim raeyat »

Excuse me i am late, thank you so much.
Cyril
Posts: 133
Joined: Wed Aug 23, 2017 5:04 pm
Location: Geneva (Switzerland)
Contact:

Re: app:: property link meaning?

Post by Cyril »

I know that your post is pretty old but I find the question useful.

PropertyLink is pretty understandable but for subtypes I found an explanation in source code here :
/**
* @brief Defines different scopes for which a link can be valid
* The scopes defined in this enum describe the different possibilities of where a link can point to.
* Local: links are valid only within the same GeoFeatureGroup as the linkowner is in or in none.
* Child: links are valid within the same or any sub GeoFeatureGroup
* Global: all possible links are valid
* Hidden: links are not included in dependency calculation
*/
I blog about HVAC / BIM / Energy : pythoncvc.net. If you like you can follow the RSS feed.
User avatar
ebrahim raeyat
Posts: 621
Joined: Sun Sep 09, 2018 7:00 pm
Location: Iran
Contact:

Re: app:: property link meaning?

Post by ebrahim raeyat »

@Cyril, very thanks.
paullee
Veteran
Posts: 5118
Joined: Wed May 04, 2016 3:58 pm

Re: app:: property link meaning?

Post by paullee »

Thanks Chris_G and Cyril.

I drop into App::PropertyLinkGlobal when I have a look at Draft.py _PathArray.

It seem some properties are not in the Scripted Object wiki ?
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: app:: property link meaning?

Post by vocx »

paullee wrote: Tue May 12, 2020 6:55 pm ...
It seem some properties are not in the Scripted Object wiki ?
Obviously. There are many outdated pages in the wiki, and scripted objects is one of them.

Personally, I would place the properties in the property page, and link that one where is needed.

In the source code, properties are located in various src/App/Property* files.

Code: Select all

#include "Property.h"
#include "PropertyContainer.h"
#include "PropertyUnits.h"
#include "PropertyFile.h"
#include "PropertyLinks.h"
#include "PropertyPythonObject.h"
#include "PropertyExpressionEngine.h"
They are initialized in src/App/Application.cpp.
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
Post Reply