예제 #1
0
def make_floor(new_floor):
    floor_curves = DB.CurveArray()
    for boundary_segment in new_floor.boundary:
        floor_curves.Append((boundary_segment).GetCurve())
    floorType = doc.GetElement(new_floor.floor_type_id)
    level = doc.GetElement(new_floor.level_id)
    normal_plane = DB.XYZ.BasisZ
    f = doc.Create.NewFloor(floor_curves, floorType, level, False,
                            normal_plane)
    fls.append(f)

    # Input parameter values from rooms
    if form.values['checkbox1'] == True:
        db.Element(f).parameters.builtins[
            'FLOOR_HEIGHTABOVELEVEL_PARAM'].value = float(
                new_floor.room_offset1)
    else:
        db.Element(f).parameters.builtins[
            'FLOOR_HEIGHTABOVELEVEL_PARAM'].value = float(offset3 / 304.8)
    try:
        db.Element(f).parameters['BA_AI_RoomName'].value = new_floor.room_name
        db.Element(
            f).parameters['BA_AI_RoomNumber'].value = new_floor.room_number
        db.Element(f).parameters['BA_AI_RoomID'].value = new_floor.room_id
        db.Element(
            f).parameters['BA_AI_FinishingType'].value = "Floor Finishing"
        db.Element(room).parameters['BA_AI_RoomID'].value = room.Id
    except:
        forms.toaster.send_toast(
            'You need to add shared parameters for BA finishing')
        #forms.alert('You need to add shared parameters for BA finishing')
        pass
예제 #2
0
def make_ceiling(new_ceiling):
    ceiling_curves = DB.CurveArray()
    for boundary_segment in new_ceiling.boundary:
        try:
            ceiling_curves.Append(boundary_segment.Curve)       # 2015, dep 2016
        except AttributeError:
            ceiling_curves.Append(boundary_segment.GetCurve())  # 2017
    ceilingType = doc.GetElement(new_ceiling.ceiling_type_id)
    ceil_thick = ceilingType.get_Parameter(BuiltInParameter.ROOF_ATTR_DEFAULT_THICKNESS_PARAM).AsDouble()
    level = doc.GetElement(new_ceiling.level_id)
    f = doc.Create.NewFootPrintRoof(ceiling_curves, level, ceilingType, clr.StrongBox[ModelCurveArray](ModelCurveArray()))
    if form.values['checkbox1'] == True :
        db.Element(f).parameters.builtins['ROOF_LEVEL_OFFSET_PARAM'].value = float(new_ceiling.room_offset - ceil_thick)
    else:
        db.Element(f).parameters.builtins['ROOF_LEVEL_OFFSET_PARAM'].value = float(offset3/304.8)
    try:
        db.Element(f).parameters['BA_AI_RoomName'].value = new_ceiling.room_name
        db.Element(f).parameters['BA_AI_RoomNumber'].value = new_ceiling.room_number
        db.Element(f).parameters['BA_AI_RoomID'].value = new_ceiling.room_id
        db.Element(f).parameters['BA_AI_FinishingType'].value = "Ceiling Finishing"
        db.Element(room).parameters['BA_AI_RoomID'].value = room.Id
    except:
        forms.toaster.send_toast('You need to add shared parameters for BA finishing')
        #forms.alert('You need to add shared parameters for BA finishing')
        pass
예제 #3
0
def to_elements(element_references):
    """ Coerces element reference (``int``, or ``ElementId``) into ``DB.Element``.
    Remains unchanged if it's already ``DB.Element``. Accepts single object or lists

    Args:
        element_references ([``DB.ElementId``, ``int``, ``DB.Element``]): Element Reference, single or list

    Returns:
        [``DB.Element``]: Elements
    """
    if not isinstance(element_references, list):
        element_references = [element_references]

    elements = []

    for element_reference in element_references:

        if isinstance(element_reference, DB.ElementId):
            element = doc.GetElement(element_reference)

        elif isinstance(element_reference, int):
            element = doc.GetElement(DB.ElementId(element_reference))

        elif isinstance(element_reference, DB.Element):
            element = element_reference

        else:
            raise RPW_TypeError('Element, ElementId, or int',
                                type(element_reference))

        elements.append(element)

    return elements
예제 #4
0
def make_floor(new_floor):
    floor_curves = DB.CurveArray()
    for boundary_segment in new_floor.boundary:
        try:
            floor_curves.Append(boundary_segment.Curve)  # 2015, dep 2016
        except AttributeError:
            floor_curves.Append(boundary_segment.GetCurve())  # 2017

    floorType = doc.GetElement(new_floor.floor_type_id)
    level = doc.GetElement(new_floor.level_id)
    normal_plane = DB.XYZ.BasisZ
    doc.Create.NewFloor(floor_curves, floorType, level, False, normal_plane)
