def processKeysValues(keys, values):
    if len(keys) != len(values):
        raise Exception(
            "DictionaryByKeysValues - Keys and Values do not have the same length"
        )
    stl_keys = []
    stl_values = []
    for i in range(len(keys)):
        if isinstance(keys[i], str):
            stl_keys.append(keys[i])
        else:
            stl_keys.append(str(keys[i]))
        if isinstance(values[i], list) and len(values[i]) == 1:
            value = values[i][0]
        else:
            value = values[i]
        if isinstance(value, bool):
            if value == False:
                stl_values.append(topologic.IntAttribute(0))
            else:
                stl_values.append(topologic.IntAttribute(1))
        elif isinstance(value, int):
            stl_values.append(topologic.IntAttribute(value))
        elif isinstance(value, float):
            stl_values.append(topologic.DoubleAttribute(value))
        elif isinstance(value, str):
            stl_values.append(topologic.StringAttribute(value))
        elif isinstance(value, list):
            l = []
            for v in value:
                if isinstance(v, bool):
                    l.append(topologic.IntAttribute(v))
                elif isinstance(v, int):
                    l.append(topologic.IntAttribute(v))
                elif isinstance(v, float):
                    l.append(topologic.DoubleAttribute(v))
                elif isinstance(v, str):
                    l.append(topologic.StringAttribute(v))
            stl_values.append(topologic.ListAttribute(l))
        else:
            raise Exception(
                "Error: Value type is not supported. Supported types are: Boolean, Integer, Double, String, or List."
            )
    myDict = topologic.Dictionary.ByKeysValues(stl_keys, stl_values)
    return myDict
def processItem(item):
    spaces = item.getSpaces()
    vertexIndex = 0
    cells = []
    apertures = []
    shadingFaces = []
    shadingSurfaces = item.getShadingSurfaces()
    for aShadingSurface in shadingSurfaces:
        shadingFaces.append(surfaceToFace(aShadingSurface))
    for count, aSpace in enumerate(spaces):
        osTransformation = aSpace.transformation()
        osTranslation = osTransformation.translation()
        osMatrix = osTransformation.rotationMatrix()
        rotation11 = osMatrix[0, 0]
        rotation12 = osMatrix[0, 1]
        rotation13 = osMatrix[0, 2]
        rotation21 = osMatrix[1, 0]
        rotation22 = osMatrix[1, 1]
        rotation23 = osMatrix[1, 2]
        rotation31 = osMatrix[2, 0]
        rotation32 = osMatrix[2, 1]
        rotation33 = osMatrix[2, 2]
        spaceFaces = []
        surfaces = aSpace.surfaces()
        for aSurface in surfaces:
            aFace = surfaceToFace(aSurface)
            aFace = topologic.TopologyUtility.Transform(
                aFace, osTranslation.x(), osTranslation.y(), osTranslation.z(),
                rotation11, rotation12, rotation13, rotation21, rotation22,
                rotation23, rotation31, rotation32, rotation33)
            #aFace.__class__ = topologic.Face
            subSurfaces = aSurface.subSurfaces()
            for aSubSurface in subSurfaces:
                aperture = surfaceToFace(aSubSurface)
                aperture = topologic.TopologyUtility.Transform(
                    aperture, osTranslation.x(), osTranslation.y(),
                    osTranslation.z(), rotation11, rotation12, rotation13,
                    rotation21, rotation22, rotation23, rotation31, rotation32,
                    rotation33)
                # aperture.__class__ = topologic.Face
                apertures.append(aperture)
            addApertures(aFace, apertures)
            spaceFaces.append(aFace)
        spaceCell = topologic.Cell.ByFaces(spaceFaces)
        print(count, spaceCell)
        if not spaceCell:
            spaceCell = topologic.Shell.ByFaces(spaceFaces)
        if not spaceCell:
            spaceCell = topologic.Cluster.ByTopologies(spaceFaces)
        if spaceCell:
            # Set Dictionary for Cell
            stl_keys = []
            stl_keys.append("TOPOLOGIC_id")
            stl_keys.append("TOPOLOGIC_name")
            stl_keys.append("TOPOLOGIC_type")
            stl_keys.append("TOPOLOGIC_color")
            stl_values = []
            spaceID = str(aSpace.handle()).replace('{', '').replace('}', '')
            stl_values.append(topologic.StringAttribute(spaceID))
            stl_values.append(topologic.StringAttribute(aSpace.name().get()))
            spaceTypeName = "Unknown"
            red = 255
            green = 255
            blue = 255
            if (aSpace.spaceType().is_initialized()):
                if (aSpace.spaceType().get().name().is_initialized()):
                    spaceTypeName = aSpace.spaceType().get().name().get()
                if (aSpace.spaceType().get().renderingColor()):
                    red = aSpace.spaceType().get().renderingColor().get(
                    ).renderingRedValue()
                    green = aSpace.spaceType().get().renderingColor().get(
                    ).renderingGreenValue()
                    blue = aSpace.spaceType().get().renderingColor().get(
                    ).renderingBlueValue()
            stl_values.append(topologic.StringAttribute(spaceTypeName))
            l = []
            l.append(topologic.IntAttribute(red))
            l.append(topologic.IntAttribute(green))
            l.append(topologic.IntAttribute(blue))
            stl_values.append(topologic.ListAttribute(l))
            dict = topologic.Dictionary.ByKeysValues(stl_keys, stl_values)
            _ = spaceCell.SetDictionary(dict)
            cells.append(spaceCell)
    return [cells, apertures, shadingFaces]