Reference to a list of edges in parametric feature
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Reference to a list of edges in parametric feature
Dear experts,
I would like to create a parametric feature in python. I followed the documentation in http://www.freecadweb.org/wiki/index.ph ... ed_objects and the examples in the mentioned subdirectory "TemplatePyMod". So far I understood how to create a solid body and use numeric parameters for that.
Now I would like pick some edges of a solid and do some processing with them. I'm not sure which is the right Property for that. Is it "App::PropertyLinkSubList"? If I add that to my feature, it does not appear in the properties table and I cannot edit it. I searched the sources for an appropriate example, but didn't find one.
Can someone give me a hint how to proceed? Any suggestions are welcome.
Regards, Hannes
I would like to create a parametric feature in python. I followed the documentation in http://www.freecadweb.org/wiki/index.ph ... ed_objects and the examples in the mentioned subdirectory "TemplatePyMod". So far I understood how to create a solid body and use numeric parameters for that.
Now I would like pick some edges of a solid and do some processing with them. I'm not sure which is the right Property for that. Is it "App::PropertyLinkSubList"? If I add that to my feature, it does not appear in the properties table and I cannot edit it. I searched the sources for an appropriate example, but didn't find one.
Can someone give me a hint how to proceed? Any suggestions are welcome.
Regards, Hannes
Re: Reference to a list of edges in parametric feature
You may have a look at macro recipes: http://www.freecadweb.org/wiki/index.ph ... os_recipes
There are some macros, which works with user selected objects, for example Macro_FCInfo.
Ulrich
There are some macros, which works with user selected objects, for example Macro_FCInfo.
Ulrich
Re: Reference to a list of edges in parametric feature
Dear Ulrich,
thanks for your hint. I must add that I already managed to do extract the edges in the way of a macro (using the getSelectionEx function).
But the code is executed only once and if I change the dimensions of the base object, the result of my processing is not updated, it remains static. Now I wanted to extend my application into a parametric feature, i.e. I wanted to select the edges once, store the reference somehow and get my feature updated every time I change the base feature.
Meanwhile I found something similar in the "PathArray" feature of the "Draft" workbench. I adapted it to my case and it works. But the selection of the edges there is made before the new feature is created and I do not see a way to change the selection after my feature is created. Is it possible that I miss something?
Regards, Hannes
thanks for your hint. I must add that I already managed to do extract the edges in the way of a macro (using the getSelectionEx function).
But the code is executed only once and if I change the dimensions of the base object, the result of my processing is not updated, it remains static. Now I wanted to extend my application into a parametric feature, i.e. I wanted to select the edges once, store the reference somehow and get my feature updated every time I change the base feature.
Meanwhile I found something similar in the "PathArray" feature of the "Draft" workbench. I adapted it to my case and it works. But the selection of the edges there is made before the new feature is created and I do not see a way to change the selection after my feature is created. Is it possible that I miss something?
Regards, Hannes
Re: Reference to a list of edges in parametric feature
Dear Hannes,
I have to admit, that I am not an experienced programmer. So it may point to something wrong. My one experiment with FeaturePython showed me, that this is a complicate matter.
I had a look to the class Octahedron in FeaturePython.py. There is a reference to a shape stored as property. In updateData you may need to write code to make a new processing. I think you need some extra gui-code, that make changes to this property based on the getSelectionEx function. And I do not remember any function in FreeCAD, that lets you change references to objects on the fly.
Here is some help from the real experts needed. How you can get a button for example in the Data-properties for a call to your new selection gui. If it not exists, you can make a feature-request on the Mantis-bug-tracker.
So unfortunately I can give no real help.
Regards, Ulrich
I have to admit, that I am not an experienced programmer. So it may point to something wrong. My one experiment with FeaturePython showed me, that this is a complicate matter.
I had a look to the class Octahedron in FeaturePython.py. There is a reference to a shape stored as property. In updateData you may need to write code to make a new processing. I think you need some extra gui-code, that make changes to this property based on the getSelectionEx function. And I do not remember any function in FreeCAD, that lets you change references to objects on the fly.
Here is some help from the real experts needed. How you can get a button for example in the Data-properties for a call to your new selection gui. If it not exists, you can make a feature-request on the Mantis-bug-tracker.
So unfortunately I can give no real help.
Regards, Ulrich
Re: Reference to a list of edges in parametric feature
The sub components of a shape get a name (from oce/occ), this name is numbered in a at least partly random manor. Any change to the solid can mean that the names of the edges etc. are changed in undefinable way.
There has been lots of talk and coding regarding this issue, I think Jan has done it all, at least most of it, its called "topological naming" or something like that. It will be in future versions of FreeCAD, possibly the next version.
I suggest you search for it in these forums. I think you will find that this is a limiting factor for what you are trying to do, if I am understanding correctly what you are trying to do.
Jim
There has been lots of talk and coding regarding this issue, I think Jan has done it all, at least most of it, its called "topological naming" or something like that. It will be in future versions of FreeCAD, possibly the next version.
I suggest you search for it in these forums. I think you will find that this is a limiting factor for what you are trying to do, if I am understanding correctly what you are trying to do.
Jim
Re: Reference to a list of edges in parametric feature
This is because we do not yet have implemented an editor for this property type.I'm not sure which is the right Property for that. Is it "App::PropertyLinkSubList"? If I add that to my feature, it does not appear in the properties table and I cannot edit it.
- wandererfan
- Veteran
- Posts: 6326
- Joined: Tue Nov 06, 2012 5:42 pm
- Contact:
Re: Reference to a list of edges in parametric feature
Probably something to do with the onChanged method. PathArray only recreates itself for some properties.hkroeger wrote:Meanwhile I found something similar in the "PathArray" feature of the "Draft" workbench. I adapted it to my case and it works. But the selection of the edges there is made before the new feature is created and I do not see a way to change the selection after my feature is created. Is it possible that I miss something?
Regards, Hannes
Code: Select all
def onChanged(self,obj,prop):
if prop in ["Count","Xlate","Align"]:
self.createGeometry(obj)
wf
- wandererfan
- Veteran
- Posts: 6326
- Joined: Tue Nov 06, 2012 5:42 pm
- Contact:
Re: Reference to a list of edges in parametric feature
Sorry, that's not it. Changing Base, Path or PathSubs properties rebuilds the PathArray even though they are not in the onChanged list.wandererfan wrote:Probably something to do with the onChanged method. PathArray only recreates itself for some properties.
Re: Reference to a list of edges in parametric feature
Dear wmayer,
ok, I understand. The same seems to apply for the PropertyLink (link to another shape, right?). If I use it, it is listed in the property table and a link "Edit..." is shown, but if I click on it, a disappointing message appears
Is that just because the editor was not necessary so far, or is there some conceptual difficulty with its implementation?
@jmaustpc: I'm aware of the topological naming problem and its implications, but the same should affect e.g. the fillet feature. But I see it is solved there somehow.
Indeed, I was thinking of implementing something similar like the fillet feature: selecting a list of edges and use them as inputs. In the fillet feature, there seems to be some extra gui code involved (haven't look in detail at it yet). Could something similar be made purely in python? Is there an example somewhere?
Thanks and regards, Hannes
ok, I understand. The same seems to apply for the PropertyLink (link to another shape, right?). If I use it, it is listed in the property table and a link "Edit..." is shown, but if I click on it, a disappointing message appears
Is that just because the editor was not necessary so far, or is there some conceptual difficulty with its implementation?
@jmaustpc: I'm aware of the topological naming problem and its implications, but the same should affect e.g. the fillet feature. But I see it is solved there somehow.
Indeed, I was thinking of implementing something similar like the fillet feature: selecting a list of edges and use them as inputs. In the fillet feature, there seems to be some extra gui code involved (haven't look in detail at it yet). Could something similar be made purely in python? Is there an example somewhere?
Thanks and regards, Hannes
Re: Reference to a list of edges in parametric feature
Yes, it's just lazinessIs that just because the editor was not necessary so far, or is there some conceptual difficulty with its implementation?