-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathutils.py
35 lines (25 loc) · 899 Bytes
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import config
from collections import namedtuple
import ezdxf
from ezdxf.tools import standards as std
# Convert blocks to units
def btu(block):
return block * config.UNITS_PER_BLOCK
def pack_transform(origin=(0, 0),
offset=(0, 0),
scale=config.UNIT_SCALE,
rotation=0):
Transform = namedtuple('Transform',
['origin', 'offset', 'scale', 'rotation'])
t = Transform(origin=origin, offset=offset, scale=scale, rotation=rotation)
return t
def new_dwg():
dwg = ezdxf.new(dxfversion='AC1015')
for linetype in std.linetypes():
try:
dwg.linetypes.new(name=linetype[0],
dxfattribs={'description': linetype[1],
'pattern': linetype[2]})
except ValueError as e:
pass
return dwg