Draft and Arch objects TypeId
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Draft and Arch objects TypeId
Hello, maybe it is a stupid question. Why Draft and Arch objects have not a TypeId property? something like Part::Box or Sketcher::Sketch ... so Draft::Line or Draft::Circle ?
follow my experiments on BIM modelling for architecture design
- DeepSOIC
- Veteran
- Posts: 7896
- Joined: Fri Aug 29, 2014 12:45 am
- Location: used to be Saint-Petersburg, Russia
Re: Draft and Arch objects TypeId
They do, sorta. Use Draft.getType. The standard TypeId doesn't help much because it is a C++ thing only.
https://forum.freecadweb.org/viewtopic. ... 18#p135051
https://forum.freecadweb.org/viewtopic. ... 18#p135051
Re: Draft and Arch objects TypeId
Most Draft objects are created from a Part::Part2DObject, which is "a specialized version of the PartShape for use with flat (2D) geometry", according to src/Mod/Part/App/Part2DObject.h.
Code: Select all
def makeCircle(radius, placement=None, face=None, startangle=None, endangle=None, support=None):
...
obj = FreeCAD.ActiveDocument.addObject("Part::Part2DObjectPython",n)
_Circle(obj)
Code: Select all
obj = Draft.makeCircle(100)
>>> obj.TypeId
'Part::Part2DObjectPython'
Code: Select all
>>> obj.Proxy
<Draft._Circle object at 0x7fd4eb98fdd8>
Code: Select all
>>> obj.Proxy.Type
'Circle'
obj.Proxy.Type = "Banana"
>>> obj.Proxy.Type
'Banana'
In the case of Arch, objects are derived from Part::Feature, and the constructor, for example, _ArchPipe, similarly sets the Type to something like "Pipe".
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
Re: Draft and Arch objects TypeId
Thanks, really clear now.
follow my experiments on BIM modelling for architecture design
Re: Draft and Arch objects TypeId
The TypeId is important so you know the base C++ class of your object. The python objects such as Drafts, Archs, etc... are actually live python objects that live inside the C++ object's Proxy property. So it makes sense that the TypeId always refers to the "carrier" C++ object.
The idea of having a Type attribute inside the Proxy object was a dirty hack at first, but it has been more and more used all over FreeCAD (in FEM, Path, etc..) so it has now more or less become a norm now... Be careful of the dirty hacks you do, they might become the norm one day
The idea of having a Type attribute inside the Proxy object was a dirty hack at first, but it has been more and more used all over FreeCAD (in FEM, Path, etc..) so it has now more or less become a norm now... Be careful of the dirty hacks you do, they might become the norm one day