Jump to content
breadbox

conecting points

Recommended Posts

Im looking to create some sort of wire tool to add a sort of wire or cable between buildings. my process is to generate a point from each building, and then id like to connect them together, then use a poly wire to connect the lines.

so i can create my points but how do i connect them? would be nice to have some distance threshold so each point will only look for points within a given radius and maybe possibly only connect lines to a given number as well?

any clues on what to use to connect points in this way?

  • Like 1

Share this post


Link to post
Share on other sites

the Add SOP

make a group of two points and feed that group in to the add SOP

have a look at the help card for examples of uses.

Share this post


Link to post
Share on other sites

What Michael said. Add SOP and then pass through a Resample SOP to add divisions.

Share this post


Link to post
Share on other sites

indeed add was what I was looking to try to use.

this is where I am at right now.

Add_sop.png

so it looks like it adds in succession by point number to create one long line. I can also skip numbers and make shorter chains but its always by point number. but how to make spider web networks so that taken a given point it will join a line to say the 4 nearest PT neighbors and well would ignore the order of points so pt_1 could connect to pt_20 if it happened to be close in proximity?

Share this post


Link to post
Share on other sites

AddGroup.png

here i try to make a group with a bounding volume to get nearest neighbors. and I use the close polygon in the add sop to get more connections, but you can see not all the possible connections are made. (no connection between pt_4 and p_17). still not quite there yet, id like to somehow procedurally determine the groups better and make all possible connections to neighbors.

Share this post


Link to post
Share on other sites

hmmm...verging into areas I'm not super good at...

however, you could have a look at the nearpoint function...

or maybe use the ray sop to find the distances....or vops...

and at this point I'm out... :\

not knowing exactly what you're doing I can only guess but if it's one point per building then you can put information into each point based on the building - like a group name or an attribute, then build an ordered group to put into the add sop...

Share this post


Link to post
Share on other sites

Many ways to approach this but invariably if you build your points correctly, then stitching them up in the end should be easier.

Now that you know that Add SOP can connect points in a few powerful ways (Groups of N Points, Skip every Nth point, Each Group Separately, By Attribute), you can rework the way you create the points to suit any of these methods.

If you are attaching points on the buildings, create them in a way that makes it easier to connect. There is also the issue of avoiding buildings. You don't want cables to penetrate through buildings (or maybe you do).

You may have to resort to point clouds to find nearest neighbor and use the By Attribute method.

Share this post


Link to post
Share on other sites

really my main objective is to learn a bit of houdini better. I do have a specific task Im trying to do but let me back up and try to make the simplest case as if i can learn the simple principals maybe ill be able to apply to a more complex generator.

I made a file most simple case. create 5 points and try to connect all the points. so want to do this in a very specific way. connect point 0 to point 1, point 0 to point 2, etc.

so in my hip file I manually make add chains that do this then merge just so we can be clear about the task. Then I try to do this by using a 'for loop' because Id like to be able to do this with 1000 of points and also vary up the groups and connection points. so I use a partition to create one group for each point. that way i was thinking the for loop would read the groups and be able to loop through. but I cant figure out what variables to assign in the add sop within the for loop to create this effect. file explains it better I think so if anyone can take a look at this id appreciate it.

I think still I'm struggling with a few fundamental concepts in houdini for example. if i want to loop through successive tasks, should i create one group with all my points, primitives objects whatever in it? and then the loop will sort through the one group taking each member of the one group and running the function, or should I sort all the points, primitives, objects into multiple groups so that each group only has one item and the loop goes through a "NameGroup" successive loop if that makes sense? because i think 'for loop' only works with groups not points, in the drop down there is only the options for each group, each attribute value or each number?

AddLoop.hipnc

Edited by breadbox

Share this post


Link to post
Share on other sites

is this really that hard to do? been trying to figure out how one would go about it but come up with nothing.

Share this post


Link to post
Share on other sites

figures none sooner than 10 min after i post this i came up with a solution. so i use a for each loop. and then I use the `stamp("..", "FORVALUE",0)`

so it took me a while to figure i needed the backticks for the stamp expression to evaluate properly. cant attach my file currently but i can upload later.

so my next step is to query the number of points so i can evaluate the for each loop the correct number of times. I dont think i can do this directly? so im using AttributeCreate using $NPT to grab the number of points and store that as an detail variable using integer. then I need to use this attribute in the for each loop however its not working. it works when i apply the $POINTNUM variable to a transform attribute to test the attribute. for example I have 5 points, so i create the attribute called pointNum, then in the transform Y I put $POINTNUM so that evaluates as a 5 as expected. now when I try to put that $POINTNUM in the foreach sop number range it doesnt evaluate as a 5?

Edited by breadbox

Share this post


Link to post
Share on other sites

here is the file. shows the problem. i create an attribute for collecting the number of points. then recall that variable in a transform node to test it. it works! then try to use that same expression in a for each node but it doesn't read the expression. says "undefined varable"

Share this post


Link to post
Share on other sites

and here is the result!

detail("../attribcreate_pointNum","pointNum",0)

ok so fortunately found a tutorial that went over creating custom attributes and using them. for some reason I can just use the $POINTNUM in the transform node but in certain cases like in the for each I must reference the detail("../nodeName","nodeVariable") stuff.

so many rules to referencing expressions. not enough just to create a variable, have to type in a whole string of characters to refrence the node, then the variable, then a default value, just to use the variable properly. all the while keeping very careful to not miss a capital letter or mis-spell. ugg

houdini you confuse me.

AddLoop_Attribute.hipnc

Edited by breadbox

Share this post


Link to post
Share on other sites

The answer is that some operators can take varying variables as parameter inputs and some don't. The ForEach SOP's top parameter level doesn't work with variables directly.

One way to tell is to open the help for the operator (hit the ? in the parms). If you don't see a section for Local Variables for that particular SOP geometry operator, then chances are this SOP doesn't support local variables.

You need to use the detail() expression to fetch the detail attribute from the input SOP.

AddLoop_Attribute_jw.hipnc

Share this post


Link to post
Share on other sites

super! thanks for the detailed explanation, now I can get on to the next task in the sequence if i can remember what that is at this point!

Share this post


Link to post
Share on other sites

I agree with you on this. I found your post after starting to connect objects by wires. Ot seems like there really must be an easier way to add each end of a wire to 2 objects.

Share this post


Link to post
Share on other sites

If you set up the points in such a way that they are numbered in the way you want,

you may only need one add node.

Before you just need to think how to define which buildings should be connected.

if you simply want to connect everything, you can also try "tedrahedalize"

Share this post


Link to post
Share on other sites

For the simple purpose of exercising and better learn Houdini I decided to give it a try, and I came up a with network of points each connecting to its n neighbours (with or without point already processed, controlled by numrange2 of nested foreach). Really not sure if this is a valid way to use the foreach SOPS though...

I'm sure there is a cleaner way to obtain the same results, even avoiding using nested for each SOP.

connecting_neighbours.hipnc

Edited by Tranguz

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×