rurik Posted October 2, 2012 Share Posted October 2, 2012 Hello I'm trying to achieve an effect where I can copy stamp a bunch of words from a text file into a Font SOP so that I can just keep adding words to the text file and have those words appear in my particle simulation. I'm assuming Python can help me here, does anybody have pointers to how I would go about doing that? Thanks! Quote Link to comment Share on other sites More sharing options...
lukeiamyourfather Posted October 2, 2012 Share Posted October 2, 2012 Check out these links. How to read text files with Python - http://docs.python.org/library/stdtypes.html#file-objects Get the node and parameter to modify - http://www.sidefx.com/docs/houdini12.1/hom/hou/Node#parm Change the parameter - http://www.sidefx.com/docs/houdini12.1/hom/hou/Parm#set 1 Quote Link to comment Share on other sites More sharing options...
rurik Posted October 2, 2012 Author Share Posted October 2, 2012 Thanks Luke Which node would I use to read in the text file? Sorry I'm very green with Houdini and Python...Would I be able to just use a file.open() inside the Copy SOP? Or would I need to open it elsewhere? Thanks so much, want to figure this out but am having trouble finding out where to start Alex Quote Link to comment Share on other sites More sharing options...
old school Posted October 2, 2012 Share Posted October 2, 2012 Sure. Python, custom expression. Both work. Python is far more expansive but to be different, I used a custom in-line expression to randomly pick over some words. If it's entire sentences or paragraphs with formatting, then use Python. In the attached example I used a variable to hold the text associated with each point and then passed that on to the Font SOP with a Copy Stamp SOP and for agruments sake, also used a For Each SOP as they are basically the same thing. I always use ForEach SOPs these days as most Artists just don't want to wrap their heads around Copy Stamping but just want things to work. Packaging up things in to the ForEach SOP is neat, tidy and self-contained. Copy SOP on the other hand can lead to spaghetti references that can be hard to follow as you are chasing stamp() and stamps() expressions potentially all over the place. word_list_stamped_on_points.hip 1 Quote Link to comment Share on other sites More sharing options...
old school Posted October 2, 2012 Share Posted October 2, 2012 Which node would I use to read in the text file? Sorry I'm very green with Houdini and Python...Would I be able to just use a file.open() inside the Copy SOP? Or would I need to open it elsewhere? In my above example you could host the Python Code right in the Attribute Create SOP to be quick and dirty. Another way would be to turn this in to an asset and use the asset's internal Python Module section to add your text reader in there then reference that function in the SOP network. You can also create a net new Python SOP that hosts the code to create the string attribute that then get's expanded in the Font SOP. Another approach is to put the Python function right in the Font SOP string field and do the work in there and just pass in the point number and bypass the point string attribute entirely. Good if you are processing millions of points. I do like to see the string right there on the point though... Quite a few ways to do this and they are all valid and will work just fine. 1 Quote Link to comment Share on other sites More sharing options...
magneto Posted October 2, 2012 Share Posted October 2, 2012 @old school: I didn't know most artists preferred the ForEach SOP. Given the same functionality, using the Copy SOP should lead to faster cooking/execution times over ForEach SOP, right? Of course I choose whichever makes more sense given the problem, which is mostly the Copy SOP for me Quote Link to comment Share on other sites More sharing options...
old school Posted October 2, 2012 Share Posted October 2, 2012 Yep the ForEach SOP is slightly slower and that is mainly the overhead of the Each SOP but that difference is mitigated with more complex set-ups. 1 Quote Link to comment Share on other sites More sharing options...
rurik Posted October 2, 2012 Author Share Posted October 2, 2012 Amazing, thanks so much! Quote Link to comment Share on other sites More sharing options...
rurik Posted October 3, 2012 Author Share Posted October 3, 2012 I just realized that instead of using the script OldSchool used in the Attribcreate, I could use something as simple as `arg("THE WORDS I WANT TO USE",$PT)' and get pretty much the same result...OldSchool's method is more powerful because using the floor method or any other filtering I could selectively leave out some of the words, but this shorter expression is probably easier to remember Thanks! Quote Link to comment Share on other sites More sharing options...
csp Posted November 20, 2012 Share Posted November 20, 2012 (edited) how is this possible to make that work with instance object on render time? I tried `points("/obj/instance", instancepoint(), "text")` in the fontSOP but it didn't work. I have attached a file word_list_stamped_on_points_instance.hip Edited November 20, 2012 by cparliaros Quote Link to comment Share on other sites More sharing options...
michael Posted November 20, 2012 Share Posted November 20, 2012 Usage instancepoint() This function takes no arguments. You can use this function in parameter expressions on objects being instanced (see point instancing). It returns the point number the object is being instanced onto. You can use this to vary object-level parameters (such as transforms or material overrides) between instances. You can not use this function at the surface level, because instancing only works at the object level. Quote Link to comment Share on other sites More sharing options...
csp Posted November 21, 2012 Share Posted November 21, 2012 You can not use this function at the surface level, because instancing only works at the object level. I recently started using instancing and I am keep forgetting that. Thanks. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.