def print_arc(cls, point, plane=None, radius=0.3): doc = __revit__.ActiveUIDocument.Document active_view = doc.ActiveView creDoc = __revit__.ActiveUIDocument.Document.Create if not plane: plane = Plane.CreateByNormalAndOrigin(active_view.ViewDirection, point) sketchPlane = SketchPlane.Create(doc, plane) new_arc = Arc.Create(point, radius, 0, pi * 2, plane.XVec, plane.YVec) m_line = creDoc.NewModelCurve(new_arc, sketchPlane) return m_line
def print_line(cls, p1, p2, plane=None, radius=0.3, color='еленая'): doc = __revit__.ActiveUIDocument.Document active_view = doc.ActiveView creDoc = __revit__.ActiveUIDocument.Document.Create if not plane: vect = p2 - p1 p3 = p1 + XYZ_multiply(active_view.ViewDirection, vect).Normalize() plane = Plane.CreateByThreePoints(p1, p2, p3) sketchPlane = SketchPlane.Create(doc, plane) new_line = Line.CreateBound(p1, p2) m_line = creDoc.NewModelCurve(new_line, sketchPlane) m_line.LineStyle = cls.get_line_style(color=color) return m_line
See this link for a copy of the GNU General Public License protecting this package. https://github.com/eirannejad/pyRevit/blob/master/LICENSE """ __doc__ = 'Reorients the current 3D view camera, perpendicular to the selected face. ' \ 'This tool will set a sketch plane over the selected face for 3d drawing.' __window__.Close() from Autodesk.Revit.DB import Transaction, View3D, SketchPlane, Plane from Autodesk.Revit.UI.Selection import ObjectType uidoc = __revit__.ActiveUIDocument doc = __revit__.ActiveUIDocument.Document selection = [doc.GetElement(elId) for elId in __revit__.ActiveUIDocument.Selection.GetElementIds()] curview = uidoc.ActiveView try: ref = uidoc.Selection.PickObject(ObjectType.Face) el = doc.GetElement(ref.ElementId) face = el.GetGeometryObjectFromReference(ref) if isinstance(curview, View3D): t = Transaction(doc, 'Orient to Selected Face') t.Start() sp = SketchPlane.Create(doc, Plane(face.Normal, face.Origin)) curview.OrientTo(face.Normal.Negate()) uidoc.ActiveView.SketchPlane = sp uidoc.RefreshActiveView() t.Commit() except: pass
# if c > 1: # Лучевая схема if 2 > 1: # Ортогональная схема sublist = [] for i, p in enumerate(path): try: start, end = path[i], path[i + 1] line = Line.CreateBound( start, end ) #https://forums.autodesk.com/t5/revit-api-forum/how-to-crete-3d-modelcurves-to-avoid-exception-curve-must-be-in/td-p/8355936 direction = line.Direction x, y, z = direction.X, direction.Y, direction.Z normal = XYZ(z - y, x - z, y - x) # normal = XYZ.BasisZ.CrossProduct(line.Direction) plane = Plane.CreateByNormalAndOrigin(normal, start) sketchPlane = SketchPlane.Create(doc, plane) modelCurve = doc.Create.NewModelCurve(line, sketchPlane) # sublist.append(Line().ByStartPointEndPoint(path[i], path[i + 1])) sublist.append(modelCurve) except IndexError: continue lines.append(sublist) else: sublist = [] sublist.append(Line.ByStartPointEndPoint(path[0], path[-1])) lines.append(sublist) OUT = cirs, panels, elements, dividedWires, lengthsWithReserve, discreteLengths, naimenovanie, marka2, sposobRaschyota, kolichestvo, edinitcyIzmereniia, electricalEquipment = FilteredElementCollector(doc).OfCategory(