Ejemplo n.º 1
0
    def familyExtrusion(familyDoc,
                        curveArrayArray,
                        sketchPlane,
                        height=10.0,
                        location=False,
                        isSolid=True):
        """
		Creates an extrusion within a given family document.

		Args:
			familyDoc (object): A reference to a family document.
			curveArrayArray (object): A Revit API ``CurveArrArray``.
			sketchPlane (object): A Revit API ``SketchPlane``.
			height (float, optional): The extrusion height. Defaults to 10.0.
			location (object, optional): A Revit API ``XYZ`` point object. Defaults to False.
			isSolid (bool, optional): Soild (True) or void (False). Defaults to True.

		Returns:
			object: The extrusion element.
		"""
        import revitron
        if not location:
            location = revitron.DB.XYZ(0, 0, 0)
        if revitron.Document(familyDoc).isFamily():
            extrusion = familyDoc.FamilyCreate.NewExtrusion(
                isSolid, curveArrayArray, sketchPlane, height)
            revitron.DB.ElementTransformUtils.MoveElement(
                familyDoc, extrusion.Id, location)
            return extrusion
Ejemplo n.º 2
0
    def getPath(self):
        """
        Gets the path of the linked document.

        Returns:
            string: The path on disk
        """   
        import revitron
             
        try:
            return revitron.Document(self.element.GetLinkDocument()).getPath()
        except:
            pass
Ejemplo n.º 3
0
 def testGetDuplicateInstances(self):
     if revitron.REVIT_VERSION > '2018':
         family = self.fixture.createGenericModelFamily()
         p1 = revitron.DB.XYZ(0, 0, 0)
         p2 = revitron.DB.XYZ(0, 0, 0)
         p3 = revitron.DB.XYZ(10, 0, 0)
         instance1 = self.fixture.createGenericModelInstance(family, p1)
         instance2 = self.fixture.createGenericModelInstance(family, p2)
         instance3 = self.fixture.createGenericModelInstance(family, p3)
         duplicatesOld = revitron.Document().getDuplicateInstances(True)
         duplicatesYoung = revitron.Document().getDuplicateInstances()
         toStr = utils.idsToStr
         self.assertEquals(str(instance1.Id.IntegerValue),
                           toStr(duplicatesOld))
         self.assertEquals(str(instance2.Id.IntegerValue),
                           toStr(duplicatesYoung))
         self.assertFalse(
             str(instance3.Id.IntegerValue) in toStr(duplicatesOld) +
             toStr(duplicatesYoung))
     else:
         revitron.Log().warning(
             'Method revitron.Document().getDuplicateInstances() requires Revit 2018 or newer!'
         )
Ejemplo n.º 4
0
 def testIsFamily(self):
     self.assertFalse(revitron.Document().isFamily())
Ejemplo n.º 5
0
from collections import defaultdict
import System.Windows


def addFields(components, fields):
    for field in fields:
        if field == '---':
            components.append(Separator())
        else:
            key = revitron.String.sanitize(field)
            components.append(Label(field))
            components.append(TextBox(key, Text=config.get(key)))
    return components


if not revitron.Document().isFamily():

    config = revitron.DocumentConfigStorage().get('revitron.export',
                                                  defaultdict())

    components = addFields([], [
        'Sheet Export Directory', 'Sheet Naming Template',
        'Sheet Size Parameter Name', 'Default Sheet Size',
        'Sheet Orientation Parameter Name'
    ])

    orientationField = 'Default Sheet Orientation'
    orientationKey = revitron.String.sanitize(orientationField)
    orientations = ['Landscape', 'Portrait']
    default = orientations[0]
    if config.get(orientationKey) in orientations:
                if _element.get(
                        'Family and Type').IntegerValue in typeIdsInteger:
                    if _element.isNotOwned():
                        _element.delete()
                        deletedCount = deletedCount + 1
                    else:
                        print(
                            'The duplicate instance {} is owned by another user!'
                            .format(output.linkify(elementId)))
            except:
                pass
            pb.update_progress(counter, max_value)
    return deletedCount


duplicates = revitron.Document().getDuplicateInstances()

if not duplicates:
    sys.exit()

familyTypes = []

for elementId in duplicates:
    familyTypes.append(_(elementId).get('Family and Type'))

dialog = SelectType(list(set(familyTypes)), 'Select family types to be purged')
selectedTypeIds = dialog.show(True)
typeIdsInteger = []

if not selectedTypeIds:
    sys.exit()