View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0001387 | Draft | Feature | public | 2014-02-06 14:09 | 2014-02-24 19:40 |
Reporter | shoogen | Assigned To | yorik | ||
Priority | none | Severity | tweak | Reproducibility | N/A |
Status | closed | Resolution | fixed | ||
Product Version | trunk | ||||
Summary | 0001387: Wrong __repr__ for Draft Objects | ||||
Description | The result of __str__ and __repr__ for Draft Objects gives a wrong result. "<Document object" istead of "<Part::PartFeature>" | ||||
Steps To Reproduce | >>> d1=App.ActiveDocument.addObject('Part::Part2DObjectPython') >>> print d1.TypeId,' ', d1.__str__(),' ', d1.__repr__() Part::Part2DObjectPython <Document object> <Document object> | ||||
Tags | No tags attached. | ||||
FreeCAD Information | |||||
|
only happens if preference != "use part primitives": with Draft preference "use part primitives" checked >>> d = App.ActiveDocument.Line >>> print d.TypeId,' ', d.__str__(),' ', d.__repr__() Part::Line <Part::PartFeature> <Part::PartFeature> with Draft preference "use part primitives" not checked >>> dd = App.ActiveDocument.Line >>> print dd.TypeId,' ', dd.__str__(),' ', dd.__repr__() Part::Part2DObjectPython <Document object> <Document object> |
|
hm technically it is not exactly wrong... The Part2DObjectPython object is indeed a document object. But I see your point. I could solve this easily I think by overriding the __repr__() inside the python objects, but there should be a better fix inside the Part2DObject itself probably. I'll have a look at it, but I'm not sure I'll be able to solve... |
|
Ok, if Document Object is the parent class. Part::Part2DObjectPython is indeed fine. But maybe the "Document" should return something else than <Document>. I don't like the idea of having the get the "TypeId" property to determine the c++ class information of an object. preferably a __repr__ result with angle brackets should include all class information available. |
|
This is strange, the representation is set in Part2DObjectPyImp.cpp, but for some reason, it is not used by the object... |
|
maybe a missing "virtual" in c++? |
|
Not sure what that means exactly... Sorry, my C++ knowlege is still weak |
|
http://en.wikipedia.org/wiki/Dynamic_dispatch But the class structure in FreeCAD is quite complicated. Just assign it to Jürgen or Werner ;) |
|
Ok I think I managed to fix it... >>> o1 = App.ActiveDocument.addObject("Part::FeaturePython","o1") >>> o2 = App.ActiveDocument.addObject("Part::Part2DObjectPython","o2") >>> o1 <FeaturePython object at 0x6ea5958> >>> o2 <FeaturePython object at 0x6ecdf68> >>> o1.TypeId 'Part::FeaturePython' >>> o2.TypeId 'Part::Part2DObjectPython' >>> o1.__repr__() '<Part::PartFeature>' >>> o2.__repr__() '<Part::Part2DObject>' >>> o1.__str__() '<Part::PartFeature>' >>> o2.__str__() '<Part::Part2DObject>' |
Date Modified | Username | Field | Change |
---|---|---|---|
2014-02-06 14:09 | shoogen | New Issue | |
2014-02-06 15:13 | wandererfan | Note Added: 0004157 | |
2014-02-08 03:05 | yorik | Note Added: 0004166 | |
2014-02-08 03:05 | yorik | Assigned To | => yorik |
2014-02-08 03:05 | yorik | Status | new => assigned |
2014-02-08 03:05 | yorik | Note Edited: 0004166 | |
2014-02-08 03:06 | yorik | Project | FreeCAD => Draft |
2014-02-09 08:58 | shoogen | Note Added: 0004173 | |
2014-02-09 09:10 | shoogen | Reproducibility | always => N/A |
2014-02-09 09:10 | shoogen | Category | Bug => Feature |
2014-02-12 15:20 | yorik | Note Added: 0004195 | |
2014-02-12 15:29 | shoogen | Note Added: 0004197 | |
2014-02-24 15:25 | yorik | Note Added: 0004292 | |
2014-02-24 16:17 | shoogen | Note Added: 0004294 | |
2014-02-24 19:11 | yorik | Note Added: 0004297 | |
2014-02-24 19:40 | yorik | Changeset attached | => FreeCAD Master master 3f99b6ec |
2014-02-24 19:40 | yorik | Status | assigned => closed |
2014-02-24 19:40 | yorik | Resolution | open => fixed |