Because I want to simplify my scripts and enable Autocompletion etc, I'd like to have an import module with all supported property and object types.
I know I can get the property Types from, for example a Body object with "body.supportedProperties()" and the supported object types from "document.supportedObjects()".
But that means I would have to create a document and/or an Object to enumerate those. Which works, but isn't exactly elegant.
Is there some kind of registry available?
[SOLVED] Enumerating Property Types and Object Types before opening a Document?
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
[SOLVED] Enumerating Property Types and Object Types before opening a Document?
Last edited by Bayesian on Tue Nov 12, 2019 9:38 am, edited 1 time in total.
- DeepSOIC
- Veteran
- Posts: 7896
- Joined: Fri Aug 29, 2014 12:45 am
- Location: used to be Saint-Petersburg, Russia
Re: Enumerating Property Types and Object Types before opening a Document?
This information is not exposed. Exposing it might need quite some work.
Listing all attributes is easy. Listing all properties is more difficult. Listing supported objects for a body is doable, but in general it might be not.
Listing all attributes is easy. Listing all properties is more difficult. Listing supported objects for a body is doable, but in general it might be not.
Re: [SOLVED] Enumerating Property Types and Object Types before opening a Document?
Hm. So there are basically two options: prepare a list offline (which doesn't account for new or nonstandard workbenches) or use the create a document and an object method.
Re: [SOLVED] Enumerating Property Types and Object Types before opening a Document?
Yes, the central registry is the C++ class Type. At the moment we don't offer a way to access it from Python but it shouldn't be too difficult to implement a way.Is there some kind of registry available?
Re: [SOLVED] Enumerating Property Types and Object Types before opening a Document?
git commit e1f85cd09
git commit d61bf15c4
git commit d61bf15c4
Code: Select all
t=App.Base.TypeId
t.getNumTypes()
p=t.fromName("App::DocumentObject")
p.Key
print(p)
p1=t.fromKey(97)
p1.Name
p.Name
p.isDerivedFrom("Base::BaseClass")
p.Module
pp=p.getParent()
pp.Name
pp.isBad()
b=t.getBadType()
b.Name
This can be done now with:I know I can get the property Types from, for example a Body object with "body.supportedProperties()" and the supported object types from "document.supportedObjects()".
Code: Select all
App.Base.TypeId.getAllDerivedFrom("App::Property")
App.Base.TypeId.getAllDerivedFrom("App::DocumentObject")
Re: [SOLVED] Enumerating Property Types and Object Types before opening a Document?
Thank you, I'm sure this will be useful!
- DeepSOIC
- Veteran
- Posts: 7896
- Joined: Fri Aug 29, 2014 12:45 am
- Location: used to be Saint-Petersburg, Russia
Re: [SOLVED] Enumerating Property Types and Object Types before opening a Document?
Awesome!wmayer wrote: ↑Tue Nov 12, 2019 11:58 pmCode: Select all
t=App.Base.TypeId t.getNumTypes() p=t.fromName("App::DocumentObject") p.Key print(p)