Best Python code snippet using ATX
anno.py
Source:anno.py
1"""Functions related to annotation."""2from Autodesk.Revit.DB import BuiltInCategory3from Autodesk.Revit.DB import BuiltInParameter4from Autodesk.Revit.DB import FamilyInstance5from Autodesk.Revit.DB import FilteredElementCollector6from Autodesk.Revit.DB import FilteredWorksetCollector7from Autodesk.Revit.DB import SpatialElementTag8from Autodesk.Revit.DB import WorksetKind9from lib import transaction10def fix_room_tags(doc):11 """Find room tags that are outside their room and move them back"""12 room_tags = FilteredElementCollector(13 doc14 ).OfClass(15 SpatialElementTag16 ).OfCategory(17 BuiltInCategory.OST_RoomTags18 )19 with transaction(doc, 'Move room tags'):20 count = 021 for tag in room_tags:22 room = tag.Room23 if not room:24 continue25 box = room.get_BoundingBox(None)26 if not box:27 continue28 tag_point = tag.Location.Point29 tag_is_in_room = tag_point.X > box.Min.X and \30 tag_point.X < box.Max.X and \31 tag_point.Y > box.Min.Y and \32 tag_point.Y < box.Max.Y33 if not tag_is_in_room:34 tag.Location.Move(room.Location.Point - tag.Location.Point)35 count += 136 print(room.Level.Name, room.Number)37 print('{} room tags moved'.format(count))38def create_text_styles(doc):39 black = int('000000', 16)40 blue = int('ff0000', 16)41 std_sizes = [42 ('1.8mm', 1.8, black),43 ('1.8mm Blue', 1.8, blue),44 ('2.0mm', 2.0, black),45 ('2.5mm', 2.5, black),46 ('3.5mm', 3.5, black),47 ('5.0mm', 5.0, black),48 ('7.0mm', 7.0, black),49 ('10.0mm', 10, black),50 ]51 #size_pairs = [std_sizes[i:i + 2] for i in range(len(std_sizes))]52 #if len(size_pairs[-1]) == 1:53 # size_pairs = size_pairs[:-1]54 text_types = FilteredElementCollector(doc).OfClass(TextNoteType)55 text_type = list(text_types)[0]56 with transaction(doc, 'Create text types'):57 for name, size, color in std_sizes:58 try:59 elem = text_type.Duplicate(name)60 elem.LookupParameter('Text Font').Set('Arial Narrow')61 elem.LookupParameter('Text Size').Set(size / MM)62 elem.LookupParameter('Color').Set(color)63 print(elem)64 except Exception as e:65 print(e)66 continue67 #for t in text_types:68 # size_in_mm = t.LookupParameter('Text Size').AsValueString()69 # size = float(size_in_mm.rstrip(' mm'))70 # print(size)71 # for lower, upper in size_pairs:72 # if lower < size and size < upper:73 # print('Change {} to {}'.format(size, lower))74def create_text(doc):75 type_id = doc.GetDefaultElementTypeId(ElementTypeGroup.TextNoteType)76 x = 077 y = 078 with transaction(doc, 'Create text'):79 text_types = FilteredElementCollector(doc).OfClass(TextNoteType)80 for tt in text_types:81 note = TextNote.Create(82 doc,83 doc.ActiveView.Id,84 XYZ(x, y, 0),85 tt.LookupParameter('Type Name').AsString(),86 tt.Id);...
foothold_manager.py
Source:foothold_manager.py
1from math import atan, cos2class FootholdManager:3 def __init__(self):4 self.footholds = []5 def add(self, foothold):6 self.footholds.append(foothold)7 def find_below(self, tag_point):8 matches = []9 for foothold in self.footholds:10 if foothold.x1 <= tag_point.x and foothold.x2 >= tag_point.x:11 matches.append(foothold)12 for foothold in matches:13 if not foothold.wall and foothold.y1 != foothold.y2:14 s1 = foothold.y2 - foothold.y115 s2 = foothold.x2 - foothold.x116 s4 = tag_point.x - foothold.x117 alpha = atan(s2 / s1)18 beta = atan(s1 / s2)19 s5 = cos(alpha) * (s4 / cos(beta))20 if foothold.y2 < foothold.y2:21 calcy = foothold.y1 - int(s5)22 else:23 calcy = foothold.y1 + int(s5)24 if calcy >= tag_point.y:25 return foothold26 elif not foothold.wall and foothold.y1 >= tag_point.y:27 return foothold...
testResult.py
Source:testResult.py
1def test(path):2 file = open(path)3 tags = 0#被æ è®°åçæ»æ°4 right = 0#æ è®°æ£ç¡®çæ°ç®5 precisionTags = 0#æææ è®°åºæ¥çæ°ç®6 recallTags = 0#åºè¯¥è¢«æ è®°çåçæ°ç®7 for line in file:8 line = line.strip()9 if(len(line)==0):10 continue11 tags += 112 _word, tag_real, tag_point = line.split()13 if tag_point == tag_real and tag_point != 'O':14 right += 115 if tag_point != 'O':#被æ 注çæ°æ®16 precisionTags += 117 if tag_real != 'O':#åºè¯¥è¢«æ 注çæ°æ®18 recallTags += 119 precision = float(right)/precisionTags20 recall = float(right)/recallTags21 f1Score = 2*precision*recall/(precision+recall)22 print("precision:%f, recall:%f, F1Score:%f\n"%(precision,recall,f1Score))...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!