Exemplo n.º 1
0
def get_all_grids(group_by_direction=False,
                  include_linked_models=False,
                  doc=None):
    doc = doc or HOST_APP.doc
    target_docs = [doc]
    if include_linked_models:
        target_docs.extend(get_all_linkeddocs())

    all_grids = []
    for tdoc in target_docs:
        if tdoc is not None:
            all_grids.extend(
                list(
                    DB.FilteredElementCollector(tdoc).OfCategory(
                        DB.BuiltInCategory.OST_Grids).
                    WhereElementIsNotElementType().ToElements()))

    if group_by_direction:
        direcs = {db.XYZPoint(x.Curve.Direction) for x in all_grids}
        grouped_grids = {}
        for direc in direcs:
            grouped_grids[direc] = [
                x for x in all_grids if direc == db.XYZPoint(x.Curve.Direction)
            ]
        return grouped_grids
    return all_grids
Exemplo n.º 2
0
def get_gridpoints(grids=None, include_linked_models=False, doc=None):
    doc = doc or HOST_APP.doc
    source_grids = grids or get_all_grids(
        doc=doc, include_linked_models=include_linked_models)
    gints = {}
    for grid1 in source_grids:
        for grid2 in source_grids:
            results = framework.clr.Reference[DB.IntersectionResultArray]()
            intres = grid1.Curve.Intersect(grid2.Curve, results)
            if intres == DB.SetComparisonResult.Overlap:
                gints[db.XYZPoint(results.get_Item(0).XYZPoint)] = \
                    [grid1, grid2]
    return [GridPoint(point=k, grids=v) for k, v in gints.items()]