Maya: connect output of a float attribute to the input of the 3D type tool

I’m banging my head trying to figure out if it’s even possible.
I have this cube that I use for character reference height and whenever I change its height attribute I want it to change the text of the text object that I have on its top.

For now I have this script:

#creates a height reference box for characters

import maya.cmds as mc
import maya.mel as mel

def run():
    mc.select(cl=1)
    mc.circle(c=[0, 0, 0], nr=[0, 1, 0], sw=360, r=60, d=3, ut=0, tol=0.01, s=8, ch=1)
    moveCtrl = mc.ls(sl=1, type="transform")[0]
    cube = mc.polyCube(w=60, h=1, d=60)
    
    mc.addAttr(moveCtrl, ln="height", at="double", min=0, dv=180)
    mc.setAttr(moveCtrl+".height", e=1, keyable=True)
    
    md = mc.createNode("multiplyDivide")
    mc.connectAttr(moveCtrl+".height", md+".input1X", f=1)
    mc.connectAttr(moveCtrl+".height", cube[1]+".height")
    mc.connectAttr(md+".outputX", cube[0]+".translateY")
    
    mc.setAttr(md+".operation", 2)
    mc.setAttr(md+".input2X", 2)
    

    #create text object
    mc.CreatePolygonType()
    typeObject = mc.ls(sl=1)
    type3d = mc.listConnections( type= "type")
    
    #edit the text
    txt = "180"
    txt += " cm"
    hexVersion = getSpacedHexFromString(txt)
    mc.setAttr(type3d[0] + ".textInput", hexVersion, type="string")
    mc.setAttr(type3d[0] + ".alignmentMode", 2)
    
    
    
    
    # connect the move control's height attribute to the type object's translation y
    mc.connectAttr(moveCtrl+".height", typeObject[0]+".translateY")
    # connect the move control's height attribute to the type object's text input
    # mc.connectAttr(moveCtrl+".height", type3d[0] + ".textInput")
    
    mc.parent(cube[0], moveCtrl)
    mc.parent(typeObject[0], moveCtrl)
    mc.select(moveCtrl, r=1)






def getSpacedHexFromString(txt):
    hexVersion = ""
    for i in txt:
        character = i
        hexCharacter = character.encode("hex")
        hexVersion = hexVersion + " " + hexCharacter
    return hexVersion

Where the function “getSpacedHexFromString” converts a string to a hex number to be passed into the input of the text field. It just seems so stupid that you can’t pass in a string from the start.

Well, I resorted to actually setting up a digital counter with sdk:s and saving the setup to a file that is imported instead.

If anyone wants it, let me know.