Search - User list
Full Version: How to convert detail attributes into a wall of text
Root » Technical Discussion » How to convert detail attributes into a wall of text
tutumannyaque
Hi! I'm building my pergola and designing it beforehand in Houdini of course.
I'm having a little trouble converting all my detail attributes into a wall of text into a font node like so:

From this:

To this:



For now I've typed all the text by hand just to take a screenshot by I would like it to be done automotically.
Any ideas?
Thanks so much!
anon_user_40689665
Try details(), however in this case its more typing than direct data-entry into the font sop.

If there's heaps of items you can parse a csv to point attributes, format the table as a detail string, then read the whole thing into font in one hit.
toadstorm
This isn't too bad with a little Python. You'll have more flexibility formatting your strings and such with Python over HScript.

Assuming your detail attributes already exist on some node, you just have to create an expression on the Text attribute of your Font SOP, then right-click and change the expression language to Python. Then try this code:

node = hou.node("../attribwrangle1") # this should point to the node with the detail attrs
geo = node.geometry()

detail_attrs = geo.globalAttribs()
output = ""
if detail_attrs:
    for attr in sorted(detail_attrs, key=lambda x: x.name()):
        value = geo.attribValue(attr)
        out = "{} = {}".format(attr.name(), value)
        output = output + out + "\n"

return output

Python's string format function is great, you can do a lot with it beyond just simple substitution.
tutumannyaque
toadstorm
This isn't too bad with a little Python. You'll have more flexibility formatting your strings and such with Python over HScript.

Assuming your detail attributes already exist on some node, you just have to create an expression on the Text attribute of your Font SOP, then right-click and change the expression language to Python. Then try this code:

node = hou.node("../attribwrangle1") # this should point to the node with the detail attrs
geo = node.geometry()

detail_attrs = geo.globalAttribs()
output = ""
if detail_attrs:
    for attr in sorted(detail_attrs, key=lambda x: x.name()):
        value = geo.attribValue(attr)
        out = "{} = {}".format(attr.name(), value)
        output = output + out + "\n"

return output

Python's string format function is great, you can do a lot with it beyond just simple substitution.


Omg this works perfectly thank you so much!
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB