it would be nice if that was harmonized and also that all of them worked as iterables,
or had a method like .totuple() or similar.
it is largely just a nice to have that imho on occasion would allow for easier to read code,
with the added benefit that one does not have to remember what works for which type.
Code: Select all
>>> vector
Vector (1.0, 2.0, 3.0)
>>> x, y, z = vector # nice
>>> vertex
<Vertex object at 0x55879787b140>
>>> x, y, z = vertex # oops
Traceback (most recent call last):
File "<input>", line 1, in <module>
TypeError: cannot unpack non-iterable Part.Vertex object
>>> x, y, z = vertex.Point # works, but why have to put .Point
>>> x, y, z = vertex.X, vertex.Y, vertex.Z # verbose
>>>
that does not render the coordinates, would be nice if it did.
another item is the printed precision, it would be nice if that could be configurable.
similar to https://docs.scipy.org/doc/numpy-1.14.0 ... tions.html
putting all of this out there in hopes that someone will take it on.
an overview (not claiming that it is complete...)
Code: Select all
>>> v = App.Vector(1,2,3)
>>> v
Vector (1.0, 2.0, 3.0)
>>> tuple(v)
(1.0, 2.0, 3.0)
>>> import Part
>>> Part.Point()
<Point (0,0,0) >
>>> p = Part.Point(1,2,3)
Traceback (most recent call last):
File "<input>", line 1, in <module>
TypeError: Point constructor accepts:
-- empty parameter list
-- Point
-- Coordinates vector
>>> p = Part.Point((1,2,3))
Traceback (most recent call last):
File "<input>", line 1, in <module>
TypeError: Point constructor accepts:
-- empty parameter list
-- Point
-- Coordinates vector
>>> p = Part.Point(v)
>>> p
<Point (1,2,3) >
>>> tuple(p)
Traceback (most recent call last):
File "<input>", line 1, in <module>
TypeError: 'Part.Point' object is not iterable
>>> Part.Vertex()
<Vertex object at 0x5587975b5620>
>>> vx = Part.Vertex(1,2,3)
>>> tuple(vx)
Traceback (most recent call last):
File "<input>", line 1, in <module>
TypeError: 'Part.Vertex' object is not iterable
>>> vx.Point
Vector (1.0, 2.0, 3.0)
>>> tuple(vx.Point)
(1.0, 2.0, 3.0)
>>> import Draft
>>> Draft.Point()
Traceback (most recent call last):
File "<input>", line 1, in <module>
TypeError: __init__() missing 1 required positional argument: 'obj'
>>> ptd = Draft.Point(1,2,3)
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/tmp/.mount_FreeCARntfqs/usr/Mod/Draft/draftobjects/point.py", line 42, in __init__
super(Point, self).__init__(obj, "Point")
File "/tmp/.mount_FreeCARntfqs/usr/Mod/Draft/draftobjects/base.py", line 81, in __init__
obj.Proxy = self
AttributeError: 'int' object has no attribute 'Proxy'
>>> ptd = Draft.Point((1,2,3))
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/tmp/.mount_FreeCARntfqs/usr/Mod/Draft/draftobjects/point.py", line 42, in __init__
super(Point, self).__init__(obj, "Point")
File "/tmp/.mount_FreeCARntfqs/usr/Mod/Draft/draftobjects/base.py", line 81, in __init__
obj.Proxy = self
AttributeError: 'tuple' object has no attribute 'Proxy'
>>> ptd = Draft.Point(v)
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/tmp/.mount_FreeCARntfqs/usr/Mod/Draft/draftobjects/point.py", line 42, in __init__
super(Point, self).__init__(obj, "Point")
File "/tmp/.mount_FreeCARntfqs/usr/Mod/Draft/draftobjects/base.py", line 81, in __init__
obj.Proxy = self
AttributeError: 'Base.Vector' object has no attribute 'Proxy'
>>> Draft.makePoint(1,2,3)
<Part::PartFeature>
>>> ptd = Draft.makePoint(1,2,3)
>>> ptd
<Part::PartFeature>
>>> tuple(ptd)
Traceback (most recent call last):
File "<input>", line 1, in <module>
TypeError: 'FeaturePython' object is not iterable
>>> ptd.Shape.Vertex1
Traceback (most recent call last):
File "<input>", line 1, in <module>
AttributeError: 'Part.Shape' object has no attribute 'Vertex1'
>>> ptd.Shape.Vertexes
[]
>>> ptd.Shape.ShapeType
Traceback (most recent call last):
File "<input>", line 1, in <module>
Base.FreeCADError: cannot determine type of null shape
>>> ptd.Shape.TypeId
'Part::TopoShape'
>>> ptd.Shape
<Shape object at 0x558797bf3280>
>>> ptd.Shape.Content
''
>>> ptd.Vector
Traceback (most recent call last):
File "<input>", line 1, in <module>
AttributeError: 'FeaturePython' object has no attribute 'Vector'
>>> ptd.Point
Traceback (most recent call last):
File "<input>", line 1, in <module>
AttributeError: 'FeaturePython' object has no attribute 'Point'
>>> import Mesh
>>> ptm = Mesh.MeshPoint()
>>> ptm = Mesh.MeshPoint(1,2,3)
>>> ptm
MeshPoint (1, 2, 3)
>>> tuple(ptm)
Traceback (most recent call last):
File "<input>", line 1, in <module>
TypeError: 'Mesh.MeshPoint' object is not iterable
>>> ptm.Vector
Vector (1.0, 2.0, 3.0)
>>>
suppose sketch point belongs here as well, but have not listed that one here, maybe there are even more.