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
0 commit comments