Beyond the copy SOP:
Packed Primitives are a rather recent addition. What's great is that thy let you "pack" any kind of geometry into a new primitive. When you have a lot of individual stuff to randomize and to render, packed primitives can be a (if not the only) way to speed things up dramatically.
As in the grass post, whenever there are thousands of different copies, the glorious copy SOP grinds to a halt. Now how to use VEX to emulate that?
Firstly, pack that box. And, yeah, use a copy SOP to scatter it.
Then in a primitive SOP:
It really gave me a hard time figuring it out, but after reading http://www.sidefx.com/docs/houdini14.0/vex/functions/setprimintrinsic it becomes rather clear. The missing piece is setattrib set like this:
Of course you can set the merge mode to something other than "set", for instance to multiply if you want to inherit the normal orientation of your copied primitives.
A more complete example could look like this:
Because I like degrees so much, my random is fitted to a rotation range that I like, like -180, 180 and than converted to radians and fed into rotate.
in VEX land:
vector scale = {1,1,1};
scale = scale * rand(@P);
matrix3 m_trans = primintrinsic(0, "transform", @ptnum);
matrix scalem = maketransform(0, 0, {0,0,0}, {0,0,0}, scale, @P);
m_trans *= matrix3(scalem);
//overall randomness: 20 deg around Y
float roat_rand = radians(fit(rand(@P),0,1,-20,20));
rotate(m_trans, roat_rand, {0,1,0});
setprimintrinsic(0, "transform", @ptnum, m_trans);