def room_bound_to_origin(room, translation): room_boundaries = DB.CurveArrArray() # get room boundary segments room_segments = room.GetBoundarySegments( DB.SpatialElementBoundaryOptions()) # iterate through loops of segments and add them to the array for seg_loop in room_segments: curve_array = DB.CurveArray() for s in seg_loop: old_curve = s.GetCurve() new_curve = old_curve.CreateTransformed( translation) # move curves to origin curve_array.Append(new_curve) room_boundaries.Append(curve_array) return room_boundaries
def createVlines(): cArray = DB.CurveArray() vn = direction(hline) xFormValues = [0] [ xFormValues.append(j) for j in list(frange(fieldColWidth, colCount + 1, colWidth)) ] for i in xFormValues: cArray.Append( vline.CreateTransformed(DB.Transform.CreateTranslation(vn * i))) revit.doc.Create.NewDetailCurveArray(revit.active_view, cArray)
def make_ceiling(): Wall_curves = List[DB.Curve]() for boundary_segment in self.Offseted_RoomBoundary(): try: Wall_curves.Add(boundary_segment) # 2015, dep 2016 except AttributeError: Wall_curves.Add(boundary_segment) # 2017 CeilingType = self.CeilingFinishType level = self.RoomLevel Floor_CurveArray = DB.CurveArray() for i in Wall_curves: Floor_CurveArray.Append(i) _doc = pyrevit._HostApplication(__revit__).doc.Create _doc.NewFloor(Floor_CurveArray, CeilingType, level, None)
def make_floor_Open(Floor): _doc = HOST_APP.doc.Create boundary = [] BoundaryArea = [i for i in self.RoomBoundary()] for i in range(0, len(self.RoomBoundary())): if i != 0: boundary.append(self.RoomBoundary()[i]) for boundary_segment in boundary: Open_CurveArray = DB.CurveArray() for i in boundary_segment: Open_CurveArray.Append(i.GetCurve()) try: _doc.NewOpening(Floor, Open_CurveArray, True) print("OpeningCreated") except Exception as e: print(e)
def createHlines(): cArray = DB.CurveArray() vn = direction(vline) xFormValues = [] for i in list(frange(0, rowCount, rowHeight)): [ xFormValues.append(j) for j in list(frange(i, fieldRowCount + 1, fieldRowHeight)) ] for i in xFormValues: cArray.Append( hline.CreateTransformed(DB.Transform.CreateTranslation(vn * i))) revit.doc.Create.NewDetailCurveArray(revit.active_view, cArray)
def make_floor(): Floor_CurveArray = DB.CurveArray() for boundary_segment in self.RoomBoundary()[0]: Floor_CurveArray.Append(boundary_segment.GetCurve()) #Floor_CurveArray.Append(Wall_curves) FloorType = self.FloorFinishType level = self.RoomLevel _doc = pyrevit._HostApplication(__revit__).doc.Create try: self.NewFloor = _doc.NewFloor(Floor_CurveArray, FloorType, level, None) self.NewFloor.get_Parameter( DB.BuiltInParameter.FLOOR_HEIGHTABOVELEVEL_PARAM).Set( self.RoomBase) print("{RoomName}建筑楼板被创建".format(RoomName=self.RoomName)) except Exception as e: self.NewFloor = None print("{RoomName}建筑楼板未能被创建:{Problem}".format( RoomName=Room.RoomName, Problem=e.__traceback__))
# get profile plane e1 = profile[0].GeometryCurve.GetEndPoint(0) e2 = profile[0].GeometryCurve.GetEndPoint(1) h = DB.XYZ(e1.X, e1.Y, 100) plane = DB.Plane.CreateByThreePoints(e1, e2, h) # use a curve loop to offset the profile polycurve curve_loop = DB.CurveLoop() for model_curve in profile: curve_loop.Append(model_curve.GeometryCurve) offset_distance = get_ins_position(roof_type) + ins_layer_width / 2 offset_loop = DB.CurveLoop.CreateViaOffset(curve_loop, offset_distance, plane.Normal) # store new curves in a curve array new_curves = DB.CurveArray() for curve in offset_loop: new_curves.Append(curve) # create profile reference plane ref_plane = doc.Create.NewReferencePlane2(e1, e2, h, revit.active_view) # get original roof parameters extr_start = roof.get_Parameter(DB.BuiltInParameter.EXTRUSION_START_PARAM).AsDouble() extr_end = roof.get_Parameter(DB.BuiltInParameter.EXTRUSION_END_PARAM).AsDouble() level = doc.GetElement(roof.get_Parameter(DB.BuiltInParameter.ROOF_CONSTRAINT_LEVEL_PARAM).AsElementId()) # create new extrusion roof new_roof = doc.Create.NewExtrusionRoof(new_curves, ref_plane, level, chosen_roof_type, extr_start, extr_end) except: pass