def getRailCurve(element_dict): refArray = DB.ReferenceArray() # refArray.Append(railCurve.Reference) for key in element_dict: print("Rail Detected\nELEMENT ID No. : " + str(key) \ + "\nElement String Representation : " + str(element_dict[key])) # refArray.Append(element_dict[key].GetPath().Reference()) railCurve = element_dict[key].GetPath() for curve in railCurve: # refArray.Append(curve.Reference) print(curve.Reference) # print(str(element_dict[key].HostRailingId)) # HostRail = element_dict[key].HostRailingId # HostParams = doc.GetElement(HostRail).Parameters # for param in HostParams: # print("Host Rail PARAMETER NAME : " + param.Definition.Name) # if param.HasValue: # try: # print("Value : " + param.AsString()) # except: # print("Value : " + param.ToString()) # for path in reversed(railCurve): # refArray.Append(path.Reference) # refArray.Append(railCurve.ReferenceArray) refArray.Append(DB.Reference(element_dict[key])) return railCurve, refArray
# set the active Revit application and document app = __revit__.Application doc = __revit__.ActiveUIDocument.Document uidoc = __revit__.ActiveUIDocument active_view = doc.ActiveView with forms.WarningBar(title="Pick levels"): try: levels = uidoc.Selection.PickElementsByRectangle(CustomISelectionFilter(DB.BuiltInCategory.OST_Levels), "Select Levels") except: forms.alert("Failed", ok=True, exitscript=True) ref_array = DB.ReferenceArray() s = "" # Terminate early if no levels were selected if not levels: forms.alert("No grids selected.", ok=True, exitscript=True) # Get all geometry reference lines for lvl in levels: if lvl: ref_array.Append(lvl.GetPlaneReference()) # Create a sketch plane to draw the dimensions in with revit.Transaction("Dim Grids Sketch Plane", doc=doc): origin = active_view.Origin direction = active_view.ViewDirection
def createBBox(geometry_curve, referenceArray): tx = DB.Transaction(doc, "test") tx.Start() railCurve = [] x_val = [] y_val = [] z_val = [] iter = 0 refArray1 = DB.ReferenceArray() refArray2 = DB.ReferenceArray() # refArray2.Append(DB.Reference(geometry_curve)) # refArray1.Append(geometry_curve.Reference) for curve in geometry_curve: print(str(curve.Length) + " Ft.") # print(curve.ToString()) refArray1.Append(curve.Reference) # refArray2.Append(DB.Reference(curve)) # c_line = DB.Line.CreateBound(curve.GetEndPoint(0), curve.GetEndPoint(1)) # print("CLINE REF") # print(c_line.Reference) # railCurve.append(c_line) # print(curve.GetEndPoint(0)) x_val.append(curve.GetEndPoint(0).X) # print("X-coordinate added : " + str(curve.GetEndPoint(0).X)) x_val.append(curve.GetEndPoint(1).X) # print("X-coordinate added : " + str(curve.GetEndPoint(1).X)) y_val.append(curve.GetEndPoint(0).Y) # print("Y-coordinate added : " + str(curve.GetEndPoint(0).Y)) y_val.append(curve.GetEndPoint(1).Y) # print("Y-coordinate added : " + str(curve.GetEndPoint(1).Y)) z_val.append(curve.GetEndPoint(0).Z) # print("Z-coordinate added : " + str(curve.GetEndPoint(0).Z)) z_val.append(curve.GetEndPoint(1).Z) # print("Z-coordinate added : " + str(curve.GetEndPoint(1).Z)) # newLine = None try: newLine = doc.Create.NewDetailCurve(view, curve) refArray2.Append(newLine.GeometryCurve.Reference) # doc.Create.NewDimension(view, newLine, referenceArray) # refArray.Append(curve) print("Detail Line Drawn") # doc.Create.NewDimension(view, curve, newRefArr) except: print("Rail Segment not visible in plane") next # refArray.Append(curve.Reference) # try: # doc.Create.NewDimension(view, curve, referenceArray) # print("New Dimension Created") # except: # print("RefArrayItem Ignored") x_max = max(x_val) # print("X Max :" + str(x_max)) # x_max_index = x_value.index(x_max) x_min = min(x_val) # print("X Min :" + str(x_min)) y_max = max(y_val) # print("Y Max :" + str(y_max)) y_min = min(y_val) # print("Y Min :" + str(y_min)) z_max = max(z_val) # print("Z Max :" + str(z_max)) z_min = min(z_val) print(str(refArray2.Size)) iter = 0 # for curve in geometry_curve: try: doc.Create.NewDimension(view, geometry_curve[2], refArray2) except: print("unable to generage dimension") # plane = doc.Create.NewReferencePlane(DB.XYZ(x_min, y_min, 0), DB.XYZ(x_max, y_max, 0), DB.XYZ(0,0,z_max), view) # for curve in geometry_curve: # detCurv = doc.Create.NewDetailCurve(view, curve) # skplane = doc.FamilyCreate.NewSketchPlane(plane) # Create Line Vertices: # lnStart = DB.XYZ(0,0,0) # lnEnd = DB.XYZ(10,10,0) # curve = app.Create.NewLine(lnStart, lnEnd, True) # crv = doc.FamilyCreate.NewModelCurve(curve, skplane) # print("Z Min :" + str(z_min)) # w = (x_max - x_min) # d = (y_max - y_min) # h = (z_max - z_min) # if d < 10: # d = 10 # if w < 10: # w = 10 # maxPt = (w,h,0) # minPt = (-w, -h, -d) # bbox = doc.GetElement(geometry_curve).BoundingBoxXYZ() # bbox.Enabled = True # bbox.Max = maxPt # bbox.Min = minPt # trans = Transform.Identity # midPt = .5 * (bbox.Max + bbox.Min) # trans.Origin = midPt # print(str(midPt)) # dim = DB.Dimension(doc.ActiveView,) tx.Commit()