예제 #5
0
파일: script.py 프로젝트: tkahng/ISGpyRevit
def make_floor(floor_type, boundary, level_id):
    floor_curves = CurveArray()
    for boundary_segment in boundary:
        try:
            floor_curves.Append(boundary_segment.Curve)       # 2015, dep 2016
        except AttributeError:
            floor_curves.Append(boundary_segment.GetCurve())  # 2017

    floorType = doc.GetElement(floor_type)
    offset = rpw.db.Element(floorType).parameters['Default Thickness'].AsDouble()
    level = doc.GetElement(level_id)
    normal_plane = XYZ.BasisZ
    floor = doc.Create.NewFloor(floor_curves, floorType, level, False, normal_plane)
    rpw.db.Element(floor).parameters['Height Offset From Level'] = offset
    return floor
예제 #6
0
def create_finish_wall(room, wall_type, wall_height):
    offset_distance = wall_type.parameters['Width'].AsDouble() * 0.5
    boundary_loops = get_boundaries(room)
    # print(boundary_loops)
    for boundary in boundary_loops:
        curveloop = curveloop_from_boundary(boundary)

        offset_curveloop = CurveLoop.CreateViaOffset(curveloop, offset_distance,
                                                     curveloop.GetPlane().Normal)
        if not is_inside_room(offset_curveloop, room):
            offset_curveloop = CurveLoop.CreateViaOffset(curveloop, -offset_distance,
                                                         curveloop.GetPlane().Normal)
        new_walls = []
        with rpw.db.Transaction('Create Finish Wall'):
            for curve in offset_curveloop:
                new_wall = Wall.Create(doc, curve, wall_type.Id, room.LevelId,
                                       wall_height/304.8, 0, False, False)
                new_walls.append(new_wall)
        with rpw.db.Transaction('Join old-new walls'):
            for idx, new_wall in enumerate(new_walls):
                old_wall = doc.GetElement(boundary[idx].ElementId)
                if old_wall:
                    try:
                        JoinGeometryUtils.JoinGeometry(doc, old_wall, new_wall)
                    except Exception as e:
                        print(e)
        with rpw.db.Transaction('Delete short walls'):
            for new_wall in new_walls:
                length = new_wall.LookupParameter('Length').AsDouble() * 304.8
                if length < 50:
                    doc.Delete(new_wall.Id)
예제 #7
0
    def elements(self):
        """
        Gets list of ```Elemend`` in selection

        Returns:
            [DB.Element]: List of Elements """
        return [doc.GetElement(eid) for eid in self.element_ids]
예제 #8
0
 def make_wall():
     walls = []
     wallfaces = self.RoomFaceWall()
     # l:EdgeLoop->[List<CurveLoop>]  n:edgeNormal w:_WallId
     for l, n, w in zip(wallfaces[0], wallfaces[1], wallfaces[2]):
         transform = DB.Transform.CreateTranslation(
             self.WallFinishType.Width / 2 * (-n))
         newLines = List[DB.Curve]()
         for i in l:
             newCurveLoop = DB.CurveLoop.CreateViaTransform(
                 i, transform)
             CurveInterator = newCurveLoop.GetCurveLoopIterator()
             for c in CurveInterator:
                 newLines.Add(c)
         OldWall = doc.GetElement(w)
         #TODO There are some proble
         try:
             NewWall = DB.Wall.Create(doc, newLines,
                                      self.WallFinishTypeId,
                                      self.RoomLevelId, None)
             NewWall.get_Parameter(
                 DB.BuiltInParameter.WALL_ATTR_ROOM_BOUNDING).Set(0)
         except:
             NewWall = None
         try:
             DB.JoinGeometryUtils.JoinGeometry(doc, NewWall, OldWall)
             walls.append(NewWall)
         except:
             if NewWall != None:
                 doc.Delete(NewWall.Id)
             walls.append(None)
     return walls
예제 #9
0
def uncut_elems_cut_by_void(void):
    dprint("void {} uncutting.".format(void.Id.IntegerValue))
    cut_elem_ids = InstanceVoidCutUtils.GetElementsBeingCut(void)
    if cut_elem_ids:
        for cut_elem_id in cut_elem_ids:
            cut_elem = doc.GetElement(cut_elem_id)
            InstanceVoidCutUtils.RemoveInstanceVoidCut(doc, cut_elem, void)
