Exemplo n.º 1
0
def copy_view_range():
    """Copy view range from source views to target views"""
    prompt_text = "Select one or multiple source views"
    with forms.WarningBar(title=prompt_text):
        source_list = forms.select_views(
            title=prompt_text, filterfunc=lambda x: isinstance(x, ViewPlan))

    if not source_list:
        return False

    prompt_text = "Select target views"
    with forms.WarningBar(title=prompt_text):
        target_list = forms.select_views(
            title=prompt_text, filterfunc=lambda x: isinstance(x, ViewPlan))

    if not target_list:
        return True

    with rpw.db.Transaction("Copy view range", doc):
        logger.info("VIEW RANGE applied from following source to target :")
        if len(source_list) == 1:
            view_range = source_list[0].GetViewRange()
            for target in target_list:  # type:ViewPlan
                target.SetViewRange(view_range)
                logger.info("{} -> {}".format(source_list[0].Name,
                                              target.Name))
        else:
            for source, target in zip(source_list,
                                      target_list):  # type:ViewPlan, ViewPlan
                target.SetViewRange(source.GetViewRange())
                logger.info("{} -> {}".format(source.Name, target.Name))
    return True
Exemplo n.º 2
0
def connect_to():
    # Prompt user to select elements and points to connect
    try:
        with forms.WarningBar(title="Pick element to move and connect"):
            reference = uidoc.Selection.PickObject(ObjectType.Element, NoInsulation(), "Pick element to move")
    except Exceptions.OperationCanceledException:
        return False

    try:
        moved_element = doc.GetElement(reference)
        moved_point = reference.GlobalPoint
        with forms.WarningBar(title="Pick element to be connected to"):
            reference = uidoc.Selection.PickObject(ObjectType.Element, NoInsulation(),
                                                   "Pick element to be connected to")
        target_element = doc.GetElement(reference)
        target_point = reference.GlobalPoint
    except Exceptions.OperationCanceledException:
        return True

    # Get associated unused connectors
    moved_connector = get_connector_closest_to(get_connector_manager(moved_element).UnusedConnectors,
                                               moved_point)
    target_connector = get_connector_closest_to(get_connector_manager(target_element).UnusedConnectors,
                                                target_point)
    try:
        if moved_connector.Domain != target_connector.Domain:
            rpw.ui.forms.Alert("You picked 2 connectors of different domain. Please retry.", header="Domain Error")
            return True
    except AttributeError:
        rpw.ui.forms.Alert("It looks like one of the objects have no unused connector", header="AttributeError")
        return True

    # Retrieves connectors direction and catch attribute error like when there is no unused connector available
    try:
        moved_direction = moved_connector.CoordinateSystem.BasisZ
        target_direction = target_connector.CoordinateSystem.BasisZ
    except AttributeError:
        rpw.ui.forms.Alert("It looks like one of the objects have no unused connector", header="AttributeError")
        return True

    # Move and connect
    with rpw.db.Transaction("Connect elements"):
        # If connector direction is same, rotate it
        angle = moved_direction.AngleTo(target_direction)
        if angle != pi:
            if angle == 0:
                vector = moved_connector.CoordinateSystem.BasisY
            else:
                vector = moved_direction.CrossProduct(target_direction)
            try:
                line = Line.CreateBound(moved_point, moved_point+vector)
                moved_element.Location.Rotate(line, angle - pi)
            # Revit don't like angle and distance too close to 0
            except Exceptions.ArgumentsInconsistentException:
                logger.debug("Vector : {} ; Angle : {}".format(vector, angle))
        # Move element in order match connector position
        moved_element.Location.Move(target_connector.Origin - moved_connector.Origin)
        # Connect connectors
        moved_connector.ConnectTo(target_connector)
    return True
