Exemplo n.º 1
0
def reorient():
    face = revit.pick_face()

    if face:
        with revit.Transaction('Orient to Selected Face'):
            # calculate normal
            if HOST_APP.is_newer_than(2015):
                normal_vec = face.ComputeNormal(DB.UV(0, 0))
            else:
                normal_vec = face.Normal

            # create base plane for sketchplane
            if HOST_APP.is_newer_than(2016):
                base_plane = \
                    DB.Plane.CreateByNormalAndOrigin(normal_vec, face.Origin)
            else:
                base_plane = DB.Plane(normal_vec, face.Origin)

            # now that we have the base_plane and normal_vec
            # let's create the sketchplane
            sp = DB.SketchPlane.Create(revit.doc, base_plane)

            # orient the 3D view looking at the sketchplane
            revit.active_view.OrientTo(normal_vec.Negate())
            # set the sketchplane to active
            revit.uidoc.ActiveView.SketchPlane = sp

        revit.uidoc.RefreshActiveView()
Exemplo n.º 2
0
def orientsectionbox(view):
    try:
        face = revit.pick_face()
        box = view.GetSectionBox()
        norm = face.ComputeNormal(DB.UV(0, 0)).Normalize()
        boxNormal = box.Transform.Basis[0].Normalize()
        angle = norm.AngleTo(boxNormal)
        axis = DB.XYZ(0, 0, 1.0)
        origin = DB.XYZ(box.Min.X + (box.Max.X - box.Min.X) / 2,
                        box.Min.Y + (box.Max.Y - box.Min.Y) / 2, 0.0)
        if norm.Y * boxNormal.X < 0:
            rotate = \
                DB.Transform.CreateRotationAtPoint(axis, Math.PI / 2 - angle,
                                                   origin)
        else:
            rotate = DB.Transform.CreateRotationAtPoint(axis, angle, origin)
        box.Transform = box.Transform.Multiply(rotate)
        with revit.Transaction('Orient Section Box to Face'):
            view.SetSectionBox(box)
            revit.uidoc.RefreshActiveView()
    except Exception:
        pass
Exemplo n.º 3
0
"""Pickup painted surface material and apply to other surfaces."""
#pylint: disable=E0401,C0111,W0613,C0103,broad-except
from pyrevit import revit, UI
from pyrevit import forms

with forms.WarningBar(title='Pick source object:'):
    source_face = revit.pick_face()

if source_face:
    material_id = source_face.MaterialElementId
    material = revit.doc.GetElement(material_id)

    with forms.WarningBar(title='Pick faces to match materials:'):
        while True:
            try:
                dest_ref = \
                    revit.uidoc.Selection.PickObject(
                        UI.Selection.ObjectType.Face
                        )
            except Exception:
                break

            if not dest_ref:
                break

            dest_element = revit.doc.GetElement(dest_ref)
            dest_face = dest_element.GetGeometryObjectFromReference(dest_ref)

            with revit.Transaction('Match Painted Materials'):
                revit.doc.Paint(dest_element.Id, dest_face, material_id)
Exemplo n.º 4
0
                                            DB.XYZ(0, 0, 1))
    result = []
    for i in NewCurve.GetCurveLoopIterator():
        result.append(i)
    return result


def EdgeArrayArrayToList(EdgeArray):
    _List = List[DB.Curve]()
    for i in EdgeArray:
        for c in i:
            _List.Add(c.AsCurve())
    return _List


picked = revit.pick_face()

#for i in picked.get_Geometry(DB.Options ()):
#for c in i.GetInstanceGeometry():
#	print(c)
#	c=i


class BAT_Room:
    def __init__(self, Room):
        self.Room = Room
        self.WrapedRoom = db.Element(self.Room)
        self.RoomLevelId = self.Room.Level.Id
        self.RoomLevel = self.Room.Level

    @property