예제 #10
0
def Main():
    for sheet in viewSheets:
        rev = sheet.GetRevisionNumberOnSheet(
            doc.GetElement(sheet.GetCurrentRevision()).Id)
        FileName = sheet.Name + "_" + rev + ".pdf"
        PrintView(doc, sheet, pRange, printerName, PrinterFolderPath,
                  RealFolderPath, FileName, combined, printSetting)
예제 #11
0
def change_sheets_name(sheet_ids, template, new):
    """
    Change sheet number to replace by template

    :param sheet_ids:
    :param template:
    :param new:
    :return:
    """

    data = []
    for sheet_id in sheet_ids:
        sheet = doc.GetElement(sheet_id)
        sheet_number = sheet.SheetNumber

        if template in sheet_number:
            new_sheet_number = sheet.SheetNumber.replace(template, new)
            sheet.SheetNumber = new_sheet_number

            data.append('OK [#{} Sheet {}]'.format(sheet_id,
                                                   repr(new_sheet_number)))
            logger.debug('OK [#{} Sheet {}]'.format(sheet_id,
                                                    repr(new_sheet_number)))
        else:
            data.append('PASS [#{} Sheet {}]'.format(sheet_id,
                                                     repr(sheet_number)))
            logger.debug('PASS [#{} Sheet {}]'.format(sheet_id,
                                                      repr(sheet_number)))

    logger.info('{} Sheets was ReNumbered'.format(len(data)))
    return data
예제 #12
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
예제 #13
0
    def get_grids_by_multi(multi_grids):
        grids = []
        for grid_id in multi_grids.GetGridIds():
            grid = doc.GetElement(grid_id)
            grids.append(grid)

        logger.debug('Multi-grids was divided by {}'.format(len(grids)))
        return grids
예제 #14
0
	def __init__(self,Element):
		self.Element=Element
		UnwrapElement=Element.unwrap()
		self.Type=UnwrapElement.GetType()
		self.Category=UnwrapElement.Category
		LevelId=UnwrapElement.LevelId

		self.BaseLevel=doc.GetElement(LevelId)
예제 #15
0
def ActivateView(viewid='', viewname=''):
	try:
		if viewid:
			uidoc.ActiveView = doc.GetElement(viewid)
		elif viewname:
			uidoc.ActiveView = GetViewIdByName(viewname)
	except:
		pass
예제 #16
0
def duplicate_view(view, cropbox, name_suffix):
    duplicate_plan = doc.GetElement(
        view.Duplicate(DB.ViewDuplicateOption.AsDependent))
    duplicate_plan.Name = sheet_name + name_suffix
    duplicate_plan.CropBoxActive = True
    duplicate_plan.CropBox = cropbox
    duplicate_plan.CropBoxVisible = False
    return duplicate_plan
예제 #17
0
def CombineMullion(CurtainGrid):

    uGridIds = CurtainGrid.GetMullionIds()

    Mullions = [doc.GetElement(i) for i in uGridIds]

    Geometrys = [i.Geometry[DB.Options()] for i in Mullions]
    #MullionIds=[i.FindInserts(True,True,True,True) for i in GridLines]
    GESExport(Geometrys[0])
예제 #18
0
 def families(self):
     """Returns:
         [``DB.Family``]: List of Family elements in this same category (unwrapped)
     """
     # There has to be a better way, but perhaps not: https://goo.gl/MqdzWg
     symbols = self.symbols
     unique_family_ids = set()
     for symbol in symbols:
         symbol_family = Element.Factory(symbol).family
         unique_family_ids.add(symbol_family.Id)
     return [doc.GetElement(family_id) for family_id in unique_family_ids]
 def GetMaterialAreaWithName(self):
     c=[]
     for i in self.getmatids():
         b={}
         mat=doc.GetElement(i)
         matarea = self.element.GetMaterialArea(i, False) * 0.09290304
         matname=mat.Name
         b['name']=matname
         b['area']=matarea
         c.append(b)
     return c
예제 #20
0
def GetTypeId(replace_familyName, replace_typeName):

	col = db.Collector(of_class=FamilySymbol)
	alltypes = col.GetElementIdIterator()
	alltypes.Reset()
	
	for el in alltypes:
		fsyb = doc.GetElement(el) 
		if fsyb.Family.Name == replace_familyName:
			tyname = Element.Name.GetValue(fsyb)
			if tyname == replace_typeName:
				return fsyb.Id