Exemplo n.º 3
0
def new_transition():
    # Prompt user to select elements and points to connect
    try:
        message = "Pick element 1 (the connector moves depending on transition length)"
        with forms.WarningBar(title=message):
            reference = uidoc.Selection.PickObject(ObjectType.Element,
                                                   NoInsulation(), message)
    except Exceptions.OperationCanceledException:
        return False

    try:
        element1 = doc.GetElement(reference)
        xyz1 = reference.GlobalPoint

        message = "Pick element 2 (static)"
        with forms.WarningBar(title=message):
            reference = uidoc.Selection.PickObject(ObjectType.Element,
                                                   NoInsulation(), message)
        element2 = doc.GetElement(reference)
        xyz2 = reference.GlobalPoint
    except Exceptions.OperationCanceledException:
        return True

    # Get associated unused connectors
    connector1 = get_connector_closest_to(
        get_connector_manager(element1).UnusedConnectors, xyz1)
    connector2 = get_connector_closest_to(
        get_connector_manager(element2).UnusedConnectors, xyz2)
    try:
        if connector1.Domain != connector2.Domain:
            rpw.ui.forms.Alert(
                "You picked 2 connectors of different domain. Please retry.",
                header="Domain Error")
            return True
    except AttributeError:
        rpw.ui.forms.Alert(
            "It looks like one of the objects have no unused connector",
            header="AttributeError")
        return True

    if not connector1 and not connector2:
        rpw.ui.forms.Alert(
            "It looks like one of the objects have no unused connector",
            header="AttributeError")
        return True

    with rpw.db.Transaction("Create transition"):
        doc.Create.NewTransitionFitting(connector1, connector2)
    return True
Exemplo n.º 4
0
def element_selection():
    try:
        with forms.WarningBar(title="Pick reference element"):
            reference = uidoc.Selection.PickObject(ObjectType.Element,
                                                   "Pick reference element")
    except Exceptions.OperationCanceledException:
        return False

    try:
        element1 = doc.GetElement(reference)
        with forms.WarningBar(title="Pick target element"):
            reference = uidoc.Selection.PickObject(ObjectType.Element,
                                                   "Pick target element")
        element2 = doc.GetElement(reference)

        logger.debug("ELEMENTS \n 1: {} \n 2: {}".format(element1, element2))

        v1 = direction(element1)
        v2 = direction(element2)

        xy_v1 = XYZ(v1.X, v1.Y, 0)  # type: XYZ
        xy_v2 = XYZ(v2.X, v2.Y, 0)  # type: XYZ

        angle = xy_v2.AngleTo(xy_v1)
        if angle > pi / 2:
            angle = angle - pi
        normal = xy_v2.CrossProduct(xy_v1)

        logger.debug("ANGLE : {}".format(angle))
        logger.debug("NORMAL : {}".format(normal))
        logger.debug("DIRECTION \n 1: {} \n 2: {}".format(
            direction(element1), direction(element2)))

        axis = Line.CreateBound(origin(element2), origin(element2) + normal)

        # Need to rotate elevation marker if it is an elevation
        try:
            if get_view_from(element2).ViewType == ViewType.Elevation:
                element2 = get_elevation_marker(element2)
        except AttributeError:
            pass

        with rpw.db.Transaction("Make parallel", doc):
            element2.Location.Rotate(axis, angle)

        return True
    except Exceptions.OperationCanceledException:
        return True
Exemplo n.º 5
0
def disconnect_object():
    # Prompt user to select elements and points to connect
    try:
        with forms.WarningBar(title="Pick element to disconnet"):
            reference = uidoc.Selection.PickObject(ObjectType.Element,
                                                   NoInsulation(),
                                                   "Pick element to move")
    except Exceptions.OperationCanceledException:
        return False

    try:
        selected_element = doc.GetElement(reference)
        connectors = get_connector_manager(selected_element).Connectors
        for c in connectors:
            connectedTo = c.AllRefs

            for con in connectedTo:
                print str(con.Owner)

                c.DisconnectFrom(con)

            #print "Connected to:" str(connectedTo )
        return True
    except Exceptions.OperationCanceledException:
        print "Error"
        return True
Exemplo n.º 6
0
    def pick_domain(self):
        # ask user for origin and max domain points
        with forms.WarningBar(title='Pick origin point (bottom-left '
                                    'corner of the pattern area):'):
            pat_bottomleft = revit.pick_point()
        if pat_bottomleft:
            with forms.WarningBar(title='Pick top-right corner '
                                        'of the pattern area:'):
                pat_topright = revit.pick_point()
            if pat_topright:
                return (MakePatternWindow.round_coord(pat_bottomleft.X),
                        MakePatternWindow.round_coord(pat_bottomleft.Y)), \
                       (MakePatternWindow.round_coord(pat_topright.X),
                        MakePatternWindow.round_coord(pat_topright.Y))

        return False
Exemplo n.º 7
0
def select_inplace_filter():
    # select elements while applying filter
    try:
        with forms.WarningBar(title="Select In-Place element to transform"):
            ref = rpw.revit.uidoc.Selection.PickObject(ObjectType.Element, InPlaceFilter())
            selection = revit.doc.GetElement(ref)
            return selection
    except Exceptions.OperationCanceledException:
        forms.alert("Cancelled", ok=True, warn_icon=False, exitscript=True)
Exemplo n.º 8
0
    def pick_domain(self):
        def round_domain_coord(coord):
            return round(coord, PICK_COORD_RESOLUTION)

        # ask user for origin and max domain points
        with forms.WarningBar(title='Pick origin point (bottom-left '
                              'corner of the pattern area):'):
            pat_bottomleft = revit.pick_point()
        if pat_bottomleft:
            with forms.WarningBar(title='Pick top-right corner '
                                  'of the pattern area:'):
                pat_topright = revit.pick_point()
            if pat_topright:
                return (round_domain_coord(pat_bottomleft.X),
                        round_domain_coord(pat_bottomleft.Y)), \
                       (round_domain_coord(pat_topright.X),
                        round_domain_coord(pat_topright.Y))

        return False
Exemplo n.º 9
0
def pick_and_match_styles(src_element):
    with forms.WarningBar(title='Pick target elements:'):
        while True:
            dest_element = revit.pick_element()

            if not dest_element:
                break

            with revit.Transaction('Match Tags'):
                tagsmgr.match_tags(src_element, [dest_element])
Exemplo n.º 10
0
def pick_and_match_types(src_props):
    """Match property values for selected types."""
    with forms.WarningBar(title="Pick objects to match type properties:"):
        while True:
            dest_element = revit.pick_element()
            if not dest_element:
                break

            dest_type = revit.query.get_type(dest_element)
            with revit.Transaction("Match Type Properties"):
                match_prop(dest_element, dest_type, src_props)
Exemplo n.º 11
0
def pick_and_match_styles(src_style):
    with forms.WarningBar(title='Pick objects to match overrides:'):
        while True:
            dest_element = revit.pick_element()

            if not dest_element:
                break

            with revit.Transaction('Match Graphics Overrides'):
                revit.activeview.SetElementOverrides(dest_element.Id,
                                                     src_style)
Exemplo n.º 12
0
def select_rooms_filter():
    # select elements while applying category filter
    try:
        with forms.WarningBar(title="Pick Rooms to transform"):
            selection = [
                revit.doc.GetElement(reference)
                for reference in rpw.revit.uidoc.Selection.PickObjects(
                    ObjectType.Element, RoomsFilter())
            ]
            return selection
    except Exceptions.OperationCanceledException:
        forms.alert("Cancelled", ok=True, warn_icon=False)
Exemplo n.º 13
0
def pick_and_match_dim_overrides(src_dim_id):
    with forms.WarningBar(title='Pick dimensions to match overrides:'):
        src_dim = revit.doc.GetElement(src_dim_id)
        while True:
            dest_dim = revit.pick_element()

            if not dest_dim:
                break

            if isinstance(dest_dim, DB.Dimension):
                with revit.Transaction('Match Dimension Overrides'):
                    setup_dim_overrides_per_config(src_dim, dest_dim)
