示例#1
0
def LocationShift(doc, point):
    cPoint = point
    basePt = doc.ActiveProjectLocation.GetProjectPosition(XYZ(0, 0, 0))
    ew = basePt.EastWest
    ns = basePt.NorthSouth
    ele = basePt.Elevation
    angle = basePt.Angle
    basexyz = [ew, ns, ele, angle]
    rotationTransform = Transform.CreateRotation(XYZ.BasisZ, angle)
    translationVector = XYZ(ew, ns, ele)
    translationTransform = Transform.CreateTranslation(translationVector)
    finalTransform = translationTransform.Multiply(rotationTransform)
    aPoint = Transform.CreateRotation(XYZ.BasisZ, angle).OfPoint(XYZ(cPoint.X, cPoint.Y, cPoint.Z))
    bPoint = XYZ(aPoint.X + ew, aPoint.Y + ns, aPoint.Z + ele)
    return(bPoint)
示例#2
0
__doc__ = 'Select the shared point of the model '\
          'This is helpful check project info'

# input ---------------------
path = 'C:\\Users\\loum\\Documents\\Pyscripts\\'
ew = doc.ActiveProjectLocation.GetProjectPosition(XYZ(
    0, 0, 0)).EastWest * float(-1.0)
ns = doc.ActiveProjectLocation.GetProjectPosition(XYZ(
    0, 0, 0)).NorthSouth * float(-1.0)
elevation = doc.ActiveProjectLocation.GetProjectPosition(XYZ(
    0, 0, 0)).Elevation * float(-1.0)
angle = doc.ActiveProjectLocation.GetProjectPosition(XYZ(
    0, 0, 0)).Angle * float(-1.0)
rotationTransform = Transform.CreateRotation(XYZ.BasisZ, angle)
translationVector = XYZ(ew, ns, elevation)
translationTransform = Transform.CreateTranslation(translationVector)
finalTransform = translationTransform.Multiply(rotationTransform)
count = 0
outLst = []
# Just to be sure how many points will be created and each list are the same length
print(len(Pointdata.pointX))
print(len(Pointdata.pointY))
print(len(Pointdata.pointZ))

# Transaction Start
t = Transaction(doc, 'Add CLash Points')

# Clash point Creation
FSymbol = DB.FilteredElementCollector(doc) \
    .OfClass(clr.GetClrType(FamilySymbol)) \
    .ToElements()
示例#3
0
文件: script.py 项目: jtpils/pyApex
def run(sel, location_option):
    logger.info("Location option: %s " % location_option)
    docs = __revit__.Application.Documents
    # where to copy
    src_doc = __revit__.ActiveUIDocument.Document
    docs = filter(lambda d: not d.IsLinked and d != src_doc, docs)
    trg_docs = forms.SelectFromList.show(docs,
                                         name_attr='Title',
                                         title='Documents to paste selection',
                                         button_name='Paste',
                                         multiselect=True)
    null_point_src = None
    null_point_cat = None
    if location_option == "Project Base Point":
        null_point_cat = BuiltInCategory.OST_SharedBasePoint
    elif location_option == "Shared Site Point":
        null_point_cat = BuiltInCategory.OST_ProjectBasePoint

    if null_point_cat:
        null_point_src = FilteredElementCollector(
            src_doc).WhereElementIsNotElementType().OfCategory(
                null_point_cat).WhereElementIsNotElementType().ToElements()
        if len(null_point_src) == 0:
            logger.warning(
                "Point for location option wasn't found in source document. Default alignment will be used"
            )

    for trg_doc in trg_docs:
        logger.debug(trg_doc)
        logger.debug(len(trg_doc.Title))
        s = "Copy %d elements from %s to %s" % (len(sel), src_doc.Title,
                                                trg_doc.Title)
        print(s)
        # logger.info(s) # TODO Fix - cannot log cyrylic project name

        # Transform
        transform_vector = None
        if null_point_src:
            null_point_trg = FilteredElementCollector(
                trg_doc).WhereElementIsNotElementType().OfCategory(
                    null_point_cat).WhereElementIsNotElementType().ToElements(
                    )
            if len(null_point_trg) == 0:
                logger.warning(
                    "Point for location option wasn't found in target document. Document will be skipped"
                )
                continue
            # _transform_vector = null_point_trg[0].GetTransform().BasisX - null_point_src[0].GetTransform().BasisX
            print(null_point_trg[0].BoundingBox[null_point_trg[0]])
            transform_vector = Transform.CreateTranslation(
                null_point_trg[0].BoundingBox.Min -
                null_point_src[0].BoundingBox.Min)

        t = Transaction(
            trg_doc,
            __title__ + " - %d elements from %s" % (len(sel), src_doc.Title))
        t.Start()
        try:
            ElementTransformUtils.CopyElements(src_doc, List[ElementId](sel),
                                               trg_doc, transform_vector, None)
            t.Commit()
        except Exception as exc:
            t.RollBack()
            logger.error(exc)