Here is the way that I create a weight attribute from the expression (p63) that came from a weight feature
Listed below are two expressions
p63=40333.8302886129
weight_attribute=ug_setPartAttrValue("WEIGHT",format("%0.0f",p63))
p63 is the expression that contains the weight
"WEGHT" is the name of the attribute that is created
The second zero in 0.0f is how many decimal places are shown in the attribute - in this case it is shown as a whole number - I forgot what the first zero is used for.
You can do this same type of thing with any other expression that you have.
weight_attribute can be named anything that you want - it does not affect the name of the attribute