-
Notifications
You must be signed in to change notification settings - Fork 4
/
MakeDuct.py
48 lines (40 loc) · 1.62 KB
/
MakeDuct.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
36
37
38
39
40
41
42
43
44
45
46
47
from math import sqrt
from numpy import rad2deg, arctan2
from random import randint, uniform
from shapely import geometry as shapely
from aecSpace.aecColor import aecColor
from aecSpace.aecFloor import aecFloor
from aecSpace.aecShaper import aecShaper
from aecSpace.aecPoint import aecPoint
from aecSpace.aecSpace import aecSpace
from aecSpace.aecSpaceGroup import aecSpaceGroup
from aecSpace.aecSpacer import aecSpacer
from aecSpace.aecSpaceDrawOCC import aecSpaceDrawOCC
def makeDuct(start: aecPoint, end: aecPoint, width: float, height: float) -> aecSpace:
shaper = aecShaper()
duct = aecSpace()
length = sqrt(((end.x - start.x) ** 2) + ((end.y - start.y) ** 2))
duct.boundary = shaper.makeBox(aecPoint(0, 0, 0), xSize = length, ySize = width)
midOrigin = aecPoint(0, (width * 0.5), 0)
duct.moveTo(fromPnt = midOrigin, toPnt = start)
angle = rad2deg(arctan2(end.y - start.y, end.x - start.x))
duct.rotate(angle, start)
duct.moveBy(z = (height * -0.5))
duct.height = height
return duct
# def makeDuctTest():
# start = aecPoint(20, 50, 10)
# end = aecPoint(60, 30, 10)
# width = 5
# height = 2
# duct1 = makeDuct(start, end, width, height)
# start = aecPoint(60, 30, 10)
# end = aecPoint(100, 50, 10)
# duct2 = makeDuct(start, end, width, height)
# return [duct1, duct2]
#
#spaces = makeDuctTest()
#spaceDrawer = aecSpaceDrawOCC()
#spaceDrawer.draw3D(spaces, displaySize = (1600, 900), update = True)
# update = True animates the example by updating the display after every space placement.
# About 60x slower to completion, but more interesting to watch.