SteveChandler Posted September 5, 2011 Report Share Posted September 5, 2011 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) Quote Link to comment
Popular Post vugie Posted September 6, 2011 Popular Post Report Share Posted September 6, 2011 It is not only important where to bend a wire, but also HOW to do it: Here is RCF plugin which does the job. Seriously, the Invoke Node you are searching for is "Create Described Wire": "Wire Desc" input is tricky one, because you have to specify coordinates of wire nodes in opposite way - as an array of (y,x) pairs... 5 Quote Link to comment
asbo Posted September 6, 2011 Report Share Posted September 6, 2011 It is not only important where to bend a wire, but also HOW to do it: I was going to tell him he was hosed, but I totally forgot about this example. Well met. Quote Link to comment
jcarmody Posted September 7, 2011 Report Share Posted September 7, 2011 I've been putting round corners on wires since this plugin was released. Thanks vugie Quote Link to comment
vugie Posted September 7, 2011 Report Share Posted September 7, 2011 I've been putting round corners on wires since this plugin was released. Thanks vugie I don't belive... IS IT REALLY BEING USED FOR SOMETHING OTHER THAN JUST FUN ??? Quote Link to comment
Popular Post jcarmody Posted September 7, 2011 Popular Post Report Share Posted September 7, 2011 I don't belive... IS IT REALLY BEING USED FOR SOMETHING OTHER THAN JUST FUN ??? Not strictly just for fun; I use it as a way to sneak around mental blocks. When one side of my brain thinks the other side is only playing, it lets its guard down long enough for me to solve what's stumping me. 3 Quote Link to comment
SteveChandler Posted September 7, 2011 Author Report Share Posted September 7, 2011 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? Quote Link to comment
vugie Posted September 7, 2011 Report Share Posted September 7, 2011 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). Quote Link to comment
Darin Posted September 7, 2011 Report Share Posted September 7, 2011 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. 1 Quote Link to comment
jcarmody Posted September 8, 2011 Report Share Posted September 8, 2011 (edited) I do this: ... to clean up the wire in a JKI RCF plugin that inserts this: This assumes that the wire is the shape I want it to be and I can simply move the whole thing. edit - I got help doing this here. Edited September 8, 2011 by jcarmody Quote Link to comment
Darin Posted September 8, 2011 Report Share Posted September 8, 2011 edit - I got help doing this here. I thought it was here: https://decibel.ni.com/content/thread/8293?tstart=30 Quote Link to comment
SteveChandler Posted September 8, 2011 Author Report Share Posted September 8, 2011 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. Quote Link to comment
Darin Posted September 8, 2011 Report Share Posted September 8, 2011 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. Quote Link to comment
jcarmody Posted September 9, 2011 Report Share Posted September 9, 2011 I thought it was here: https://decibel.ni.c.../8293?tstart=30 Doh! Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.