Houdini Triangle Grid using HOM

Thought I’d post my first little (of many) experiments.
A piece of code that helped me create the header image in Houdini 11.
Sort of a hello_site example.

I plan on posting something every week or so. As in a tutorial or small experiment that helped me achieve a certain task or goal. At work or for fun.

To get this snippet of code working, create a Python geometry operator in Houdini: “file” > “new operator type”. Select: “Python Type” and “Geometry Operator”. Give the new operator a name and location on disk (default is your Houdini home / “otl”

You should be presented with a screen asking you to create new parameters and place your code.

For this piece of code to work, 4 parameters are required:

  • name: width, type:  int, default: 20
  • name: slope, type:  int, default: 1
  • name: size,   type:  float, default: 1
  • name: attr_name, type: string, default: pscale

On their own these parameters do absolutely nothing. We need to bind them in our code. See the example below on how to achieve this. All code is commented and can be placed directly in the python operator.

After pasting or writing the code, click on “Accept”. You should now be able to tab and find the operator. The “width” defines the amount of base points, the   “slope” defines the triangle angle slope, the “size” specifies the element size (or space between points). The attributre “pscale” is created and set for each point. When copying a cube on to every point, the cube should have the correct size because of the pscale attribute.

# This code is called when instances of this SOP cook.
geo = hou.pwd().geometry()

# Evaluate our parameters
width = hou.pwd().evalParm("width")
slope = hou.pwd().evalParm("slope")
size  = hou.pwd().evalParm("size")
attrib_name = hou.pwd().evalParm("attr_name")

# Initialize base numbers
height = 0
offset = 0

# Add point attribute
attrib = geo.addAttrib(hou.attribType.Point, attrib_name, 1.0)

# Compensate for slope
width_offset  = 2*slope
slope_offset  = 1*slope

# Compensate for center
center_offset = float(width) / 2.0

# Calculate Point Grid
while width > 0:
    for i in range(width):

        # Create the point
        point = geo.createPoint()

        # Get the x position
        x_position = float(offset+i) - center_offset

        # Set the point in space
        point.setPosition((x_position*size,height*size,0))

        # Add point attribute
        point.setAttribValue(attrib, size)
    
    # Compensate the position every iteration
    width -= width_offset
    height += 1
    offset += slope_offset

81 thoughts on “Houdini Triangle Grid using HOM

  1. That is amusing, my first opinion never got published here.
    I will just wanted to say that I truly appreciate reading through your site posts.
    I aspire to be able to write like you one day.

  2. I truly appreciate this post. I have been looking everywhere for this! Thank goodness I found it on Bing. You have made my day! Thank you again

  3. Its like you read my mind! You appear to know a lot about this, like you wrote the book in it or something. I think that you can do with a few pics to drive the message home a little bit, but other than that, this is magnificent blog. An excellent read. I will definitely be back.

  4. Hey There. I found your blog using msn. This is a really well written article. I’ll make sure to bookmark it and come back to read more of your useful info. Thanks for the post. I will definitely return.

  5. I precisely wanted to say thanks once more. I am not sure what I could possibly have undertaken in the absence of these aspects shown by you on such a area of interest. It had become an absolute challenging dilemma for me, however , noticing this skilled avenue you processed the issue made me to jump with joy. Extremely thankful for your work and then trust you really know what an amazing job you were getting into teaching others all through your webblog. Probably you haven’t encountered all of us.

  6. I have been browsing online more than 3 hours today, yet I never found any interesting article like yours. It’s pretty worth enough for me. In my view, if all webmasters and bloggers made good content as you did, the internet will be much more useful than ever before.

  7. I do believe all of the ideas you’ve presented for your post. They are really convincing and can certainly work. Nonetheless, the posts are too quick for newbies. May just you please lengthen them a bit from subsequent time? Thank you for the post.

  8. I’m still learning from you, while I’m trying to reach my goals. I definitely liked reading everything that is posted on your site.Keep the information coming. I liked it!

  9. I am no longer positive where you’re getting your info, however great topic. I must spend some time studying more or understanding more. Thank you for great info I was in search of this information for my mission.

  10. I cling on to listening to the news lecture about getting boundless online grant applications so I have been looking around for the most excellent site to get one. Could you tell me please, where could i find some?

  11. Its like you read my mind! You seem to know so much about this, like you wrote the book in it or something. I think that you can do with a few pics to drive the message home a little bit, but other than that, this is excellent blog. An excellent read. I will definitely be back.

  12. I am now not positive where you are getting your info, but great topic. I needs to spend a while studying more or working out more. Thank you for magnificent info I used to be on the lookout for this info for my mission.

  13. hello there and thank you for your info – I have certainly picked up something new from right here. I did however expertise some technical points using this site, as I experienced to reload the web site lots of times previous to I could get it to load properly. I had been wondering if your web hosting is OK? Not that I am complaining, but slow loading instances times will often affect your placement in google and could damage your high quality score if ads and marketing with Adwords. Well I’m adding this RSS to my e-mail and can look out for much more of your respective interesting content. Make sure you update this again soon..

  14. Just desire to say your article is as amazing. The clearness in your post is just nice and i can assume you are an expert on this subject. Fine with your permission allow me to grab your feed to keep up to date with forthcoming post. Thanks a million and please carry on the rewarding work.

  15. It¡¦s really a great and useful piece of information. I am satisfied that you just shared this useful information with us. Please stay us up to date like this. Thanks for sharing.

  16. Great weblog here! Additionally your web site quite a bit up very fast! What host are you the use of? Can I am getting your associate hyperlink in your host? I wish my site loaded up as quickly as yours lol

  17. Nice read, I just passed this onto a colleague who was doing some research on that. And he actually bought me lunch because I found it for him smile Therefore let me rephrase that: Thank you for lunch!

  18. certainly like your website however you have to check the spelling on quite a few of your posts. Several of them are rife with spelling issues and I in finding it very bothersome to tell the reality however I¡¦ll surely come again again.

  19. I actually wanted to jot down a simple comment in order to thank you for all of the nice tricks you are giving at this website. My particularly long internet investigation has at the end been recognized with reputable tips to exchange with my contacts. I would repeat that most of us site visitors actually are very blessed to exist in a remarkable community with many outstanding individuals with very helpful concepts. I feel truly blessed to have encountered your weblog and look forward to many more thrilling moments reading here. Thank you once more for everything.

  20. Thank you a bunch for sharing this with all of us you really recognize what you’re speaking about! Bookmarked. Kindly also seek advice from my site =). We could have a link change arrangement between us!

  21. My brother suggested I might like this website. He was entirely right. This post truly made my day. You can not imagine just how much time I had spent for this info! Thanks!

  22. We are a group of volunteers and starting a new scheme in our community. Your website provided us with valuable information to work on. You’ve done an impressive job and our whole community will be thankful to you.

  23. Thank you a lot for sharing this with all folks you really recognise what you are talking approximately! Bookmarked. Please also visit my website =). We can have a hyperlink change arrangement among us!

  24. What i don’t understood is actually how you are no longer really much more well-preferred than you might be right now. You are very intelligent. You already know therefore considerably in the case of this subject, made me in my view believe it from so many numerous angles. Its like men and women are not fascinated except it is something to accomplish with Girl gaga! Your personal stuffs outstanding. Always handle it up!

  25. I am now not sure where you’re getting your information, but good topic. I needs to spend a while studying much more or understanding more. Thanks for fantastic info I was on the lookout for this info for my mission.

  26. I was just searching for this info for a while. After six hours of continuous Googleing, at last I got it in your website. I wonder what’s the lack of Google strategy that don’t rank this type of informative web sites in top of the list. Normally the top sites are full of garbage.

  27. Hiya, I’m really glad I have found this info. Today bloggers publish just about gossips and web and this is really irritating. A good site with exciting content, this is what I need. Thank you for keeping this site, I’ll be visiting it. Do you do newsletters? Can’t find it.

  28. It is in reality a nice and useful piece of info. I am satisfied that you simply shared this useful info with us. Please keep us informed like this. Thanks for sharing.

  29. you are in point of fact a excellent webmaster. The web site loading pace is amazing. It kind of feels that you are doing any distinctive trick. In addition, The contents are masterwork. you have performed a excellent task in this matter!

  30. I have not checked in here for a while since I thought it was getting boring, but the last several posts are good quality so I guess I will add you back to my everyday bloglist. You deserve it my friend :)

  31. Hi there I discovered your page by mistake when i searched AOL for this concern, I have to tell you your site is quite helpful I also enjoy the design, it is amazing!

  32. Its like you read through my thoughts! You appear to know a great deal about this, like you wrote the e book in it or a little something. I think that you simply could do with some pics to generate the message house somewhat, but besides that, this can be excellent blogging site. An incredible examine. Sick undoubtedly be back again.

  33. I savour, cause I discovered exactly what I used to be taking a look for. You’ve ended my 4 day long hunt! God Bless you man. Have a great day. Bye

  34. excellent publish, very informative. I’m wondering why the other experts of this sector do not notice this. You should proceed your writing. I’m sure, you have a great readers’ base already!

  35. Fantastic goods from you, man. I’ve understand your stuff previous to and you are just extremely excellent. I really like what you have acquired here, certainly like what you are stating and the way in which you say it. You make it entertaining and you still take care of to keep it smart. I can’t wait to read far more from you. This is actually a wonderful web site.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>