Exemplo n.º 14
0
    def pick_domain(self):
        # ask user for origin and max domain points
        with forms.WarningBar(title='Pick origin point (bottom-left '
                              'corner of the pattern area):'):
            view = revit.active_view
            if not view.SketchPlane \
                    and not isinstance(view, DB.ViewDrafting):
                base_plane = \
                    DB.Plane.CreateByNormalAndOrigin(view.ViewDirection,
                                                     view.Origin)
                with revit.Transaction('Set Selection Plane'):
                    pick_plane = DB.SketchPlane.Create(revit.doc, base_plane)
                    view.SketchPlane = pick_plane
            pat_bottomleft = revit.pick_point()
        if pat_bottomleft:
            with forms.WarningBar(title='Pick top-right corner '
                                  'of the pattern area:'):
                pat_topright = revit.pick_point()
            if pat_topright:
                return self.make_pattern_line(pat_bottomleft, pat_topright)

        return False
Exemplo n.º 15
0
def selected_legend():
    """Get Box Outline Point of User Selected Legend"""
    with forms.WarningBar(title='Select Legend on Sheet'):
        selected_element = doc.GetElement(
            uidoc.Selection.PickObject(ObjectType.Element))
    select_legend = -1
    try:
        if doc.GetElement(
                selected_element.ViewId).ViewType.ToString() == 'Legend':
            select_legend = selected_element
    except:
        pass

    return select_legend
Exemplo n.º 16
0
def pick_and_match_styles(src_style):
    with forms.WarningBar(title='Pick objects to match overrides:'):
        while True:
            dest_element = revit.pick_element()

            if not dest_element:
                break

            dest_element_ids = [dest_element.Id]
            if hasattr(dest_element, 'GetSubComponentIds'):
                dest_element_ids.extend(dest_element.GetSubComponentIds())
            with revit.Transaction('Match Graphics Overrides'):
                for dest_elid in dest_element_ids:
                    revit.active_view.SetElementOverrides(dest_elid, src_style)
def UserSelect():
	from pyrevit import forms
	from rpw.ui.forms import CommandLink, TaskDialog

	commands= [CommandLink('Pick by order...', return_value=False),
			   CommandLink('Select multiple...', return_value=True)]
	
	mg = "No elements preselected, so select elements now...\nIf listed order in excel matters, pick them by order."
	mg += "\n\nInstructions :\n  1) If pick, when done, press ESCAPE key or in context menu (mouse right click) select Cancel."
	mg += "\n  2) If multiple, when done, press Finish button (on the left, under the ribbon). ESCAPE key will cancel, no elements will be selected."

	dialog = TaskDialog('neoCL | iParameters Editor',
					title_prefix=False,
					content=mg,
					commands=commands,
					buttons=[],
					show_close=False)
	selectMultiple = dialog.show()
	
	els = []
	ct = len(els)
	go = True
	
	if selectMultiple:
		mg = 'neoCL | Select Element(s). Press Finish button (on the left, under the ribbon) when done. ESCAPE key will cancel.'
	else:
		mg = 'neoCL | Pick Element(s) by order! ESCAPE key (or right click and Cancel) when done. Total[' + str(ct) + ']'

	while go:
		try:
			with forms.WarningBar(title=mg):
				if selectMultiple:
					elx = ui.Pick.pick_element(msg=mg, multiple=selectMultiple)
					for el in elx:						
						el = db.Element.from_id(el.id)
						els.append(el)
					go = False
				else:
					el = ui.Pick.pick_element(msg=mg, multiple=selectMultiple)
					el = db.Element.from_id(el.id)
					els.append(el)
					ct = len(els)
					mg = "Selecting... Total[" + str(ct) + "] ESCAPE key when done."
		except:
			go = False
			
	return els
Exemplo n.º 18
0
def pick_and_match_dim_overrides(src_dim_id):
    with forms.WarningBar(title='Pick dimensions to match overrides:'):
        src_dim = revit.doc.GetElement(src_dim_id)
        if src_dim.NumberOfSegments > 1:
            src_dim = src_dim.Segments[0]
        while True:
            dest_dim = revit.pick_element()

            if not dest_dim:
                break

            if isinstance(dest_dim, DB.Dimension):
                with revit.Transaction('Match Dimension Overrides'):
                    if dest_dim.NumberOfSegments > 1:
                        segments = dest_dim.Segments
                        for segment in segments:
                            setup_dim_overrides_per_config(src_dim, segment)
                    else:
                        setup_dim_overrides_per_config(src_dim, dest_dim)
