io_import_dxf: Fix ZeroDivision #104553

Closed
Oxicid wants to merge 2 commits from (deleted):oxicid-dxf-vector-normalized into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Showing only changes of commit 64869bab09 - Show all commits

View File

@ -9,6 +9,8 @@ __author__ = "mozman <mozman@gmx.at>"
import math import math
from mathutils import Vector
from . import const from . import const
from .color import TrueColor from .color import TrueColor
from .styles import default_text_style from .styles import default_text_style
@ -733,11 +735,6 @@ def deg2vec(deg):
return math.cos(rad), math.sin(rad), 0. return math.cos(rad), math.sin(rad), 0.
def normalized(vector):
x, y, z = vector
m = (x**2 + y**2 + z**2)**0.5
return x/m, y/m, z/m
################################################## ##################################################
# MTEXT inline codes # MTEXT inline codes
# \L Start underline # \L Start underline
@ -850,7 +847,7 @@ class MText(DXFEntity):
self.raw_text = "".join(lines) self.raw_text = "".join(lines)
if xdir is None: if xdir is None:
xdir = deg2vec(rotation) xdir = deg2vec(rotation)
self.xdirection = normalized(xdir) self.xdirection = Vector(xdir).normalized()
self.set_default_extrusion() self.set_default_extrusion()
def lines(self): def lines(self):