Manipulating InList and OutList
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Manipulating InList and OutList
I have two FeaturePython classes: Box and BoxDimensions.
I'd like to make BoxDimensions part of Box's InList. I've search high and low for a method of doing this in the Wiki, API docs, and forums, and have only found ways to read and iterate InList/OutList, but not how to write/insert/append to these lists.
The intuitive way, obj.InList.append(sobj) doesn't work.
Since I'm now delving into application code to try to find an answer, I figured I should ask in here to try and save some time.
Does anyone know what the appropriate API calls to modify InList and OutList are?
I'd like to make BoxDimensions part of Box's InList. I've search high and low for a method of doing this in the Wiki, API docs, and forums, and have only found ways to read and iterate InList/OutList, but not how to write/insert/append to these lists.
The intuitive way, obj.InList.append(sobj) doesn't work.
Since I'm now delving into application code to try to find an answer, I figured I should ask in here to try and save some time.
Does anyone know what the appropriate API calls to modify InList and OutList are?
Re: Manipulating InList and OutList
I think all the *List properties need to be set "as a whole".
append(), extend(), ... don't work directly :
append(), extend(), ... don't work directly :
Code: Select all
tmpList = myObj.InList
tmpList.append(item)
myObj.InList = tmpList
Re: Manipulating InList and OutList
They are stored internally as tuples?Chris_G wrote: ↑Thu Mar 11, 2021 8:18 am I think all the *List properties need to be set "as a whole".
append(), extend(), ... don't work directly :Code: Select all
tmpList = myObj.InList tmpList.append(item) myObj.InList = tmpList
Regards
Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
Re: Manipulating InList and OutList
I get an error trying to set the list directly:
Code: Select all
>>> il = obj.InList
>>> il.append(sobj)
>>> obj.InList = il
Traceback (most recent call last):
File "<input>", line 1, in <module>
AttributeError: Attribute 'InList' of object 'DocumentObject' is read-only
Re: Manipulating InList and OutList
You cannot directly manipulate the InList and OutList of a feature because this is a collection of all link properties used by the features and you can't know which link properties to modify in the end.
The OutList gives you the features a given feature depends on and it must have a link property of a sub-type of PropertyLinkBase. The InList gives you the features that depend on the given feature.
So, you can only indirectly modify the InList/OutList by manipulating the corresponding link properties of the features.
The OutList gives you the features a given feature depends on and it must have a link property of a sub-type of PropertyLinkBase. The InList gives you the features that depend on the given feature.
So, you can only indirectly modify the InList/OutList by manipulating the corresponding link properties of the features.
Re: Manipulating InList and OutList
Hello wmayer, Thank you for your prompt reply.
I was also looking at the link properties and wasn't sure what role they played in the dependency graph. I will experiment with these a bit more. Where's the best place to find documentation for them? I find the wiki and forums to be a bit sparse at best, and these seem like core features...
Would you allow a relative newcomer like me to help update the documentation or contribute a mini-tutorial once I've uncovered a solution?
I was also looking at the link properties and wasn't sure what role they played in the dependency graph. I will experiment with these a bit more. Where's the best place to find documentation for them? I find the wiki and forums to be a bit sparse at best, and these seem like core features...
Would you allow a relative newcomer like me to help update the documentation or contribute a mini-tutorial once I've uncovered a solution?
Re: Manipulating InList and OutList
Oops, sorry for the mis-information.
I have never used InList / OutList specifically and thought they were simply behaving like other *List properties.
I have never used InList / OutList specifically and thought they were simply behaving like other *List properties.
Re: Manipulating InList and OutList
No problem, it was only curiosity (not the lander on Mars).
Regards
Carlo D.
Regards
Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
Re: Manipulating InList and OutList
Maybe a real case will be useful.Hermit wrote: ↑Thu Mar 11, 2021 9:14 am Hello wmayer, Thank you for your prompt reply.
I was also looking at the link properties and wasn't sure what role they played in the dependency graph. I will experiment with these a bit more. Where's the best place to find documentation for them? I find the wiki and forums to be a bit sparse at best, and these seem like core features...
Would you allow a relative newcomer like me to help update the documentation or contribute a mini-tutorial once I've uncovered a solution?
Some code with one can work on to test some solutions, in many other "help forums" they ask for a MWE (Minimal Working Example) or to be more precise:
A minimal unworking example and some information about:
1) what you intend to achieve
2) how the actual solution is wrong or subotpimal
3) what you expect the program will do
In this manner and with a MWE someone could test and maybe find a solution
This post is not to criticize, only to help to find a solution.
Regards
Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
Re: Manipulating InList and OutList
My original post answers these three points.
I have two FeaturePython classes, Box and BoxDimension. I would like BoxDimension's InList to contain a Box object. Similarly, I would like Box's OutList to contain the corresponding BoxDimension object.
Maybe I had the semantics for InList and OutList reversed in my OP, but this entirely describes the conditions that I am trying to achieve.
I have two FeaturePython classes, Box and BoxDimension. I would like BoxDimension's InList to contain a Box object. Similarly, I would like Box's OutList to contain the corresponding BoxDimension object.
Maybe I had the semantics for InList and OutList reversed in my OP, but this entirely describes the conditions that I am trying to achieve.