Exemplo n.º 19
0
from pyrevit import revit
from pyrevit import forms

import tagscfg
import tagsmgr

__author__ = '{{author}}'


def pick_and_match_styles(src_element):
    with forms.WarningBar(title='Pick target elements:'):
        while True:
            dest_element = revit.pick_element()

            if not dest_element:
                break

            with revit.Transaction('Match Tags'):
                tagsmgr.match_tags(src_element, [dest_element])


if tagscfg.verify_tags_configs():
    with forms.WarningBar(title='Pick source element:'):
        source_element = revit.pick_element()

    if source_element:
        pick_and_match_styles(source_element)
else:
    forms.alert('Tags tools need to be configured before using. '
                'Click on the Tags Settings button to setup.')
Exemplo n.º 20
0
    Main_Top_Constraint = Selected_wall.get_Parameter(
        BuiltInParameter.WALL_HEIGHT_TYPE)
    Main_Top_Constraint_Id = Selected_wall.get_Parameter(
        BuiltInParameter.WALL_HEIGHT_TYPE).AsElementId()
    Main_is_unconnected = str(
        Main_Top_Constraint_Id
    ) == "-1"  # True = Unconnected / False = Up to Level

    #>>>>>>>>>> BASE
    Main_Base_Containt = Selected_wall.get_Parameter(
        BuiltInParameter.WALL_BASE_CONSTRAINT).AsElementId()
    Main_Base_Offset = Selected_wall.get_Parameter(
        BuiltInParameter.WALL_BASE_OFFSET).AsDouble()

    #>>>>>>>>>> LOOP: SELECT MATCH WALL
    with forms.WarningBar(title="Pick Wall to match base constrains:",
                          handle_esc=True):
        while True:

            #>>>>>>>>>> PICK WALL
            try:
                Match_wall = pick_wall(uidoc)
            except:
                break
            if not Match_wall: break

            #>>>>>>>>>> SET PARAMETERS
            with revit.Transaction(__title__):

                Match_wall.get_Parameter(
                    BuiltInParameter.WALL_HEIGHT_TYPE).Set(
                        Main_Top_Constraint_Id)
Exemplo n.º 21
0
def new_transition():
    # Prompt user to select elements and points to connect
    try:
        message = "Pick element 1 (the connector moves depending on transition length)"
        with forms.WarningBar(title=message):
            reference = uidoc.Selection.PickObject(
                ObjectType.Element, NoInsulationNoFamilyInstance(), message)
    except Exceptions.OperationCanceledException:
        return False

    try:
        element1 = doc.GetElement(reference)
        xyz1 = reference.GlobalPoint

        message = "Pick element 2 (static)"
        with forms.WarningBar(title=message):
            reference = uidoc.Selection.PickObject(ObjectType.Element,
                                                   NoInsulation(), message)
        element2 = doc.GetElement(reference)
        xyz2 = reference.GlobalPoint
    except Exceptions.OperationCanceledException:
        return True

    # Get associated unused connectors
    connector1 = get_connector_closest_to(
        get_connector_manager(element1).UnusedConnectors, xyz1)
    connector2 = get_connector_closest_to(
        get_connector_manager(element2).UnusedConnectors, xyz2)

    try:
        if connector1.Domain != connector2.Domain:
            forms.alert(
                "You picked 2 connectors of different domain. Please retry.",
                title="Domain Error",
            )
            return True
    except AttributeError:
        forms.alert(
            "It looks like one of the objects have no unused connector",
            title="AttributeError",
        )
        return True

    if not connector1 and not connector2:
        forms.alert(
            "It looks like one of the objects have no unused connector",
            title="AttributeError",
        )
        return True

    with revit.Transaction("Create transition"):
        try:
            doc.Create.NewTransitionFitting(connector1, connector2)
        except Exceptions.InvalidOperationException:
            cmd_link1_msg = "Show exemple image"
            result = forms.alert(
                "Unable to connect.",
                sub_msg=
                "Make sure you click near connectors you want to make a transition between.",
                options=[cmd_link1_msg])
            if result == cmd_link1_msg:
                import os
                os.startfile(os.path.join(__commandpath__, "WhereToClick.png"))
    return True
