From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to align control A to control B?

Hello.  I am attempting to align controls on a front panel (see attached).  It appears that I need something more than the alignment tools on the toolbar, or a different strategy... What I typically do in UML tools is to align a single column of controls (such as the "Pulse Width" row) by placing the highest and lowest control where I want them and then distribute the column evenly.  Then I align the top and bottom rows to the top and bottom controls, and distribute the other columns evenly.  However, LabVIEW appears to use an averaging algorithm to align items rather than using one item as the baseline (e.g. the first or last item selected).  So I end up doing an iteration exercise which leaves me with carpal tunnel syndrome and a desire to post on the forum for a better way 🙂

 

Thanks,

-Jamie

0 Kudos
Message 1 of 10
(4,203 Views)
There are actually two distribution buttons: one distributes based on object centers the other based on the gaps between the objects. These two techniques use different algorithms.

Have you tried both?

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 10
(4,188 Views)

And both do a lousy job when dealing with controls with differing sizes as shown in the attached image.  If the column headers (Pulse Width, etc.) were implemented as labels or captions on the first row of controls it would be even worse.

 

I think there are some suggestions posted on the Idea Exchange requesting improvements in the way the alignment and distribution tools work, but they do not seem to be gaining much traction.

 

If I were a conspiracy theorist, I would suspect that the UI department at NI was being paid off by someone who benefitted from programmers with carpal tunnel.  However, I have met some of the UI developers and know that they are good people.

 

Lynn

0 Kudos
Message 3 of 10
(4,182 Views)

Yes I have.  The problem is that I can't align a control to another control's location, only to some mean location.  So if I want to align controls in a grid fashion, I have to iteratively use the distribute and align functions.

0 Kudos
Message 4 of 10
(4,178 Views)

Would Scripting allow you to place controls exactly where you wanted?  If so, you could use Scripting to place controls exactly where you wanted (do I hear an echo?).

 

Bob Schor

0 Kudos
Message 5 of 10
(4,176 Views)

Aligning all these controls in two dimensions is like herding cats.

 

A better apporach is to use higher structures. For example you could use a 2D array of numerics and a 1D array of switches. Or you could create a cluster with a boolean and three numeric controls (or a horizontal 1D array of three controls), then create a vertical 1D array of those clusters. If you combine the top labels into one large label with spaces, they will be always be aligned horizontally. If you use the caption of the array container for labeling, it will remain grouped with the control. (Make sure to watch the font settings and avoid symbolic fonts, so the font sizes don't change on other system, but that's a different discussion)

 

If you make the containers transparent, it won't look much different to what you have. If anything, it will make more efficient use of the available area.

 

Not only will things stay perfectly aligned, it is likely that your diagram is also significantly simplified, replacing piles of wires and terminals with  a much smaller number.

Message 6 of 10
(4,160 Views)

Yes, Altenbach, this is why you are a Knight -- you go right to the heart of the problem and state the (what should be obvious to the rest of us) logical suggestion!

 

Bob Schor

0 Kudos
Message 7 of 10
(4,131 Views)

Reasonable, but an "align to" option would also solve the problem.  I've used UML/SysML tools that do this to pretty good effect.

0 Kudos
Message 8 of 10
(3,964 Views)

If I use an array of switches, how do I use the individual switches to drive an event structure?

0 Kudos
Message 9 of 10
(3,921 Views)
Use a value changed event on the array, compare new and old from the event data node, and find the changed element. Then use a case structure to act accordingly.
0 Kudos
Message 10 of 10
(3,911 Views)