Macros for generation properties list of active object

Discussions about the wiki documentation of FreeCAD and its translation.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
Roy_043
Veteran
Posts: 8409
Joined: Thu Dec 27, 2018 12:28 pm

Re: Macros for generation properties list of active object

Post by Roy_043 »

Hmm...

Code: Select all

>>> obj.getAllDerivedFrom()
['Part::FeaturePython']
Seems useful to me... (obj is Draft_PolarArray).

Or:

Code: Select all

>>> box.isDerivedFrom("Part::Primitive")
True
User avatar
Evgeniy
Posts: 477
Joined: Thu Jul 15, 2021 6:10 pm

Re: Macros for generation properties list of active object

Post by Evgeniy »

Roy_043 wrote: Thu Sep 09, 2021 4:47 pm Hmm...

Code: Select all

>>> obj.getAllDerivedFrom()
['Part::FeaturePython']
Seems useful to me... (obj is Draft_PolarArray).

Or:

Code: Select all

>>> box.isDerivedFrom("Part::Primitive")
True
But if create Part::Sphere in Part worckbench. Select it and run. Method is return:

Code: Select all

sel = FreeCADGui.Selection.getSelection()
obj = FreeCAD.ActiveDocument.getObject(sel[0].Name)
obj.getAllDerivedFrom()
>>> ['Part::Sphere']
This function looks as "Captain Obvious"

if create Strucure in Arch worckbench its return:

Code: Select all

sel = FreeCADGui.Selection.getSelection()
obj = FreeCAD.ActiveDocument.getObject(sel[0].Name)
obj.getAllDerivedFrom()
>>> ['Part::FeaturePython']
But then from where do the IFC properties comes? That are inherited from some unnamed Python class ...
This method does not explain many things...
User avatar
Roy_043
Veteran
Posts: 8409
Joined: Thu Dec 27, 2018 12:28 pm

Re: Macros for generation properties list of active object

Post by Roy_043 »

Yes, I agree it is confusing.
User avatar
Roy_043
Veteran
Posts: 8409
Joined: Thu Dec 27, 2018 12:28 pm

Re: Macros for generation properties list of active object

Post by Roy_043 »

Note that the solution adopted in Macro_Wiki_Object_Properties_List_Generator is problematic. F.e. a Draft_Text does not inherit the Placement property, but your code will identify it as such.
User avatar
Evgeniy
Posts: 477
Joined: Thu Jul 15, 2021 6:10 pm

Re: Macros for generation properties list of active object

Post by Evgeniy »

Roy_043 wrote: Fri Sep 10, 2021 9:30 am Note that the solution adopted in Macro_Wiki_Object_Properties_List_Generator is problematic. F.e. a Draft_Text does not inherit the Placement property, but your code will identify it as such.
Hi,

im update sorce code in https://wiki.freecadweb.org/Macro_Wiki_ ... _Generator

Can you show me report of selected object for i understand what you mean?
User avatar
Roy_043
Veteran
Posts: 8409
Joined: Thu Dec 27, 2018 12:28 pm

Re: Macros for generation properties list of active object

Post by Roy_043 »

Placement inherited from classPartDesign::Body is clearly wrong. A Draft_Text does not inherit anything from PartDesign::Body and, as already mentioned, the Placement property is not inherited:

https://github.com/FreeCAD/FreeCAD/blob ... ext.py#L54

Code: Select all

10:28:25  
==Properties==
10:28:25  
===View===
10:28:25  
<!--
DisplayMode inherited from classPartDesign::Body
LineColor inherited from classPartDesign::Body
LineWidth inherited from classPartDesign::Body
OnTopWhenSelected inherited from classPartDesign::Body
SelectionStyle inherited from classPartDesign::Body
ShowInTree inherited from classPartDesign::Body
Visibility inherited from classPartDesign::Body
-->
10:28:25  
* {{PropertyView|Proxy|PythonObject}}: 
10:28:25  
{{TitleProperty|Annotation}}
10:28:25  
* {{PropertyView|AnnotationStyle|Enumeration}}: Annotation style to apply to this object.
When using a saved style some of the view properties will become read-only;
they will only be editable by changing the style through the 'Annotation style editor' tool.
10:28:25  
* {{PropertyView|ScaleMultiplier|Float}}: General scaling factor that affects the annotation consistently
because it scales the text, and the line decorations, if any,
in the same proportion.
10:28:25  
{{TitleProperty|Text}}
10:28:25  
* {{PropertyView|FontName|Font}}: The font of the text
10:28:25  
* {{PropertyView|FontSize|Length}}: The size of the text
10:28:25  
* {{PropertyView|Justification|Enumeration}}: The vertical alignment of the text
10:28:25  
* {{PropertyView|LineSpacing|Float}}: Line spacing (relative to font size)
10:28:25  
* {{PropertyView|TextColor|Color}}: Text color
10:28:25  
===Data===
10:28:25  
<!--
ExpressionEngine inherited from classPartDesign::Body
Label inherited from classPartDesign::Body
Label2 inherited from classPartDesign::Body
Placement inherited from classPartDesign::Body
Visibility inherited from classPartDesign::Body
-->
10:28:25  
* {{PropertyData|Proxy|PythonObject}}: 
10:28:25  
{{TitleProperty|Base}}
10:28:25  
* {{PropertyData|Text|StringList}}: The text displayed by this object.
It is a list of strings; each element in the list will be displayed in its own line.
User avatar
Evgeniy
Posts: 477
Joined: Thu Jul 15, 2021 6:10 pm

Re: Macros for generation properties list of active object

Post by Evgeniy »

As far as I know, FreeCAD does not currently have tools to determine whether a property is inherited from or added.
Making a list manually is not a grateful thing. Since everything is very difficult to track.
The property can also be added, and then it is not inherited, but it can be used many times.
I think the algorithm in the form in which it is performs most of the task.
User avatar
Roy_043
Veteran
Posts: 8409
Joined: Thu Dec 27, 2018 12:28 pm

Re: Macros for generation properties list of active object

Post by Roy_043 »

Evgeniy wrote:Ping
You have created at least 4 pages and one template while experimenting with this. Some of them can be deleted I think.

The procedure involved has already been pointed out to you:
https://wiki.freecadweb.org/WikiPages#D ... _and_pages
User avatar
Evgeniy
Posts: 477
Joined: Thu Jul 15, 2021 6:10 pm

Re: Macros for generation properties list of active object

Post by Evgeniy »

Roy_043 wrote: Sun Sep 19, 2021 10:41 am You have created at least 4 pages and one template while experimenting with this. Some of them can be deleted I think.
What four pages are you talking about?
The template that was used for testing can be deleted.
Post Reply