[Draft] Add better error message in get_svg for direction

An AttributeError is raised when `direction=Vector(0,0,0)` and obj is
an Arch::Space on line: a3fb3cc804/src/Mod/Draft/draftfunctions/svg.py (L799)

This patch checks if early on if the direction vector and raises a
ValueError with a description of what has gone wrong.

A caveat with this solution is that this new behaviour might break old
code which depends on that invalid directions can be used.
This commit is contained in:
Benjamin Nauck
2021-01-31 20:24:59 +01:00
parent 049fd712e3
commit ce7856d51f
2 changed files with 24 additions and 0 deletions

View File

@@ -468,6 +468,8 @@ def get_svg(obj,
plane.alignToPointAndAxis_SVG(App.Vector(0, 0, 0),
direction.negative().negative(),
0)
else:
raise ValueError("'direction' cannot be: Vector(0, 0, 0)")
elif isinstance(direction, WorkingPlane.plane):
plane = direction