Help with python script to create MEP Fabrication Containment (wire cable tray)

Hey everyone! I put together a script to create a wire basket, but I’m running into a type error with the arguments in ‘Create’. I’m feeling a bit stuck and could really use some guidance to figure this out. Thanks so much in advance!:
What i want:

The other nodes are there just to see what button i wanted:


Here is the script:

import clr
clr.AddReference('RevitAPI')
clr.AddReference('RevitServices')
from Autodesk.Revit.DB import *
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

level = IN[0]

TransactionManager.Instance.EnsureInTransaction(doc)

errores = []

try:
    # Obtener la configuración de fabricación:
    config = FabricationConfiguration.GetFabricationConfiguration(doc)

    # Verificar que la configuración es válida:
    if config:
        # Obtener todos los servicios de fabricación:
        allservices = config.GetAllServices()

        if allservices and len(allservices) > 0:
            fabrication_service = None
            for service in allservices:
                if service.Name == "Electrical: Wire Basket":
                    fabrication_service = service
                    break



            # Obtener un botón del servicio (grupo 0 boton 0 para charofil recto):
            fabservicebutton = fabrication_service.GetButton(0, 0)

            # Verificar que se obtuvo el botón correctamente:
            if fabservicebutton:

                fabrication_part = FabricationPart.Create(doc, fabservicebutton, 110/304.8, 110/304.8, 311)
            else:
                errores.append("No se pudo obtener el botón de servicio de fabricación.")
        else:
            errores.append("No se encontraron servicios de fabricación en la configuración.")
    else:
        errores.append("No se pudo obtener la configuración de fabricación.")
except Exception as e:
    errores.append(f"Error durante la ejecución: {e}")


TransactionManager.Instance.TransactionTaskDone()


if errores:
    OUT = errores
else:
    OUT = fabrication_part

@Urabe 311? ElementId(311) would make more sense. i checked that overload, it says document, services button, double, double, ElementId.

I also tried with “level.Id” but still the same error

Never mind, I understand now that I was not passing the data in the format requested. Here’s the script for the community. Please note that I’m using the metric system in my fabrication parts, which is why there’s a division by ‘304.8’ in width and depth:

import clr
clr.AddReference('RevitAPI')
clr.AddReference('RevitServices')
from Autodesk.Revit.DB import *
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument


level = IN[0]
size = IN[1]
if len(size) > 1 and level:
    width, depth = size
elif len(size) < 1:
    OUT = 'Necesitas 2 datos en in[1] (ancho y profundidad)...'
elif not level:
    OUT = 'Falta nivel en in[0]...'
else:
    OUT = 'No hay data detectada en las entradas...'

TransactionManager.Instance.EnsureInTransaction(doc)

errores = []

try:
    # Obtener la configuración de fabricación:
    config = FabricationConfiguration.GetFabricationConfiguration(doc)

    if config:
        # Obtener todos los servicios de fabricación:
        allservices = config.GetAllServices()

        if allservices and len(allservices) > 0:
            fabrication_service = None
            for service in allservices:
                if service.Name == "Electrical: Wire Basket":
                    fabrication_service = service
                    break

            # Verificar si se encontró el servicio de fabricación:
            if fabrication_service:
                # Verificar la cantidad de botones y grupos disponibles:
                button_count = fabrication_service.GetButtonCount(0)
                if button_count > 0:
                    group_index = 0
                    button_index = 0

                    # Verificar si los índices son válidos:
                    if 0 <= group_index and  0 <= button_index < button_count:
                        fabservicebutton = fabrication_service.GetButton(group_index, button_index)

                        # Verificar que se obtuvo el botón correctamente:
                        if fabservicebutton:
                            element_id = ElementId(level.Id)
                            fabrication_part = FabricationPart.Create(doc, fabservicebutton, width/304.8, depth/304.8, element_id)
                        else:
                            errores.append("No se pudo obtener el botón de servicio de fabricación.")
                    else:
                        errores.append("Índices del grupo o botón fuera de rango.")
                else:
                    errores.append("No hay condiciones disponibles en el servicio de fabricación seleccionado.")
            else:
                errores.append("No se encontró el servicio de fabricación especificado.")
        else:
            errores.append("No se encontraron servicios de fabricación en la configuración.")
    else:
        errores.append("No se pudo obtener la configuración de fabricación.")
except Exception as e:
    errores.append(f"Error durante la ejecución: {e}")


TransactionManager.Instance.TransactionTaskDone()


if errores:
    OUT = errores
    try:
        archivo = open("your_own_path_xd\\Errores_en_fabricationparts.txt", "w", encoding="utf8")
        for string in errores:
            archivo.write(f"{string}\n")
    except Exception as e:
        print(e)
    finally:
        archivo.close()

else:
    OUT = fabrication_part