Esempio n. 1
0
def execute_command(command_unique_name):
    """Executes a pyRevit command.

    Args:
        command_unique_name (str): Unique/Class Name of the pyRevit command

    Returns:
        results from the executed command
    """

    cmd_class = find_loaded_command(command_unique_name)

    if not cmd_class:
        logger.error('Can not find command with unique name: {}'
                     .format(command_unique_name))
        return None

    from pyrevit import HOST_APP

    # noinspection PyUnresolvedReferences
    from System.Runtime.Serialization import FormatterServices
    # noinspection PyUnresolvedReferences
    from Autodesk.Revit.DB import ElementSet
    # noinspection PyUnresolvedReferences
    from Autodesk.Revit.UI import ExternalCommandData

    tmp_cmd_data = FormatterServices.GetUninitializedObject(ExternalCommandData)
    tmp_cmd_data.Application = HOST_APP.uiapp
    # tmp_cmd_data.IsReadOnly = False
    # tmp_cmd_data.View = None
    # tmp_cmd_data.JournalData = None

    command_instance = cmd_class()
    return command_instance.Execute(tmp_cmd_data, '', ElementSet())
Esempio n. 2
0
 def lookup(self, element):
     if not self.RevitLookup:
         print 'RevitLookup not installed. Visit https://github.com/jeremytammik/RevitLookup to install.'
         return
     if isinstance(element, int):
         element = self.revit.ActiveUIDocument.Document.GetElement(
             ElementId(element))
     if isinstance(element, ElementId):
         element = self.revit.ActiveUIDocument.Document.GetElement(element)
     if isinstance(element, list):
         elementSet = ElementSet()
         for e in element:
             elementSet.Insert(e)
         element = elementSet
     form = self.RevitLookup.Snoop.Forms.Objects(element)
     form.ShowDialog()
# get the Id of the level
levelUnwrappedId = levelUnwrapped.Id
# filter elements by the unwrapped level id
levelFilter = ElementLevelFilter(levelUnwrappedId)

# alias areaFilter, for areas (not rooms) we will want to exclude
areaFilter = AreaFilter()
# change to room filter if you want svg of areas not rooms
#areaFilter = RoomFilter()
# collect elements to be excluded
areaExcludes = fec(doc).WherePasses(areaFilter).ToElements()
# convert to a list if not allready so
areaExcludes = list(areaExcludes)

# create empty set and list to store elements in
element_set = ElementSet()
excludes = List[ElementId]()
# check if there are any areas to exclude
if len(areaExcludes) == 0:
    # if there are no areas to exclude then
    # filter for levelFilter and filterArea0
    filters = LogicalAndFilter(levelFilter, filterArea0)
# otherwise if there are areas to exclude
else:
    # for each item in areaExcludes
    for i in areaExcludes:
        # use set to add items to excluded list
        element_set.Insert(i)
        elemIter = element_set.ForwardIterator()
        elemIter.Reset()
        while elemIter.MoveNext():
Esempio n. 4
0
 def snoop(self, element):
     elementSet = ElementSet()
     elementSet.Insert(element)
     form = self.RevitLookup.Snoop.Forms.Objects(elementSet)
     form.ShowDialog()