App::PropertyLinkList cannot append / pop / clear etc…

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
Cyril
Posts: 133
Joined: Wed Aug 23, 2017 5:04 pm
Location: Geneva (Switzerland)
Contact:

App::PropertyLinkList cannot append / pop / clear etc…

Post by Cyril »

Hi,

I wonder why it is not possible possible to use App::PropertyLinkList as a standard list.

Code: Select all

object_1.property.append(object_2)
=> No error but object_2 is not appended

Code: Select all

object_1.property.pop()
=> No error and it return an object but this object is not removed from the list

Code: Select all

object_1.property.clear()
=> No error but it does nothing

Etc…

Apparently when we use a standard list method it affects a copy of the list and not the list stored in the property.
  • Is there any reason that we cannot directly modify the list ?
  • If not. Would it be easy and desirable to change this behavior
I blog about HVAC / BIM / Energy : pythoncvc.net. If you like you can follow the RSS feed.
User avatar
wandererfan
Veteran
Posts: 6324
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: App::PropertyLinkList cannot append / pop / clear etc…

Post by wandererfan »

Cyril wrote: Fri Oct 04, 2019 3:35 pm
  • Is there any reason that we cannot directly modify the list ?
  • If not. Would it be easy and desirable to change this behavior
In C++ we must do it more or less like this:

Code: Select all

myList = App.ActiveDocument.myObject.LinkListProperty.copy()
myList.append(anotherLink);
App.ActiveDocument.myObject.LinkListProperty = myList
I believe Python works in a similar fashion.

PropertyLinkList isn't really a list behind the scenes - there's all sorts of background activity.

So to actually answer the questions:
A) yes there is a reason - it isn't really a list
B) definitely not easy - would involve big changes to the Property system.
Cyril
Posts: 133
Joined: Wed Aug 23, 2017 5:04 pm
Location: Geneva (Switzerland)
Contact:

Re: App::PropertyLinkList cannot append / pop / clear etc…

Post by Cyril »

Too bad. Thanks for your answer !
I blog about HVAC / BIM / Energy : pythoncvc.net. If you like you can follow the RSS feed.
Post Reply