Scatter 250 rocks using HF scatter

   176   2   0
User Avatar
Member
95 posts
Joined: Feb. 2016
Offline
I have 250 rocks I exported to disk in a sequence. Rocks numbered from 1 to 250.
Is there a way to import these and scatter them from disk using HF scatter? I want to use HF scatter because it recognises other scattered object and places them accordingly.
Thanks
User Avatar
Member
29 posts
Joined: Aug. 2015
Offline
The way i usually load files from disk, assuming they are in the same folder:

- use a python node to read from a directory, create a point per file found that i want with the path and name as point attributes.

import os

node = hou.pwd()
geo = node.geometry()

#get dir contents
dir = node.evalParm('pPath') # from path parm
dirContent = os.listdir(dir)

#create pt attribs
attribPath = geo.addAttrib(hou.attribType.Point,'filePath','')
attribName = geo.addAttrib(hou.attribType.Point,'fileName','')

#loop over dir contents
for f in dirContent :

    p = os.path.join(dir,f)
    
    #make sure it is a file and type is bgeo
    if os.path.isfile(p) and os.path.splitext(p)[1] == '.bgeo':
        pnt = geo.createPoint()
        pnt.setAttribValue(attribPath, os.path.abspath(p) )
        pnt.setAttribValue(attribName, f )

Then a for loop, iterate over points. For each point load the file given the path in the point's attrib. Load directly or as packed disk prim. Add class or name attrib based on loop iteration.

The HF Scatter node allows to define pieces by attribute. However i found name attribute doesn't work, so it possibly doesn't like string attribs. Use an integer attrib like class. Using this method you can scatter your 250 objects in one pass.

One bug i found however is that the point relaxation is done before object instancing, so i think the relax does not take into account the actual instance size, just the scale value in the “variability” section. Im not sure how to fix that without cracking open the scatter tool.
User Avatar
Member
95 posts
Joined: Feb. 2016
Offline
That's great thanks so much Nicolas, I'll give it a go.
  • Quick Links