Skip to content

Commit 2f85ca5

Browse files
authored
Merge pull request #18 from Amoursol/master
sync
2 parents 0011964 + c6a57e4 commit 2f85ca5

File tree

2 files changed

+80
-8
lines changed

2 files changed

+80
-8
lines changed

revitAPI/CreateWallSweep.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
'''
2+
Create Wall Sweep - By Wall
3+
'''
4+
5+
__author__ = 'min.naung/mgjean @https://twentytwo.space/contact'
6+
__twitter__ = '@_mgjean'
7+
__version__ ='1.0.0'
8+
9+
10+
# import common language runtime
11+
import clr
12+
13+
# clr.AddReference loads and imports .net assembly(dll) as python module
14+
# load RevitAPI.dll and RevitServices.dll
15+
clr.AddReference("RevitAPI")
16+
clr.AddReference("RevitServices")
17+
18+
# import all classes from Revit DB
19+
from Autodesk.Revit.DB import *
20+
21+
# import document manager
22+
from RevitServices.Persistence import DocumentManager
23+
# import transaction manager
24+
from RevitServices.Transactions import TransactionManager
25+
26+
# instantiate current document
27+
doc = DocumentManager.Instance.CurrentDBDocument
28+
29+
# for output result
30+
wallSweeps = []
31+
# wallsweeptype dictionary
32+
wallSweepTypes = {"Sweep": WallSweepType.Sweep,
33+
"Reveal": WallSweepType.Reveal}
34+
# input1 walls
35+
walls = IN[0]
36+
# input3 string input
37+
sweepOrReveal = IN[2]
38+
# input4 boolean input default is horizontal(false)
39+
vertical = IN[3] if IN[3] else False
40+
# distance from wall base if horizontal, vertical wall start
41+
# default is 1000mm
42+
distance = IN[4]/304.8 if IN[4] else 1000/304.8
43+
44+
# check and make list
45+
if not isinstance(walls,list):
46+
walls = UnwrapElement([IN[0]])
47+
else:
48+
walls = UnwrapElement(IN[0])
49+
# input2 wall sweep type input
50+
wallSweepTypeId = UnwrapElement(IN[1]).Id
51+
# wall sweep info class constructor
52+
wallSweepInfo = WallSweepInfo(wallSweepTypes[sweepOrReveal],vertical)
53+
# set distance
54+
wallSweepInfo.Distance = distance
55+
# start transaction
56+
TransactionManager.Instance.EnsureInTransaction(doc)
57+
# loop input walls
58+
for wall in walls:
59+
# create wall sweep by wall, wallsweepid and wallsweep info
60+
wallsweep = WallSweep.Create(wall,wallSweepTypeId,wallSweepInfo)
61+
# append result to output
62+
wallSweeps.append(wallsweep)
63+
# transaction done
64+
TransactionManager.Instance.TransactionTaskDone()
65+
# output result
66+
OUT = wallSweeps

revitAPI/rdsCsvExporter.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def ListChopEvenly(l, n):
6464
return [l[i:i + n] for i in xrange(0, len(l), n)]
6565

6666
# -----------------------
67-
# input paramters
67+
# input parameters
6868
# -----------------------
6969

7070
# in the dynamo environment wire a string node to the input
@@ -82,19 +82,15 @@ def ListChopEvenly(l, n):
8282
params = replaceParams.split(',')
8383
# so we can chop a flat list into groups we need to know its lengths
8484
paramsLen = len(params)
85-
# we will need somehere to store values for csv
86-
values = []
87-
# the csv will need to have as headers for each parameter
88-
for p in params :
89-
values.append(p)
9085

9186
# -----------------------
92-
# inputs
87+
# parameter values
9388
# -----------------------
9489

9590
# collect all rooms as elements
9691
allRooms = fec(doc).OfCategory(BuiltInCategory.OST_Rooms).ToElements()
97-
92+
# we will need somehere to store values for csv
93+
values = []
9894
# to lookup the parameter value, for each parameter, for each room
9995
for r in allRooms :
10096
for p in params :
@@ -115,13 +111,23 @@ def ListChopEvenly(l, n):
115111
elif strStorageType == 'Double' :
116112
# cast value as double
117113
doubleValue = value.AsDouble()
114+
# convert square feet to square meters for area
115+
if p == "Area" :
116+
doubleValue = doubleValue * 0.092903
118117
# round the double value
119118
doubleRound = round(doubleValue, 3)
120119
# append values
121120
values.append(doubleRound)
122121

123122
# a flat list values needs to be chopped into groups by list length
124123
choppedValues = ListChopEvenly(values, paramsLen)
124+
choppedValues.sort()
125+
126+
# the csv will need to have as headers for each parameter
127+
headers = []
128+
for p in params :
129+
headers.append(p)
130+
choppedValues.insert(0, headers)
125131

126132
# -----------------------
127133
# write csv file of room parameters

0 commit comments

Comments
 (0)