Jump to content

Specify where to bend wire?


Recommended Posts

Forgive me but I am just starting to learn about scripting today. I can open a VI, get a reference to the block diagram and to a VI or terminal and move it to a new location. Woo hoo!

My question is that when I move a node the wire will bend in the middle. Can I specify where to bend the wire? A picture is worth a thousand words. (One of the best features of LabVIEW)

post-17905-0-96995600-1315242120.png

Link to comment

Thanks everyone. I can not figure out is how to move a wire segment.

I looked at the Joints[] property. It returns an array of clusters containing info on all the segments but it is read only. Is there a way to identify a segment in order to move it, like when you single click on a wire and use the arrow keys?

I' recalling it from memory, but I'm pretty sure that it is not possible. Exactly as in snippet I posted, you have to delete whole the wire first and then recreate it. You may of course use information from Joints[] for recreating (retrieved before deletion).

Link to comment

In LV10 I use the Move Selected Objects Method of the TopLvlDiag Class (ie. Block Diagram). I use the Joints[] property to find the segment I want. Typically I index the array to select the starting joint. I will use the maximum of the Left/Right/Up/Down indices to find the opposite end of the segment. Using those two points I would use the Point2Rect.vi followed by RectCentroid.vi (both in vi.lib) to find the center of the segment, and then use Point2Rect.vi again with the incremented and decremented centroid value. This defines a very small rect around the center of the wire segment. Then I would use the Clear Selection Method (TopLvlDiag), followed by MakeSelectionFromRect using the rect you found, followed by Move Selected Objects with appropriate Delta X/Y. Finally Clear Selection.

I could post an example later, this is from memory. Better learning experience recreating it yourself. I have added other features like finding the segment closest to a given point, and double checking that the selection process does not add other objects. It is easy to get the terminals selected on shorter segments which are hidden.

My other point is that you are usually a much, much happier scripter if you let LV deal with the wiring (BD cleanup, Clean Wire method, autowire). Futzing with wiring in scripting is a spaghetti factory, this simple task is already a screen wide on a BD.

  • Like 1
Link to comment

I could post an example later, this is from memory. Better learning experience recreating it yourself. I have added other features like finding the segment closest to a given point, and double checking that the selection process does not add other objects. It is easy to get the terminals selected on shorter segments which are hidden.

I think I can figure out most of it. An example would be helpful especially with the check for add other objects. I will try creating it myself before looking at the example though. I just started playing around with scripting and really want to learn about it. I have had lots of fun writing code that writes code but only with, eh.., scripting languages. It really is too bad that LabVIEW scripting requires the development environment but it is understandable and I gather that this will not change.

My other point is that you are usually a much, much happier scripter if you let LV deal with the wiring (BD cleanup, Clean Wire method, autowire). Futzing with wiring in scripting is a spaghetti factory, this simple task is already a screen wide on a BD.

Yes I am starting to see that. But it is good that there is flexibility in case you want to do something crazy like weird wires. That still blows me away especially with highlight execution.

Link to comment

I think I can figure out most of it. An example would be helpful especially with the check for add other objects.

The check is really simple, after you make the selection use the SelectionList[] property of the TopLvlDiag. Use a For Loop to compare each object to the Wire reference (Equals? is very handy when dealing with refs). If it is not equal, use the Remove From Selection Method (TopLvlDiag).

If you are nudging a wire you can sometimes get away with selecting the entire wire, but it can be handy to move a single bend around.

Link to comment

Join the conversation

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

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.