def AddGISLocation_Wall(WallElement): WrapedWall = db.Element(WallElement) LocationCurve = WallElement.Location StartPoint = LocationToValue(LocationCurve)[0] EndPoint = LocationToValue(LocationCurve)[1] Location = { "SP": StartPoint, "EP": EndPoint, "BL": "", "BO": "", "TL": "", "TO": "" } Location["BL"] = WrapedParameterValue( WrapedWall.parameters[ParameterName.WALL_BASE_CONSTRAINT]) Location["BO"] = WrapedParameterValue( WrapedWall.parameters[ParameterName.WALL_BASE_OFFSET]) Location["TL"] = WrapedParameterValue( WrapedWall.parameters[ParameterName.WALL_HEIGHT_TYPE]) Location["TO"] = WrapedParameterValue( WrapedWall.parameters[ParameterName.WALL_TOP_OFFSET]) with db.Transaction('add Gis Location'): WrapedWall.parameters["GISLocation"] = Location
def MoveToFloor(self, Floor): _Floor = BAT_Floor(Floor) TopSurfaces = _Floor.GetTopPlane() Proj1 = TopSurfaces[0].Project(self.StartPoint) Proj2 = TopSurfaces[0].Project(self.EndPoint) if Proj1 != None and Proj2 != None: Distance1 = Proj1.XYZPoint.Z Distance2 = Proj2.XYZPoint.Z print(Distance2, Distance1) with db.Transaction('Move Beam To Floor'): SLO = self.WrapedBeam.parameters[ ParameterName.BEAM_Start_Level_Offset].value ELO = self.WrapedBeam.parameters[ ParameterName.BEAM_End_Level_Offset].value self.WrapedBeam.parameters[ ParameterName.BEAM_Start_Level_Offset] = Distance1 self.WrapedBeam.parameters[ ParameterName.BEAM_End_Level_Offset] = Distance2 print("梁被排布在板底") else: print("梁{}(id:{})不在板内,请重新放置梁".format(self.Beam.Name, self.Beam.Id)) return [Proj1.XYZPoint, Proj2.XYZPoint]
def SetNewType(find_familyName, find_typeName, replace_familyName, replace_typeName, where): tyId = GetTypeId(replace_familyName, replace_typeName) #els = db.Collector(view=doc.ActiveView).get_elements(True) els = nfc.CollectAllElements(where) log = 'Nothing done!' errlog = '' with db.Transaction('neoCL | Family and Type Replacer'): for elx in els: try: elxFn = elx.parameters["Family"].value_string if find_familyName == elxFn: if find_typeName == elx.name: try: elx._revit_object.ChangeTypeId(tyId) log = "At least one replaced." except: errlog = errlog + "\nCouldn't change type of : " + str(elx.name) + " Id[" + str(elx.Id) + "]" print("Couldn't change type of : " + str(elx.name) + " Id[" + str(elx.Id) + "]") except: #print("Can't get Family of : " + str(elx.name)) pass return log + errlog
def wrapped(*args, **kwargs): with db.Transaction(msg) as trans: failure_options = trans.GetFailureHandlingOptions() failure_options.SetFailuresPreprocessor(accessor) trans.SetFailureHandlingOptions(failure_options) res = func(*args, **kwargs) return res
def ImportXl(): with db.Transaction('neoCL | Import from iParameters Editor'): XL, wb = GetWb() sh = wb.Worksheets(shName) sh.Activate ImportMain(sh) wb.Save wb.Close
def PrintView(doc, sheet, pRange, printerName, PrinterFolderPath, RealFolderPath, FileName, combined, printSetting): viewSet = ViewSet() viewSet.Insert(sheet) tempFullName = PrinterFolderPath + "\\" + FileName realFullName = RealFolderPath + "\\" + FileName pm = doc.PrintManager pm.PrintRange = pRange pm.PrintRange = PrintRange.Select pm.ViewSheetSetting.CurrentViewSheetSet.Views = viewSet pm.SelectNewPrintDriver(printerName) pm.PrintToFile = True pm.PrintToFileName = realFullName pm.Apply() try: printSetup = pm.PrintSetup printSetup.CurrentPrintSetting = printSetting pm.Apply() except: pass with db.Transaction('neoCL | Print'): pm.SubmitPrint() shutil.move(tempFullName, realFullName) #def DeleteViewSet(doc, ViewSetName): # viewSets = FilteredElementCollector(doc).OfClass(ViewSheetSet) # for vs in viewSets: # if vs.Name == ViewSetName: # with db.Transaction('neoCL | Printer'): # doc.Delete(i.Id) #pm.CombinedFile = combined #pm.PrintToFile = pm.IsVirtual #ViewSetName = "neoCL_PDF_Printer" #DeleteViewSet(doc, ViewSetName) #printManager.PrintToFile = True # set file path #pm.PrintToFileName = FullFileName #pm.Apply() # apply print setting #try: # pm.ViewSheetSetting.SaveAs(ViewSetName) # pm.Apply() #except: # pass #pm.ViewSheetSetting.Delete()
def main(): selected_element_by_room = [] family_instance_reference = uidoc.Selection.PickObject( UI.Selection.ObjectType.Element, ClassISelectionFilter(), "Select FamilyInstance") room_reference = uidoc.Selection.PickObject( UI.Selection.ObjectType.Element, CategoryISelectionFilterByName("Rooms"), "Select Room") """ room_reference = uidoc.Selection.PickObject( UI.Selection.ObjectType.Element, CategoryISelectionFilterByBuiltInCategory( DB.BuiltInCategory.OST_Rooms), "Select Room") """ source_fi = doc.GetElement(family_instance_reference.ElementId) source_room = doc.GetElement(room_reference.ElementId) # print(source_fi) selected_elements = db.Collector( of_class="FamilyInstance", is_not_type=True, where=lambda x: x.GetTypeId() == source_fi.GetTypeId()).get_elements() view = uidoc.ActiveView phase_name = view.get_Parameter( DB.BuiltInParameter.VIEW_PHASE).AsValueString() phase = get_phase(phase_name) with db.Transaction("Selected Element by Python"): for e in selected_elements: if e.Room[phase].Id == source_room.Id: selected_element_by_room.append(e) e.parameters['Selected Comment'].value = "Selected" else: e.parameters['Selected Comment'].value = "" ui.forms.Alert("Family Name: {}\nType Name: {}\nFamily Count: {}".format( source_fi.Symbol.FamilyName, db.Element(source_fi).name, len(selected_element_by_room)), title="Selected Elements/Room", header="Room Name: {} Room Number: {}".format( db.Room(source_room).name, source_room.Number)) uidoc.Selection.SetElementIds(List[DB.ElementId]( e.Id for e in selected_element_by_room))
def Start(): with db.Transaction('neoCL | Import from iParameters Editor'): go = True val = g.pmVal print("Val " + str(val)) while go: el = UserSelect(True) if el: pm = el.parameters[g.pmTag] try: if pm.type is str: pm._revit_object.Set(str(val)) elif pm.type is int: pm._revit_object.Set(int(val)) elif pm.type is float: pm._revit_object.SetValueString(str(val)) else: pm._revit_object.SetValueString(val) except: print("-> Can't set this parameter: " + val) else: go = False
# EVENT ON CLICK ////// # Event on Cancel Button Click def Cancel(self, sender, event): self.Close() # Event on OK Button Click def Ok(self, sender, event): for i in range(self.checkedlistbox1.CheckedItems.Count): revision_out.append(self.checkedlistbox1.CheckedItems[i]) self.Close() # run form Application.Run(MyListBox2()) # END OF WINDOWS FORM /////////////////////////////////////////////////// # /////////////////////////////////////////////////////////////////////// # Get collection element id of revision selected by user revision_out_id = [] for item in revision_out: revision_out_id.append(dico_revision_nameToId[item]) collectionId_revision = List[DB.ElementId](revision_out_id) # Transaction with db.Transaction("set new revision"): for sheets in sheets_selected: dico_sheet_nameToElementId[sheets].SetAdditionalRevisionIds( collectionId_revision)
#element2 = db.Element.from_int(Integer) # couldn't get element just from element ID..but there must be a way?! #need to do a level collector #elements = [] #elements.append(doc_active.GetElement(-1)) #selection = ui.Selection(wall_elements) # START A TRANSACTION t = db.Transaction('connect unconnected walls') def set_param(element, ParameterName, Value): param_constraint = wall.parameters[ParameterName].Set(elementid) #Set(elementid.InvalidElementId) will set it to -1, which is unconnected t.Start() for wall in wall_elements: set_param(wall, "Top Constraint", -1) # having trouble changing Top Constraint for some reason. for wall in wall_elements: param_constraint = wall.parameters['Top Constraint'] #print param_constraint
__doc__ = "DepthMap Analysis" import clr import time import sys import rpw import pyrevit from rpw import db, doc, uidoc from pyrevit import revit, DB, UI, forms, HOST_APP import System from System.Collections.Generic import List from pyrevit.framework import Stopwatch ###################################### #allElementsInView = DB.FilteredElementCollector(doc, doc.ActiveView.Id).ToElements() #for i in allElementsInView: # print(i) allElementsInView = db.Collector(view=doc.ActiveView, is_type=False).get_elements(wrapped=True) with db.Transaction('AddElementId'): for i in allElementsInView: #print(i.unwrap().Id) try: i.parameters['ElementId'].value = i.unwrap().Id except: pass
def Import(): import _neo_importer import lib.revisions.neo_revisions_main as mn with db.Transaction(str('neoCL | Import Revisions')): XL, wb = GetWb() XL.DisplayAlerts = False sh = wb.Worksheets(shName) sh.Cells(1, 1).Value = "Importing to Revit... please wait..." ri = re #ci = ce while(True): newRev = False rId = sh.Range[rg(ri, ce)] rlog = sh.Range[rg(ri, ce + 8)] rDescription = sh.Range[rg(ri, ce + 4)] revOrder = sh.Range[rg(ri, ce + 1)].Text revOrder = int(revOrder.strip() or 0) if rId.Text and not rDescription.Text: if mn.DeleteRevision(rId.Text): rlog.Value2 = "Revision DELETED!" else: rlog.Value2 = "Can't delete revision!" mn.revIdsToReorder.append([int(revOrder), DB.ElementId(int(rId.Text))]) elif rDescription.Text: try: revId = rId.Text if revId: rev = doc.GetElement(DB.ElementId(int(revId))) else: rev = DB.Revision.Create(doc) revId = rev.Id.ToString() sh.Range[rg(ri, ce)].Value2 = "'" + revId newRev = True mn.revIdsToReorder.append([int(revOrder), DB.ElementId(int(revId))]) rev.Issued = True if sh.Range[rg(ri, ce + 5)].Text == 'Yes' else False if not rev.Issued: rev.RevisionDate = sh.Range[rg(ri, ce + 3)].Text rev.Description = sh.Range[rg(ri, ce + 4)].Text rev.IssuedTo = sh.Range[rg(ri, ce + 6)].Text rev.IssuedBy = sh.Range[rg(ri, ce + 7)].Text numType = sh.Range[rg(ri, ce + 2)].Text if numType == "Numeric": rev.NumberType = DB.RevisionNumberType.Numeric elif numType == "Alphanumeric": rev.NumberType = DB.RevisionNumberType.Alphanumeric elif numType == "None": rev.NumberType = DB.RevisionNumberType.None rlog.Value2 = "Done." else: rlog.Value2 = "Can't update data in Issued revisions. Set Issued to No to allow editing." except: # OSError as err: #print("OS error: {0}".format(err)) rlog.Value2 = "Error trying to update... Is the Id correct?" if newRev: rlog.Value2 = "New revision created. " + rlog.Value2 elif not rId.Text and not rDescription.Text: try: mn.ReorderRevisions() #print("Import is done!") sh.Cells(1, 1).Value = "Import to Revit is done!" except: err = "Process ended. Can't reorder revisions! Are all the revisions listed in Excel? Read HOW TO sheet!" #print(err) sh.Range[rg(1, 1)].Value2 = err sh.Cells.EntireColumn.AutoFit() XL.DisplayAlerts = True return ri += 1
pass operated_rooms[n] = rooms_data for n in operated_rooms: area = 0 for unit in dataset: rooms_data = operated_rooms[n] for type in rooms_data: if type == str(db.Element(unit.walltype).parameters['BA_AI_Structure'].value) and unit.roomid == n: rooms_data[type] += unit.wallarea #print('True') else: #print('False') pass with db.Transaction('BA_WallFinishing Parameters'): for key in operated_rooms: a = operated_rooms[key] n = 1 area_all = '' type_all = '' areatext = '' typetext = '' for k in a: areatext = str(n) + ". " + str(round(a[k],2)) + " м2 \r\n" typetext = str(n) + ". " + str(k) + "\r\n" n += 1 area_all += areatext type_all += typetext db.Element(doc.GetElement(ElementId(int(key)))).parameters['BA_AI_RoomFinishingDescription-Wall'].value = type_all db.Element(doc.GetElement(ElementId(int(key)))).parameters['BA_AI_RoomFinishingArea-Wall'].value = area_all
# FlexForm components = [ Label('Select Level:'), ComboBox('Level', levels_dict), Button('Select') ] form = ui.forms.FlexForm('Set Level', components) form_show = form.show() # Returns a dictionary with one object form_value_dict = form.values # Returns a list with just the value in the dictionary (no key). You need the value because that is the element ID object. form_value_list = form_value_dict.values() # Start transaction t = db.Transaction() t.Start() # Set the Top Constraint parameter to the level that was selected via FlexForm for wall in wall_elements: wall.parameters['Top Constraint'] = form_value_list[0] # Because form_value_list returns a list, you must grab the item object in that list via [] and feed it into the parameter. If you dont, you get the following error: # Exception : System.Exception: Wrong Storage Type: [<type 'ElementId'>]:[<type 'list'>:[<Autodesk.Revit.DB.ElementId object at 0x0000000000001F22 [665247]>]] t.Commit()
#Combining a data package for a new wall new_wall = NewWall(wall_type_id=wall_type_id, wall_type=wall_type, curve=line, level_id=room_level_id, room_name=room_name, room_number=room_number, room_id=room_id, plug=plug, room_height=room_height, bound_walls=bound_walls) new_walls.append(new_wall) #Create wall wallz = [] with db.Transaction('Create walls'): # Duplicating wall type tmp = duplicate_wall_type(new_wall.wall_type) # Creating wall for new_wall in new_walls: make_wall(new_wall, tmp) # Changing wall type back for n in wallz: #changetype(n,new_wall.wall_type) n.ChangeTypeId(new_wall.wall_type.Id) n.get_Parameter(BuiltInParameter.WALL_KEY_REF_PARAM).Set(3) # Deleting temp wall type
Label('Select the element'), ComboBox('pick_elem', { 'Poutres': 0, 'Dalles': 1 }), Label('write the parameter'), TextBox('textbox'), Separator(), Button('OK') ] form = FlexForm('Your moment', components) form.show() floor_level = round(form.values["floor_level"].Elevation / 3.2808399, 3) elem_number = form.values["pick_elem"] parameter_name = form.values["textbox"] if elem_number == 1: with db.Transaction('Tag floor'): for floor in floor_collector: z_min = ((floor.get_Geometry(options).GetBoundingBox().Min).Z / 3.2808399) # + valeur point de base possiblement floor.LookupParameter(parameter_name).Set(z_min - floor_level) elif elem_number == 0: with db.Transaction('Tag beam'): for beam in beam_collector: z_min = ( (beam.get_Geometry(options).GetBoundingBox().Min).Z / 3.2808399 ) # + valeur point de base possiblement beam.LookupParameter(parameter_name).Set(z_min - floor_level)
dialog = TaskDialog("Warning Form", content = 'The Excel sheet to import must be open with for first colomn x, second y and third z', commands = commands) if dialog.show(): def convertStr(s): try: ret = int(s) except ValueError: ret = None return ret # Get the Excel file # t = Transaction(doc, 'Read Excel spreadsheet.') # t.Start() with db.Transaction('read xl sheet'): #Accessing the Excel applications. try: xlApp = System.Runtime.InteropServices.Marshal.GetActiveObject('Excel.Application') except: Alert('The Excel sheet must be open (the program failed because of a problem with Excel)', title = "Failed", exit = True) dicWs = {} count = 1 for i in xlApp.Worksheets: dicWs[i.Name] = i count += 1 components = [Label('Select the name of Excel sheet to import :'), ComboBox('combobox', dicWs), Label('Choose the units you used in your Excel sheet :'),
all_sheet_numbers = [] all_sheet_names = [] for sheet_name in sheet_names: for i in range(1, 5): all_sheet_names.append(sheet_name + "-Type {}".format(i)) all_sheet_numbers.append(sheet_name.split("-")[0] + "." + str(i)) viewTypeId = DB.ElementId(10522069) view_data = { "WW-ViewCategory": "Working", "WW-ViewSubCategory": "0000 Architecture" } params = ["WW-ViewCategory", "WW-ViewSeries", "WW-ViewSubCategory"] with db.Transaction("Add Elevation Marker"): for sheet_name in all_sheet_names: print("pick point for {}".format(sheet_name)) pt = ui.Pick.pick_pt().unwrap() col = db.Collector(of_class="ViewSection", is_type=False, where=lambda x: sheet_name in x.Name) col = col.unwrap() if col.GetElementCount() < 1: marker = DB.ElevationMarker.CreateElevationMarker( doc, viewTypeId, pt, 20) viewPlanId = doc.ActiveView.Id for i in range(4): elevation = marker.CreateElevation(doc, viewPlanId, i) elevation.Name = sheet_name + " - Elevation {}".format(i + 1)
doc = revit.doc #Collect View Templates views = FilteredElementCollector(doc).OfClass(View).ToElements() template_dict = { v.Name: v for v in views if v.ViewType == ViewType.FloorPlan and v.IsTemplate } #Collect Levels levels = FilteredElementCollector(doc).OfClass(Level).ToElements() #Create Floor Plan View Type view_type = doc.GetDefaultElementTypeId(ElementTypeGroup.ViewTypeFloorPlan) #Launch main window user_input = flex_form(template_dict, 'Enter Suffix Here').values if user_input['select_levels']: levels = select_levels(doc, levels) else: pass with db.Transaction(doc=doc, name="Create Views"): print('The Following Views were Created' + '\n' + '-' * 50) for level in levels: new_view = ViewPlan.Create(doc, view_type, level.Id) new_view.Name = level.Name.upper() + '-' + user_input['suffix'] new_view.ViewTemplateId = user_input['template'].Id print(new_view.Name) print('Template --> {}'.format(user_input['template'].Name))
aussparung_types_dict = defaultdict(dict) void_symbol = None found_counter = 0 types_created = 0 existed_already_counter = 0 created_counter = 0 obsolete_counter = 0 family_filter_name = "ROHB_GEN_Aussparung_DD_rechteckig" filtered_wall_names = [ "10_AUS_WND_GK", "10_AUS_BDB_BST", "10_AUS_WND_DST", ] if correct_selection(selection): with db.Transaction("cur_nested_rvt_voids"): # create link instance of selected model link selected_link_type = selection[0] link_model_path = selected_link_type.GetExternalFileReference( ).GetAbsolutePath() print("found: {}".format(ConvertToUserPath(link_model_path))) rvt_link_type = RevitLinkType.Create(doc, link_model_path, rvt_link_opt) rvt_link = RevitLinkInstance.Create(doc, rvt_link_type.ElementId) rvt_doc = rvt_link.GetLinkDocument() rvt_file_name = op.split(rvt_doc.PathName)[-1] time_stamp = timestamp_now() # access local and linked generic models linked_gen_mods = Fec(rvt_doc).OfCategory(
"Ceilings": ceil_cat, "Generic Models": gen_cat } components = [ Label('Выберите категорию элементов для присоединения:'), ComboBox('categories', cats), Button('Select') ] form = FlexForm('Choose element category ', components) form.show() if form == False: sys.exit() else: selected_cat = form.values['categories'] obj_type = ObjectType.Element selection = ui.Selection().PickObjects(obj_type, "Choose elements to join") results = [] with db.Transaction('Multiple join'): for A in selected_cat: #print(A) for B in selection: #print(doc.GetElement(B.ElementId)) try: result = Autodesk.Revit.DB.JoinGeometryUtils.JoinGeometry( doc, A, doc.GetElement(B.ElementId)) results.append(result) except: pass
allmaterials = db.Collector(of_category="OST_Materials") allmaterials = [i for i in allmaterials if i.Name[:3] == "WWI"] # newPath = r"B:\Content\WWAS\Families\India\Furniture\Bulk" newPath = r"B:\Content\WWAS\Materials\India" def getAssetPath(mat): editMatScope = DB.Visual.AppearanceAssetEditScope(doc) editableMatAsset = editMatScope.Start(mat.AppearanceAssetId) assetMatProperty = editableMatAsset["generic_diffuse"] connectedMatAsset = assetMatProperty.GetSingleConnectedAsset() if connectedMatAsset: texturepath = connectedMatAsset.FindByName( DB.Visual.UnifiedBitmap.UnifiedbitmapBitmap ) return editMatScope, texturepath for mat in allmaterials: editMatScope, texturepath = getAssetPath(mat) if texturepath: with db.Transaction(): texturepath.Value = path.join( newPath, newPathDict[path.basename(texturepath.Value)] ) editMatScope.Commit(False) print(texturepath.Value)
walldir = fc * v.Normalize() up = XYZ.BasisZ viewdir = walldir.CrossProduct(up) t = Transform.Identity t.Origin = midpoint t.BasisX = walldir t.BasisY = up t.BasisZ = viewdir sectionBox = BoundingBoxXYZ() sectionBox.Transform = t sectionBox.Min = min # scope box bottom sectionBox.Max = max # scope box top with db.Transaction('Create Section'): # Create wall section view newSection = ViewSection.CreateSection(doc, viewFamilyTypeId, sectionBox) newSections.append(newSection) else: newSections = [] for wall in walls: # Determine section box lc = wall.Location line = lc.Curve p = line.GetEndPoint(0) q = line.GetEndPoint(1) v = p - q
import rpw from rpw import revit, db, ui, DB, UI from rpw.ui.forms import * from System import Array from System.Runtime.InteropServices import Marshal import sys import Autodesk e_a = str("\xe9") a_a = str("\xe0") # INSERT LINK # User select a revit file in folders filepath = select_file('Revit Model (*.rvt)|*.rvt') #start transaction with db.Transaction('insert link'): for path in filepath: linkpath = DB.ModelPathUtils.ConvertUserVisiblePathToModelPath( filepath) linkoptions = DB.RevitLinkOptions(relative=True) linkloadresult = DB.RevitLinkType.Create(revit.doc, linkpath, linkoptions) linkinstance = DB.RevitLinkInstance.Create(revit.doc, linkloadresult.ElementId) # # Insert from Base Point to Base Point # DB.RevitLinkInstance.MoveBasePointToHostBasePoint(linkinstance, resetToOriginalRotation = True) # # Insert from Origin To Origin # DB.RevitLinkInstance.MoveOriginToHostOrigin(linkinstance, resetToOriginalRotation = True) # ACQUIRE COORDINATES FROM REVIT LINK collector_maq = DB.FilteredElementCollector(revit.doc) linkInstances = collector_maq.OfClass(DB.RevitLinkInstance)
dwg_collector = db.Collector(of_class='ImportInstance', is_type=False) dwg_elements = dwg_collector.get_elements() # Collect views view_collector = db.ViewPlan.collect() # Set Color color_gray = DB.Color(80, 80, 80) # Create Class for Override ogs = DB.OverrideGraphicSettings().SetProjectionLineColor(color_gray) # Start transaction t = db.Transaction('Set Linked CADs to Gray') t.Start() # The SetElementOverrides method requires element ID and override instance for view in view_collector: for dwg in dwg_elements: dwg_id = dwg.Id dwg.Pinned = False view.SetElementOverrides(dwg_id, ogs) dwg.Pinned = True t.Commit()
plan_view = doc.GetElement(DB.ElementId(11335718)) rcp_view = doc.GetElement(DB.ElementId(11632340)) def duplicate_view(view, cropbox, name_suffix): duplicate_plan = doc.GetElement( view.Duplicate(DB.ViewDuplicateOption.AsDependent)) duplicate_plan.Name = sheet_name + name_suffix duplicate_plan.CropBoxActive = True duplicate_plan.CropBox = cropbox duplicate_plan.CropBoxVisible = False return duplicate_plan with db.Transaction("Duplicate View"): for sheet_name in all_sheet_names: # check if duplicate exists col_plan = db.Collector( of_class="ViewPlan", is_type=False, where=lambda x: sheet_name + "-Plan" in x.Name, ).unwrap() col_rcp = db.Collector( of_class="ViewPlan", is_type=False, where=lambda x: sheet_name + "-RCP" in x.Name, ).unwrap() # get cropbox region cropbox = DB.BoundingBoxXYZ() bbmin, bbmax = ui.Pick.pick_box(sheet_name)
for n in operated_rooms: area = 0 for unit in dataset: rooms_data = operated_rooms[n] for type in rooms_data: if type == str( db.Element(unit.floortype).parameters['BA_AI_Structure']. value) and unit.roomid == n: rooms_data[type] += unit.floorarea #print('True') else: #print('False') pass with db.Transaction('BA_FloorFinishing Parameters'): for key in operated_rooms: a = operated_rooms[key] n = 1 area_all = '' type_all = '' areatext = '' typetext = '' for k in a: areatext = str(n) + ". " + str(round(a[k], 2)) + " м2 \r\n" typetext = str(n) + ". " + str(k) + "\r\n" n += 1 area_all += areatext type_all += typetext db.Element( doc.GetElement(ElementId(int(key)))
#opening_boundary = room.GetBoundarySegments(room_boundary_options)[1] room_boundary = room.GetBoundarySegments(room_boundary_options)[0] all_boundaries = room.GetBoundarySegments(room_boundary_options) n = 0 for bound_set in all_boundaries: all_boundaries1.append( room.GetBoundarySegments(room_boundary_options)[n]) n += 1 all_boundaries1.pop(0) new_floor = NewFloor(floor_type_id=floor_type_id, boundary=room_boundary, level_id=room_level_id, count=r, opening_boundary=all_boundaries1, openings=n - 1, room_offset1=room_offset1, room_name=room_name, room_number=room_number, room_id=room_id) new_floors.append(new_floor) c = 0 #Create floor for new_floor in new_floors: with db.Transaction('Create Floor'): make_floor(new_floor) c += 1 if form.values['checkbox2'] and new_floor.openings != 0: for i in new_floor.opening_boundary: with db.Transaction('Create Openeing'): make_opening(new_floor)
def startTransaction(self, tname): #Generate transaction and start it self.transaction = db.Transaction(tname) self.transaction.Start()
def run(m_set): with db.Transaction('*BA* Create Shared Params'): create_shared_param(m_set.t_param_option, m_set.t_catset, m_set.t_parameters, m_set.t_group)