Exemplo n.º 22
0
            return True
        else:
            return False

    @staticmethod
    def AllowReference(ref, point):
        return True


# 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 grid lines."):
    try:
        grids = uidoc.Selection.PickElementsByRectangle(
            CustomISelectionFilter("Grids"), "Select Grids")
    except:
        TaskDialog.Show("Failed", "Yup, failed")

ref_array = ReferenceArray()
s = ""

for gr in grids:
    crv = gr.Curve
    p = crv.GetEndPoint(0)
    q = crv.GetEndPoint(1)
    v = p - q
    up = DB.XYZ.BasisZ
Exemplo n.º 23
0
# pick text style
txt_types = DB.FilteredElementCollector(revit.doc).OfClass(DB.TextNoteType)
text_style_dict= {txt_t: txt_t.get_Parameter(DB.BuiltInParameter.SYMBOL_NAME_PARAM).AsString() for txt_t in txt_types}

# sort styles by name
sorted_text_styles = OrderedDict(sorted(text_style_dict.items(), key=lambda t:t[1]))
view = revit.active_view

# dims and scale
scale = float(view.Scale)/ 200
shift = 5 * scale
offset = 0

text_height = 0

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

origin = pick_point
with revit.Transaction("Place Text Notes"):
    for ts in sorted_text_styles:

        label_text = sorted_text_styles[ts]

        text_position = DB.XYZ(pick_point.X, (pick_point.Y-offset),0)
        text_height = ts.get_Parameter(DB.BuiltInParameter.TEXT_SIZE).AsDouble()
        offset += (text_height * 2.75 * float(view.Scale))
        text_note = DB.TextNote.Create(revit.doc, view.Id, text_position, label_text, ts.Id)
Exemplo n.º 24
0
    # add areas if active view is an Area Plan
    if revit.active_view.ViewType == DB.ViewType.AreaPlan:
        renumber_options.insert(1, RNOpts(cat=BIC.OST_Areas))

    options_dict = OrderedDict()
    for renumber_option in renumber_options:
        options_dict[renumber_option.name] = renumber_option
    selected_option_name = \
        forms.CommandSwitchWindow.show(
            options_dict,
            message='Pick element type to renumber:',
            width=400
        )

    if selected_option_name:
        selected_option = options_dict[selected_option_name]
        if selected_option.by_bicat:
            # if renumber doors by room
            if selected_option.bicat == BIC.OST_Doors \
                    and selected_option.by_bicat == BIC.OST_Rooms:
                with forms.WarningBar(
                        title='Pick Pairs of Door and Room. ESCAPE to end.'):
                    door_by_room_renumber(selected_option)
        else:
            starting_number = ask_for_starting_number(selected_option.name)
            if starting_number:
                with forms.WarningBar(
                        title='Pick {} One by One. ESCAPE to end.'.format(
                            selected_option.name)):
                    pick_and_renumber(selected_option, starting_number)
Exemplo n.º 25
0
from pyrevit import revit, DB, forms, script

import rpw
from rpw import doc, uidoc, DB, UI

from tags_wrapper import *

#Point = namedtuple('Point', ['X', 'Y','Z'])

cView = doc.ActiveView
Tags = rpw.ui.Selection()

if cView.ViewType in [
        DB.ViewType.FloorPlan, DB.ViewType.CeilingPlan, DB.ViewType.Detail,
        DB.ViewType.AreaPlan, DB.ViewType.Section, DB.ViewType.Elevation
]:

    if len(Tags) < 1:
        UI.TaskDialog.Show('pyRevitPlus', 'A tag must preselected')
    if len(Tags) > 1:
        UI.TaskDialog.Show('pyRevitPlus', 'Select a SINGLE tag')
    else:
        cTag = Tags[0]
        cPos = cTag.TagHeadPosition

        with forms.WarningBar(title='Pick tag One by One. ESCAPE to end.'):
            if cView.ViewType in [DB.ViewType.Section, DB.ViewType.Elevation]:
                allign_XY(cTag.Category, cPos)
            else:
                allign_X(cTag.Category, cPos)
