def setUpModule(): logger.title('SETTING UP TESTS...') logger.title('REVIT {}'.format(version)) collector = DB.FilteredElementCollector(doc) walls = collector.OfClass(DB.Wall).ToElements() if walls: t = DB.Transaction(doc, 'Delete Walls') t.Start() for wall in walls: doc.Delete(wall.Id) t.Commit() collector = DB.FilteredElementCollector(doc) level = collector.OfClass(DB.Level).FirstElement() pt1 = DB.XYZ(0, 0, 0) pt2 = DB.XYZ(20, 20, 0) wall_line = DB.Line.CreateBound(pt1, pt2) t = DB.Transaction(doc, 'Add Wall') t.Start() wall = DB.Wall.Create(doc, wall_line, level.Id, False) t.Commit() global wall_int wall_int = wall.Id.IntegerValue logger.debug('WALL CREATED.') collector = DB.FilteredElementCollector(doc) desk = collector.OfCategory( DB.BuiltInCategory.OST_Furniture).FirstElement() if desk: with rpw.Transaction('Delete Desk'): f = desk.Family doc.Delete(f.Id) ################################################## # Load Fixture Family and Place Instances ################################################## logger.debug('LOADING SYMBOl') family_path = os.path.join(test_dir, 'fixtures', 'desk.rfa') if not os.path.exists(family_path): raise Exception('Could not find fixture: {}'.format(family_path)) logger.debug('LOADING SYMBOl') family = clr.Reference[DB.Family]() with rpw.Transaction('Load Family'): doc.LoadFamily(family_path, family) family = family.Value symbols = [] for family_symbol in family.Symbols: symbols.append(family_symbol) with rpw.Transaction('Place Instances'): level = DB.FilteredElementCollector(doc).OfClass( DB.Level).WhereElementIsNotElementType().FirstElement() doc.Create.NewFamilyInstance(DB.XYZ(5, 0, 0), symbols[0], level, DB.Structure.StructuralType.NonStructural) doc.Create.NewFamilyInstance(DB.XYZ(10, 4, 0), symbols[0], level, DB.Structure.StructuralType.NonStructural) doc.Create.NewFamilyInstance(DB.XYZ(15, 8, 0), symbols[1], level, DB.Structure.StructuralType.NonStructural)
def wrapped(*args, **kwargs): trans = DB.Transaction(doc, '11') trans.Start() res = func(*args, **kwargs) trans.Commit() return res
def delete_all_walls(): collector = DB.FilteredElementCollector(doc) walls = collector.OfClass(DB.Wall).ToElements() if walls: t = DB.Transaction(doc, 'Delete Walls') t.Start() for wall in walls: doc.Delete(wall.Id) t.Commit()
def make_wall(): collector = DB.FilteredElementCollector(doc) level = collector.OfClass(DB.Level).FirstElement() pt1 = DB.XYZ(0, 0, 0) pt2 = DB.XYZ(20, 20, 0) wall_line = DB.Line.CreateBound(pt1, pt2) t = DB.Transaction(doc, 'Add Wall') t.Start() wall = DB.Wall.Create(doc, wall_line, level.Id, False) t.Commit() return wall
def __init__(self, name=None, clear_after_rollback=False, show_error_dialog=False): db_transaction = \ DB.Transaction(doc, name if name else DEFAULT_ACTION_NAME) super(Transaction, self).__init__(db_transaction, enforce_type=DB.Transaction) self._fail_hndlr_ops = self._wrapped_object.GetFailureHandlingOptions() self._fail_hndlr_ops.SetClearAfterRollback(clear_after_rollback) self._fail_hndlr_ops.SetForcedModalHandling(show_error_dialog) self._wrapped_object.SetFailureHandlingOptions(self._fail_hndlr_ops)
def __init__(self, name=None, doc=revit.doc): if name is None: name = 'RPW Transaction' super(Transaction, self).__init__(DB.Transaction(doc, name)) self.transaction = self._revit_object
def __init__(self, name=None): if name is None: name = 'RPW Transaction' self.transaction = DB.Transaction(doc, name)
def setUp(self): self.transaction = DB.Transaction(doc, 'Test') self.transaction.Start()