Copy to points and variants
4915 6 0-
- robsdesign
- Member
- 240 posts
- Joined: March 2015
- Online
Hi, I'm using a copy-to-points and variants setup but would like "unique" variants. I've attached a hip file showing a rough example of what I'm trying to do. I've used colours as a visual aid but the actual project uses different geometry, not colours.
I have 12 variants and 12 "Clusters" and would like to choose 5 variants for each "Cluster" by using a seed.
Cluster 1 has repeated variant #7 which I don't want.
Cluster 2 has "unique" variants. (none are repeated)
Cluster 2 only works because that particular seed just happens to work. Rather than try random seeds to find working ones, I'd like to make sure there are no repeats, no matter what seed is used.
One option would be to use a working seed and shift each variant by 1,2,3 etc but I can't quite figure it out.
I'd appreciate any suggestions.
Rob
I have 12 variants and 12 "Clusters" and would like to choose 5 variants for each "Cluster" by using a seed.
Cluster 1 has repeated variant #7 which I don't want.
Cluster 2 has "unique" variants. (none are repeated)
Cluster 2 only works because that particular seed just happens to work. Rather than try random seeds to find working ones, I'd like to make sure there are no repeats, no matter what seed is used.
One option would be to use a working seed and shift each variant by 1,2,3 etc but I can't quite figure it out.
I'd appreciate any suggestions.
Rob
-
- Enivob
- Member
- 2658 posts
- Joined: June 2008
- Offline
Python can help in that case because it is easy to check if a value is in a list or not.
The HUGE CAVEAT, of course, is don't submit more points than you have variants or you will generate an infinite loop. The while will never be able to exit. So don't do that.
The HUGE CAVEAT, of course, is don't submit more points than you have variants or you will generate an infinite loop. The while will never be able to exit. So don't do that.

import random geo = hou.pwd().geometry() # Create the point attribute value, giving it a default value and store the returned hou.Attrib object. rnd_variant = geo.addAttrib(hou.attribType.Point, "variant", 0) sample_set = [0,1,2,3,4,5,6,7,8,9,10,11] result_set = [] for point in geo.points(): n = False while(n==False): value = random.sample(sample_set, 1) if value not in result_set: result_set.append(value) n = True for index,point in enumerate(geo.points()): value = result_set[index] point.setAttribValue(rnd_variant, value)
Edited by Enivob - Feb. 21, 2022 10:33:37
Using Houdini Indie 20.5
Windows 11 64GB Ryzen 16 core.
nVidia 3060RTX 12BG RAM.
Windows 11 64GB Ryzen 16 core.
nVidia 3060RTX 12BG RAM.
-
- robsdesign
- Member
- 240 posts
- Joined: March 2015
- Online
-
- tamte
- Member
- 9421 posts
- Joined: July 2007
- Offline
-
- robsdesign
- Member
- 240 posts
- Joined: March 2015
- Online
tamte
Didn't check the file, but you should be able to use Sort SOP and randomize point numbers and Enumerate SOP to create variant attrib from those point numbers
Randomized point numbers never repeat, it's like a shuffle
I'm probably not understanding or doing it correctly because that results in only variants 0 to 4 being used on each cluster.
ie. if I have 5 points and 12 variants to choose from...
5 points = variants 0,1,2,3,4 whereas I needed 5 points = variants 3,6,8,9,10 etc.
-
- tamte
- Member
- 9421 posts
- Joined: July 2007
- Offline
in that case it would be easiest like this
- make sure your variants are already packed (so 1 point with variant attribute per variant)
- Sort SOP shuffle your variants
- Attrib Copy SOP the variant to your scatter points (this will pick first N shuffled variant numbers in case there is more variats, or it will cycle if there is less variants)
- profit
- make sure your variants are already packed (so 1 point with variant attribute per variant)
- Sort SOP shuffle your variants
- Attrib Copy SOP the variant to your scatter points (this will pick first N shuffled variant numbers in case there is more variats, or it will cycle if there is less variants)
- profit
Tomas Slancik
CG Supervisor
Framestore, NY
CG Supervisor
Framestore, NY
-
- robsdesign
- Member
- 240 posts
- Joined: March 2015
- Online
-
- Quick Links


I have no clue about Python so I wouldn't have figured that out.