app:: property link meaning?

Need help, or want to share a macro? Post here!
User avatar
ebrahim raeyat
Posts: 159
Joined: Sun Sep 09, 2018 7:00 pm
Location: Iran
Contact:

app:: property link meaning?

Postby ebrahim raeyat » Tue Jun 25, 2019 7:18 pm

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: 159
Joined: Sun Sep 09, 2018 7:00 pm
Location: Iran
Contact:

Re: app:: property link meaning?

Postby ebrahim raeyat » Tue Jun 25, 2019 7:18 pm

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: 159
Joined: Sun Sep 09, 2018 7:00 pm
Location: Iran
Contact:

Re: app:: property link meaning?

Postby ebrahim raeyat » Tue Jun 25, 2019 7:20 pm

This is related post:

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


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

Re: app:: property link meaning?

Postby Chris_G » Tue Jun 25, 2019 8:37 pm

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: 159
Joined: Sun Sep 09, 2018 7:00 pm
Location: Iran
Contact:

Re: app:: property link meaning?

Postby ebrahim raeyat » Wed Aug 14, 2019 6:11 pm

Excuse me i am late, thank you so much.