Set finish height and other informations in label

Hello, I’m contacting you because I’m currently coding a python code to return information in a label for a staircase landing (finished landing height, gross landing height and landing thickness). The code has no error and I get results that display the values with watch, but nothing is displayed in the label. I’d like to point out that I have shared parameters that group together the three measurements mentioned at the beginning, i.e. finished bearing height, gross bearing height and bearing thickness, with common categories and number data for using dimensions.

In my case, I’m French, so the names of my variables are in French. Here’s a quick translation:

H_finie /Hauteur finie palier=Finished_height
H_brute/Hauteur brute palier=gross_height
Epaisseur/Epaisse mesuresur palier=thickness

Attached is the python code and a snapshot of my dynamo code

Thanks in advance for your reply
the code here:

# Importation des bibliothèques nécessaires
import clr
import os
import subprocess
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

# Accéder à la liste des points entrée
H_brute = IN[0]
H_finie = IN[1]

# Calculer les épaisseurs
epaisseurs = H_finie - H_brute
# Affichage des résultats ou traitement supplémentaire ici
# Pour cet exemple, nous les envoyons simplement à la sortie pour les voir dans le nœud 'Watch'
# Construisez la chaîne de sortie pour écrire dans le fichier
data = "Hauteur brute palier: {}\nHauteur finie palier: {}\nÉpaisseur palier: {}".format(H_finie,H_brute, epaisseurs)

# Définissez le chemin du fichier sur le bureau de l'utilisateur (à modifier selon vos préférences)
file_path = os.path.expanduser('~\\Desktop\\Alti_Palier.txt')

# Écrire dans le fichier texte
with open(file_path, 'w') as file:
    file.write(data)

# Ouvrir le fichier texte avec le programme par défaut sur Windows
subprocess.Popen(['notepad.exe', file_path])

# Sortie du nœud Python (pas nécessaire pour la fonctionnalité d'écriture/ouverture de fichier)
print(IN[0], IN[1])
OUT = H_brute,H_finie,epaisseurs, file_path


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

# Obtenez le document Revit actuel à partir de Dynamo
doc = DocumentManager.Instance.CurrentDBDocument

# Supposons que 'element' est un seul objet Revit et 'H_brutes', 'H_finies', 'epaisseurs'
# sont des listes de valeurs que vous souhaitez appliquer à cet élément.

transaction = Transaction(doc, 'Set Parameter Values')
transaction.Start()

try:
    # Supposons que 'element' est un objet Revit unique et 'H_brutes', 'H_finies', 'epaisseurs'
    # sont des listes des valeurs.
    for H_brute, H_finie, epaisseurs in zip(H_brutes, H_finies, epaisseurs):
        param = element.LookupParameter('Hauteur brute palier')
        if param and not param.IsReadOnly:
            param.Set(H_brute)
        
        param = element.LookupParameter('Hauteur finie palier')
        if param and not param.IsReadOnly:
            param.Set(H_finie)
        
        param = element.LookupParameter('Épaisseur palier')
        if param and not param.IsReadOnly:
            param.Set(epaisseurs)

    transaction.Commit()
except Exception as e:
    print(e)
    transaction.RollBack()

Welcome!
Most of this looks good, but there are a few glaring issues and things I’m confused on:

  • you have 4 inputs but only define 2 of them in your code
  • element is being called but never defined
  • what would presumably be the element input is a function with the wrong input connected
  • you use a zip function with 2 undefined variables

The biggest issue though is that you run OUT before any of your functionality. Anything after OUT will not execute - it should always be the last line of your code.