예제 #21
0
def get_selected_elements():
    """ Returns actual Elements that are currently selected. """
    selection = uidoc.Selection
    selection_ids = selection.GetElementIds()
    selection_size = selection_ids.Count
    if not selection_ids:
        TaskDialog.Show('CropImage', 'No Elements Selected.')
      #__window__.Close()
        sys.exit(0)
    elements = []
    for element_id in selection_ids:
        elements.append(doc.GetElement(element_id))
    return elements
예제 #22
0
        def make_wall():
            wallfaces = self.RoomFaceWall()
            for l, n, w in zip(wallfaces[0], wallfaces[1], wallfaces[2]):

                transform = DB.Transform.CreateTranslation(
                    self.WallFinishType.Width / 2 * (n))
                newLines = List[DB.Curve]()
                for i in l:
                    newLines.Add(i.CreateTransformed(transform))

                NewWall = DB.Wall.Create(doc, newLines, self.WallFinishTypeId,
                                         self.RoomLevelId, None)
                NewWall.get_Parameter(
                    DB.BuiltInParameter.WALL_ATTR_ROOM_BOUNDING).Set(0)
                OldWall = doc.GetElement(w)
                DB.JoinGeometryUtils.JoinGeometry(doc, NewWall, OldWall)
예제 #23
0
    def __init__(self, viewport):
        if not isinstance(viewport, DB.Viewport):
            raise TypeError('Element is not a viewport: {}'.format(viewport))

        # vp_outline
        # Space: Sheet | Origin: Sheet View Origin
        vp_outline = viewport.GetBoxOutline()
        vp_outline_min = DB.XYZ(vp_outline.MinimumPoint.X, vp_outline.MinimumPoint.Y, 0)
        vp_outline_max = DB.XYZ(vp_outline.MaximumPoint.X, vp_outline.MaximumPoint.Y, 0)

        # view_outline
        # Space: Sheet | Origin: Project Base Point
        view = doc.GetElement(viewport.ViewId)
        view_outline = view.Outline
        view_outline_min = uv_to_pt(view_outline.Min)
        view_outline_max = uv_to_pt(view_outline.Max)

        self.project_origin_in_sheetspace = vp_outline_min - view_outline_min
예제 #24
0
    def WallFinishType(self):
        try:
            WallFinishName = self.WrapedRoom.parameters[
                ParameterName.Room_Wall_Finish].value
            param_id = DB.ElementId(DB.BuiltInParameter.SYMBOL_NAME_PARAM)
            parameter_filter = db.ParameterFilter(param_id,
                                                  equals=WallFinishName)
            WallType = db.Collector(of_category='OST_Walls',
                                    parameter_filter=parameter_filter,
                                    is_type=True).get_first()

            WallType = WallType.unwrap()
            return WallType

        except Exception as e:
            print("{roomname} 没有设置墙体类型,使用默认墙体".format(roomname=self.RoomName))
            defaultWallTypeId = doc.GetDefaultElementTypeId(
                DB.ElementTypeGroup.WallType)
            WallType = doc.GetElement(defaultWallTypeId)
            return WallType
예제 #25
0
def ResetColumnToInstance(Element):
    for element in Element:
        try:
            level = doc.GetElement(element.LevelId)

            baseLevel = element.Parameter[
                DB.BuiltInParameter.FAMILY_BASE_LEVEL_PARAM]
            topLevel = element.Parameter[
                DB.BuiltInParameter.FAMILY_TOP_LEVEL_PARAM]
            baseOffset = element.Parameter[
                DB.BuiltInParameter.FAMILY_BASE_LEVEL_OFFSET_PARAM]
            topOffset = element.Parameter[
                DB.BuiltInParameter.FAMILY_TOP_LEVEL_OFFSET_PARAM]

            elementLocation = element.Location.Point
            elementSymbol = element.Symbol

            #elementFamily = elementSymbol.Family

            newElementInstance = doc.Create.NewFamilyInstance(
                elementLocation, elementSymbol, level,
                DB.Structure.StructuralType.Column)

            newElementInstance.Parameter[
                DB.BuiltInParameter.FAMILY_BASE_LEVEL_PARAM].Set(
                    baseLevel.AsElementId())
            newElementInstance.Parameter[
                DB.BuiltInParameter.FAMILY_TOP_LEVEL_PARAM].Set(
                    topLevel.AsElementId())
            newElementInstance.Parameter[
                DB.BuiltInParameter.FAMILY_BASE_LEVEL_OFFSET_PARAM].Set(
                    baseOffset.AsDouble())
            newElementInstance.Parameter[
                DB.BuiltInParameter.FAMILY_TOP_LEVEL_OFFSET_PARAM].Set(
                    topOffset.AsDouble())
            #topOffset.Set(newElementInstance.Id)
            print("ID{}Done".format(element.Id))
            doc.Delete(element.Id)

        except Exception as e:
            print("ID{}Wrong".format(element.Id))
