Exemplo n.º 1
0
def unpickle_line_list(linelist):
    curveloop = DB.CurveLoop()
    for line in linelist:
        p1 = DB.XYZ(line[0][0], line[0][1], 0)
        p2 = DB.XYZ(line[1][0], line[1][1], 0)
        curveloop.Append(DB.Line.CreateBound(p1, p2))

    return curveloop
Exemplo n.º 2
0
def unpickle_line_list(all_cloops_data):
    all_cloops = []
    for cloop_lines in all_cloops_data:
        curveloop = DB.CurveLoop()
        for line in cloop_lines:
            p1 = DB.XYZ(line[0][0], line[0][1], 0)
            p2 = DB.XYZ(line[1][0], line[1][1], 0)
            curveloop.Append(DB.Line.CreateBound(p1, p2))

        all_cloops.append(curveloop)

    return all_cloops
Exemplo n.º 3
0
def get_room_bound(r):
    room_boundaries = DB.CurveLoop()
    # get room boundary segments
    room_segments = r.GetBoundarySegments(DB.SpatialElementBoundaryOptions())
    # iterate through loops of segments and add them to the array
    outer_loop = room_segments[0]
    # for curve in outer_loop:
    curve_loop = [s.GetCurve() for s in outer_loop]
    open_ends = get_open_ends(curve_loop)
    if open_ends:
        return None
    for curve in curve_loop:
        # try:
        room_boundaries.Append(curve)
        # except Exceptions.ArgumentException:
        # print (curve)
    return room_boundaries
Exemplo n.º 4
0
def make_filledregion_element(base_point, fr_type):
    cloop = DB.CurveLoop()
    cloop.Append(
        DB.Line.CreateBound(
            DB.XYZ(base_point.X, base_point.Y, base_point.Z),
            DB.XYZ(base_point.X + 1, base_point.Y, base_point.Z)))
    cloop.Append(
        DB.Line.CreateBound(
            DB.XYZ(base_point.X + 1, base_point.Y, base_point.Z),
            DB.XYZ(base_point.X + 1, base_point.Y + DIRECTION, base_point.Z)))
    cloop.Append(
        DB.Line.CreateBound(
            DB.XYZ(base_point.X + 1, base_point.Y + DIRECTION, base_point.Z),
            DB.XYZ(base_point.X, base_point.Y + DIRECTION, base_point.Z)))
    cloop.Append(
        DB.Line.CreateBound(
            DB.XYZ(base_point.X, base_point.Y + DIRECTION, base_point.Z),
            DB.XYZ(base_point.X, base_point.Y, base_point.Z)))

    DB.FilledRegion.Create(revit.doc, fr_type.Id, revit.activeview.Id,
                           List[DB.CurveLoop]([cloop]))
Exemplo n.º 5
0
    def zero_cropbox(view):
        """Generates a rectangular curve loop in model coordinates
        (0,0; 0,1; 1,1; 1,0) parallel to a provided view.

        Args:
            view (DB.View): view, to which the curves should be projected

        Returns:
            DB.CurveLoop: result curve loop
        """
        # model points (lower left and upper right corners)
        p1 = DB.XYZ(0, 0, 0)
        p3 = DB.XYZ(1, 1, 1)
        # uv's of model points projected to a view
        uv1 = revit.units.project_to_viewport(p1, view)
        uv3 = revit.units.project_to_viewport(p3, view)
        # uv's of upper left and lower right corners of rectangle
        uv2 = DB.UV(uv1.U, uv3.V)
        uv4 = DB.UV(uv3.U, uv1.V)
        # project all points back to model coordinates
        p2 = revit.units.project_to_world(uv2, view)
        p4 = revit.units.project_to_world(uv4, view)
        p1 = revit.units.project_to_world(
            revit.units.project_to_viewport(p1, view),
            view
            )
        p3 = revit.units.project_to_world(
            revit.units.project_to_viewport(p3, view),
            view
            )
        # create lines between points
        l1 = DB.Line.CreateBound(p1, p2)
        l2 = DB.Line.CreateBound(p2, p3)
        l3 = DB.Line.CreateBound(p3, p4)
        l4 = DB.Line.CreateBound(p4, p1)
        # generate curve loop
        crv_loop = DB.CurveLoop()
        for crv in (l1, l2, l3, l4):
            crv_loop.Append(crv)
        return crv_loop
Exemplo n.º 6
0
            # set level offset
            change_offset = new_roof.get_Parameter(DB.BuiltInParameter.ROOF_LEVEL_OFFSET_PARAM).Set(level_offset)

        # for EXTRUSION ROOF: create new roof using offset profile
        elif isinstance(roof, DB.ExtrusionRoof):
            try:
                profile = roof.GetProfile()

                # get profile plane
                e1 = profile[0].GeometryCurve.GetEndPoint(0)
                e2 = profile[0].GeometryCurve.GetEndPoint(1)
                h = DB.XYZ(e1.X, e1.Y, 100)
                plane = DB.Plane.CreateByThreePoints(e1, e2, h)

                # use a curve loop to offset the profile polycurve
                curve_loop = DB.CurveLoop()
                for model_curve in profile:
                    curve_loop.Append(model_curve.GeometryCurve)

                offset_distance = get_ins_position(roof_type) + ins_layer_width / 2
                offset_loop = DB.CurveLoop.CreateViaOffset(curve_loop, offset_distance, plane.Normal)

                # store new curves in a curve array
                new_curves = DB.CurveArray()
                for curve in offset_loop:
                    new_curves.Append(curve)

                # create profile reference plane
                ref_plane = doc.Create.NewReferencePlane2(e1, e2, h, revit.active_view)

                # get original roof parameters
Exemplo n.º 7
0
 def deserialize(self):
     crv_loop = DB.CurveLoop()
     for crv in self.curves:
         crv_loop.Append(crv.deserialize())
     return crv_loop
Exemplo n.º 8
0
# dims and scale
scale = float(view.Scale) / 100
w = convert_length_to_internal(box_width) * scale
h = convert_length_to_internal(box_height) * scale
text_offset = 1 * scale
shift = (convert_length_to_internal(box_offset + box_height)) * scale

with forms.WarningBar(title="Pick Point"):
    try:
        pt = revit.uidoc.Selection.PickPoint()
    except Exceptions.OperationCanceledException:
        forms.alert("Cancelled", ok=True, exitscript=True)

# create rectrangle
crv_loop = DB.CurveLoop()

p1 = DB.XYZ(pt.X, pt.Y, 0)
p2 = DB.XYZ(pt.X + w, pt.Y, 0)
p3 = DB.XYZ(pt.X + w, pt.Y + h, 0)
p4 = DB.XYZ(pt.X, pt.Y + h, 0)

# create lines between points
l1 = DB.Line.CreateBound(p1, p2)
l2 = DB.Line.CreateBound(p2, p3)
l3 = DB.Line.CreateBound(p3, p4)
l4 = DB.Line.CreateBound(p4, p1)

rectangle = [l1, l2, l3, l4]

with revit.Transaction("Draw Filled Regions"):