Пример #1
0
 def __init__(self, definition, binding):
     # type: (Definition, ElementBinding) -> None
     self.definition = definition
     self.binding = binding
     self.category_set = binding.Categories
     self.bip_group = BipGroup(definition.ParameterGroup)
     self.pt_name = LabelUtils.GetLabelFor(definition.ParameterType)
     self.ut_name = LabelUtils.GetLabelFor(definition.UnitType)
     if isinstance(binding, InstanceBinding):
         self.is_instance = True
     else:
         self.is_instance = False
Пример #2
0
 def all_param_group(self):
     if not self.__class__._all_param_group:
         els = {
             LabelUtils.GetLabelFor(getattr(BuiltInParameterGroup, i)):
             getattr(BuiltInParameterGroup, i)
             for i in dir(BuiltInParameterGroup) if i[0:2] == "PG"
         }
         self.__class__._all_param_group = els
     return self.__class__._all_param_group
Пример #3
0
    def all_param_names(self):
        if self._all_param_names is None:

            self._all_param_names = {
                "({}) {}".format(
                    LabelUtils.GetLabelFor(i.Definition.ParameterGroup),
                    i.Definition.Name): i
                for i in self.fm.GetParameters()
            }
        return self._all_param_names
    def para_setter(self, room, space):
        ''' 
        Function transers parameters from the room to newly created spaces
        room: Revit Room, space: MEPSpace
        '''
        # For each parameter in room parameters define if it's shared or builtin parameter
        for par in room.Parameters:
            par_name = par.Definition.Name
            if par.IsShared and par_name in self._excel_parameters:
                # If room parameter is shared get space from Spaces dictionary by UniqueId and extract corresponding space parameter from it by room parameter GUID
                # Depending on the room parameter storage type set its value to the space parameter
                if not par.IsReadOnly:
                    try:
                        space_par = space.get_Parameter(par.GUID)
                        if par.StorageType == StorageType.String and par.HasValue:
                            space_par.Set(par.AsString())
                        elif par.StorageType == StorageType.Integer and par.HasValue:
                            space_par.Set(par.AsInteger())
                        elif par.StorageType == StorageType.Double and par.HasValue:
                            space_par.Set(par.AsDouble())
                    except Exception as e:
                        logger.error(e, exc_info=True)
                        pass

                    self.counter += 1
                    self.ReportProgress.emit(self.counter)

            elif par.Definition.BuiltInParameter != BuiltInParameter.INVALID\
                and LabelUtils.GetLabelFor(par.Definition.BuiltInParameter) in self._excel_parameters:
                # If room parameter is builtin get space from Spaces dictionary by UniqueId and extract corresponding space parameter from it by builtin parameter
                # Depending on the room parameter storage type set its value to the space parameter
                if not par.IsReadOnly:
                    try:
                        space_par = space.get_Parameter(par.Definition)
                        if par.StorageType == StorageType.String and par.HasValue:
                            space_par.Set(par.AsString())
                        elif par.StorageType == StorageType.Integer and par.HasValue:
                            space_par.Set(par.AsInteger())
                        elif par.StorageType == StorageType.Double and par.HasValue:
                            space_par.Set(par.AsDouble())

                    except Exception as e:
                        logger.error(e, exc_info=True)
                        pass

                    self.counter += 1
                    self.ReportProgress.emit(self.counter)
    def get_builtin_parameters(self):
        builtin_pars = set()
        bicId = [ElementId(BuiltInCategory.OST_MEPSpaces)]
        catlist = List[ElementId](bicId)
        paramIds = ParameterFilterUtilities.GetFilterableParametersInCommon(
            self.doc, catlist)
        for bpar in BuiltInParameter.GetValues(
                clr.GetClrType(BuiltInParameter)):

            try:
                bparId = ElementId(bpar)
                if bparId in paramIds:
                    builtin_pars.add(LabelUtils.GetLabelFor(bpar))

            except Exception as e:
                logger.error(e, exc_info=True)
                pass

        return builtin_pars
Пример #6
0
doc = rpw.revit.doc  # type: Document

unit_format_options = doc.GetUnits().GetFormatOptions(UnitType.UT_Length)

display_unit = unit_format_options.DisplayUnits

symbol_type = unit_format_options.UnitSymbol

if symbol_type == UnitSymbolType.UST_NONE:
    try:
        symbol_type = FormatOptions.GetValidUnitSymbols(display_unit).Item[1]
    except System.ArgumentOutOfRangeException:
        display_unit = DisplayUnitType.DUT_DECIMAL_FEET
        symbol_type = FormatOptions.GetValidUnitSymbols(display_unit).Item[1]
symbol = LabelUtils.GetLabelFor(symbol_type)

def import_config_length(length):
    return str(UnitUtils.ConvertFromInternalUnits(float(length), display_unit))

def export_config_length(lenght):
    return str(UnitUtils.ConvertToInternalUnits(float(lenght), display_unit))

class CreateSectionOptions(forms.WPFWindow):

    def __init__(self):
        forms.WPFWindow.__init__(self, "CreateSectionOptions.xaml")

        #self.set_image_source(self.diagram_img, "diagram.png")
        self.tblock_units.Text = "All length in {}".format(symbol)
    cats_by_name[cat.Name] = cat
    if cat.SubCategories:
        for subcat in cat.SubCategories:
            # print('{} {}'.format(subcat.Id.IntegerValue, subcat.Name))
            cats[subcat.Id.IntegerValue] = (subcat, subcat.Name)
            cats_by_name[cat.Name] = subcat

for i in cats:
    print('{} {}'.format(i, cats[i][1]))

builtin_params = {}
builtin_params_by_name = {}
for i in dir(BuiltInParameter):
    try:
        bip = getattr(BuiltInParameter, i)
        name = LabelUtils.GetLabelFor(bip)
        builtin_params[ElementId(bip).IntegerValue] = (bip, name)
        builtin_params_by_name[name] = bip
    except:
        pass

# bip = builtin_params[[i for i in builtin_params][0]]
# print(bip)
# print(type(bip))

# print(111111111111)

# for i in dir(bip[0]):
#     if "<type 'BuiltInParameter'>" != str(type(getattr(bip[0], i))):
#         print('{} {}'.format(i, (getattr(bip[0], i))))
#     # print(i)
Пример #8
0
 def enum_member_by_name(cls, name):
     # type: (str) -> Enum
     for enum_member in cls.enum_generator():
         if LabelUtils.GetLabelFor(enum_member) == name:
             return enum_member
Пример #9
0
 def enum_name_generator(cls):
     for enum_member in cls.enum_generator():
         yield LabelUtils.GetLabelFor(enum_member)
Пример #10
0
 def name(self):
     try:
         return "{}{}({})".format(LabelUtils.GetLabelFor(self.enum_member),
                                  4 * " ", self.enum_member)
     except Exceptions.InvalidOperationException:
         return "Invalid"