Showing posts with label instance. Show all posts
Showing posts with label instance. Show all posts

Tuesday, 9 April 2024

instance ass files (not paths)

use instancefile to access geo saved somewhere...

in a point wrangle - 


  s@instancefile=chs("path");


now with the geo node, you gotta add the instance tab and turn on fast instancing.





Monday, 26 September 2022

@scale

 I can't believe I've never used @scale....

@pscale is useful for uniformly scaling the instance/copied object onto a point. But what if you need to adjust the scale on a per-axis basis?

@scale=set(1,2,3);

this will scale the object by 2 in the Y, and 3 in the Z

woop woop

Friday, 20 November 2020

instance path

Say you have some points and you want to instance an object from disk to them..

in a point wrangle-

 s@instancepath=chs("path");

create the input box and type in the path of your object eg: c:\dave\ball.obj


beneath the point wrangle, add an instance node. ta da!

Friday, 21 February 2020

time shifting copy stamps

Needed to time offset an alembic which was being copy-to-points.
The methodology is the same as a previously posted thing, but the copy-to-points node needs to be situated inside the For Each loop



if you squint, you'll see there's an attribrandomize node. I've made an integer attribute called TimeOffset and ..randomised it..
In the timeshift node, I make a spare input and point it to ../PT, which holds said TimeOffset values

The value for the timeshift is : $FF+point(-1, 0, "timeOffset", 0)

so, we take the current frame and add the individual time offset value to it.

Shweet.

Monday, 2 September 2019

Checking if your instancefile files exist

Checking if your instancefile files actually exist...Cos sometimes...they don't! Stolen from MikeB

Paste this into a Python node:



import os

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

geo.addAttrib(hou.attribType.Point,'exists',0)

for pt in geo.points():
    file = pt.attribValue('instancefile')
   
    if os.path.isfile(file):
        pt.setAttribValue('exists',1)
    else:
        pt.setAttribValue('exists',0)
   

Thursday, 18 April 2019

Copying different objects to points

Sometimes you need to copy a bunch of different objects to points. Eg. You have 5 variations of wood splinters and you're emitting them from a snapping plank.
Instead of using the slower copy stamp with random point values, you can use a ForEach loop and a Switch node..and of course a point wrangle.

Connect the objects to the Switch node. In a point wrangle, give each point an (random) integer value (eg "instanceID") ranging from 0 to the number of objects you have.
Make a ForEach network and connect the Point wrangle into the top. Create a null node directly after the start of the Foreach Begin. This will be a "temporary holder" node. It will carry the instanceID value to the Switch node. I've called it PT
The clever bit happens in the Switch node. In the parameter window, click on the cog wheel and add a Spare Input. This will create a new dialog box called Spare Input 0. Type in:

../PT

This will point the spare input to our temporary null & its instanceID value.
In the Select Input dialog box, type

point(-1, 0, "instanceID", 0)

here we are telling the Switch node to get a point attribute from input -1 (which is the spare dialog....which is pointing to the PT temporary null..). The attribute in question is instanceID.. NICE.
A purple arrow going from PT to Switch should have appeared now. This represents that link we've just made.

All that is left to do is to create a Copy To Points node & put the Switch output into the objects input & plug PT into the points input. Finally plug the output of all of that into the Foreach End.

Thursday, 9 November 2017

alternative to copy stamping

Copy Stamping is a bit slow, here's another way of copying things using point attributes.
EG - a bunch of points comprising of cubes, spheres and donuts.


  1. get a bunch of points!
  2. give them an id attribute eg 1,2,3,4..which will represent cube,sphere,donut. The attribute randomise node is quite good for this. There is a setting called Discrete Values which you can tweak with weighting. Eg. 20% value 1, 40%value 2, 40% value 3. Lets call the attribute ID
  3. Create a For-Each-Loop network. Set the mode to "points". By default it is set to process "pieces". Uncheck the use "name" bit. This is to do with the fracturing rigid body workflow.
  4. Connect the cube, sphere and donut to a switch node. In the index box type: point("../foreach1/",0,"ID",0)    this references the current point being processed by the foreach loop and reads it's corresponding ID value.
  5. Inside the foreach loop add a "copy to points" node. Connect the switch node to this.
  6. This should all work now!