예제 #26
0
    def WallFinishType(self):
        try:
            WallFinishName = self.WrapedRoom.parameters['Wall Finish'].value
            param_id = DB.ElementId(DB.BuiltInParameter.SYMBOL_NAME_PARAM)
            parameter_filter = db.ParameterFilter(param_id,
                                                  equals=WallFinishName)
            WallType = db.Collector(of_category='OST_Walls',
                                    parameter_filter=parameter_filter,
                                    is_type=True).get_first()

            return WallType

        except Exception as e:
            print(
                "{roomname} is not set WallFinishType,We use Default Wall Type defaultType"
                .format(roomname=self.RoomName))
        finally:
            defaultWallTypeId = doc.GetDefaultElementTypeId(
                DB.ElementTypeGroup.WallType)
            WallType = doc.GetElement(defaultWallTypeId)
            return WallType
예제 #27
0
def get_sheet_from_ids_int(sheet_ids_int):
    """
    Получить листы по int Ids

    :param sheet_ids_int: Список int Id листов
    :type sheet_ids_int: list[int]
    :return: Список листов
    :rtype: list[DB.Sheets]
    """

    res = []
    for str_id in sheet_ids_int:
        sheet_id = DB.ElementId(str_id)
        sheet = doc.GetElement(sheet_id)

        if sheet is None:
            logger.debug('Sheet #{} not found, may be delete'.format(sheet_id))
            continue

        res.append(sheet)
    return res
예제 #28
0
def get_selected_views_id():
    pre_selected = uidoc.Selection.GetElementIds()
    selected_views_id = List[DB.ElementId]()

    for elem_id in pre_selected:
        elem = doc.GetElement(elem_id)
        if elem and isinstance(elem,
                               DB.View) and elem.ViewType in VALID_VIEW_TYPE:
            selected_views_id.Add(elem_id)

    if selected_views_id:
        logger.debug('User select {} views'.format(len(selected_views_id)))
        return selected_views_id

    if doc.ActiveView.ViewType in VALID_VIEW_TYPE:
        logger.debug(
            'Not found any valid selected view. So return ActiveView id')
        return List[DB.ElementId]([doc.ActiveView.Id])

    raise ElemNotFound(
        'Valid selected view and ActiveView not found. ActiveView.ViewType is "{}"'
        .format(doc.ActiveView.ViewType))
예제 #29
0
def ResetBeamToInstance(Element):
    for element in Element:
        try:
            level = doc.GetElement(element.LevelId)

            referenceLevel = element.Parameter[
                DB.BuiltInParameter.INSTANCE_REFERENCE_LEVEL_PARAM]
            startLevelOffset = element.Parameter[
                DB.BuiltInParameter.STRUCTURAL_BEAM_END0_ELEVATION]
            endLevelOffset = element.Parameter[
                DB.BuiltInParameter.STRUCTURAL_BEAM_END1_ELEVATION]

            elementLocation = element.Location.Curve
            elementSymbol = element.Symbol

            #elementFamily = elementSymbol.Family

            newElementInstance = doc.Create.NewFamilyInstance(
                elementLocation, elementSymbol, level,
                DB.Structure.StructuralType.Beam)

            newElementInstance.Parameter[
                DB.BuiltInParameter.INSTANCE_REFERENCE_LEVEL_PARAM].Set(
                    referenceLevel.AsElementId())
            newElementInstance.Parameter[
                DB.BuiltInParameter.STRUCTURAL_BEAM_END0_ELEVATION].Set(
                    startLevelOffset.AsDouble())
            newElementInstance.Parameter[
                DB.BuiltInParameter.STRUCTURAL_BEAM_END1_ELEVATION].Set(
                    endLevelOffset.AsDouble())
            #topOffset.Set(newElementInstance.Id)
            print("ID{}Done".format(element.Id))
            doc.Delete(element.Id)

        except Exception as e:
            print(e)
            print("ID{}Wrong".format(element.Id))
예제 #30
0
def get_name_view_by_id(view_id):
    view = doc.GetElement(view_id)
    if view:
        return make_valid_name(view.Title)

    raise ElemNotFound('View #{}. Not found in document'.format(view_id))