Jump to content
SDietrich

How to relate the terminals and endpoints of a wire?

Recommended Posts

Hi all,

 

a quick drop plugin I am currently working on needs to traverse along wires. Using Wire.Joints[] one gets a good representation of where the wire runs. And of course at every Endpoint there is a terminal, one that is returned by Wire.Terms[]. But how can I say which terminal is at which endpoint? The order is different for the endpoints and for the terminals. :(

 

I could use the position and bounds to find out which terminal overlaps which endpoint, but this feels like some voodoo that will go wrong sooner or later.

 

Any ideas or suggestions?

 

FYI: I already have SuperSecretPrivateSpecialStuff=True.

Share this post


Link to post
Share on other sites

On each terminal you can use the "Is Source" property node and it will tell you if it is the source, or sink of a wire.  By the way I believe index 0 is always a source and the last element is always a sink.

Share this post


Link to post
Share on other sites

Thanks hooovahh, but I think have to elaborate a little more.

 

At the moment, I don't care for source and sinks. The idea is more to go along a wire and sum up the lengths in pixels or the number of junctions, bends and so on. So I end up having an endpoint and I need to know, what terminal it is connected to so I can find the object and work on from there, e.g. highlighting it or getting the name of the object or so.

So if the first endpoint always is the source (and a non-broken wire has only one source) that is a good start. But I also need to get the terminals for the sinks.

Share this post


Link to post
Share on other sites

I have not found much that goes wrong by relating the position to the endpoint.  The only tricky thing to remember is that one endpoint can have more than one terminal.  

 

Of course I have tried for years to convince people that no purpose is served by allowing terminals, tunnels and the like to be overlapping but I am basically alone on that one.  Basically I have stopped sharing scripting code because I get tired of having to check for these kind of special cases that complicate and obfuscate my code.  I prefer to keep it for personal use only and then I know that most of these corner cases are ruled out.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.