Exemplo n.º 26
0
                break

            if isinstance(dest_dim, DB.Dimension):
                with revit.Transaction('Match Dimension Overrides'):
                    setup_dim_overrides_per_config(src_dim, dest_dim)


def pick_and_match_styles(src_style):
    with forms.WarningBar(title='Pick objects to match overrides:'):
        while True:
            dest_element = revit.pick_element()

            if not dest_element:
                break

            with revit.Transaction('Match Graphics Overrides'):
                revit.activeview.SetElementOverrides(dest_element.Id,
                                                     src_style)


# fixme: modify to remember source style
with forms.WarningBar(title='Pick source object:'):
    source_element = revit.pick_element()

if source_element:
    if isinstance(source_element, DB.Dimension):
        pick_and_match_dim_overrides(source_element.Id)
    else:
        source_style = get_source_style(source_element.Id)
        pick_and_match_styles(source_style)
Exemplo n.º 27
0
                            if curve.GetEndPoint(0) - pt1 < curve.GetEndPoint(
                                    1) - pt1:
                                return edge.GetEndPointReference(0)
                            else:
                                return edge.GetEndPointReference(1)


for element in selection:
    try:
        direction = element.Location.Curve.Direction
        break
    except AttributeError:
        continue
else:
    with forms.WarningBar(
            title=
            "Unable to find a lead direction. Please pick a parallel line."):
        ref = uidoc.Selection.PickObject(ObjectType.Element, CurveLineFilter())
        direction = doc.GetElement(ref).Location.Curve.Direction

pt1 = uidoc.Selection.PickPoint()  # type: XYZ
pt2 = pt1 + XYZ(-direction.Y, direction.X, 0)
line = Line.CreateBound(pt1, pt2)

for element in selection:
    reference_array.Append(get_reference(element))

with rpw.db.Transaction("QuickDimensionPipe"):
    logger.debug([reference for reference in reference_array])
    dim = doc.Create.NewDimension(doc.ActiveView, line, reference_array)
Exemplo n.º 28
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.º 29
0
                                               yes=True, no=True):
    source_element = selected_elements[0]
    target_type = "Views" if isinstance(source_element, DB.View)\
        else "Elements"
else:
    source_element = None
    # ask for type of elements to match
    # some are not selectable in graphical views
    target_type = \
        forms.CommandSwitchWindow.show(
            ["Elements", "Views"],
            message="Pick type of targets:")

    # determine source element
    if target_type == "Elements":
        with forms.WarningBar(title="Pick source object:"):
            source_element = revit.pick_element()
    elif target_type == "Views":
        source_element = \
            forms.select_views(title="Select Source View", multiple=False)

# grab parameters from source element
if source_element:
    target_element = None
    if target_type == "Elements":
        target_element = revit.pick_element(message="Pick target element:")
    elif target_type == "Views":
        target_element = \
            forms.select_views(title="Select Target View", multiple=False)
    if target_element:
        compare_props(source_element, target_element)
Exemplo n.º 30
0
if form.show():
    border_size = form.values["combobox1"]
    tag = form.values["combobox2"]
    pdf_tb = form.values["combobox3"]
    view_temp = form.values["combobox4"]
    text = form.values["combobox6"]
    line_style = form.values["combobox5"]
    short_descript = form.values["textbox1"]

    plan_view = revit.doc.ActiveView
    forms.check_viewtype(plan_view, DB.ViewType.FloorPlan, exitscript=True)
    today = date.today()
    today = today.strftime("%m/%d/%Y")

    with forms.WarningBar(title="Pick instances to add to legend:"):
        source_elements = revit.pick_elements()

    values = []
    if source_elements:

        # Filtering for current sheets to get highest sheet number
        current_sheets = []
        all_sheets = (DB.FilteredElementCollector(revit.doc).OfCategory(
            DB.BuiltInCategory.OST_Sheets).ToElements())
        for s in all_sheets:
            try:
                num = math.floor(float(s.SheetNumber))
                current_sheets.append(num)
            except ValueError:
                continue