07-04-2024 08:36 AM
Front panel of a VI has a numeric indicator belonging to class Slide (Class ID = 21). Can its orientation (horizontal or vertical) be determined programmatically, i.e. using scripting suctions? Unfortunately I'm out of guesses.
Thank you
Solved! Go to Solution.
07-04-2024 09:01 AM
You can use the rectangular bounds to see if the width is larger than the height.
07-04-2024 09:07 AM
@santo_13 wrote:
You can use the rectangular bounds to see if the width is larger than the height.
Yes, This is what do I use now. However, the method is not general.
For example a very wide vertical Slide can have the width larger then the height. Such a Slide will be detected as horizontal.
07-04-2024 09:10 AM - edited 07-04-2024 10:08 AM
@santo_13 wrote:
You can use the rectangular bounds to see if the width is larger than the height.
Won't work in case you have a tank that looks like this:
Regards,
Raphaël.
07-04-2024 09:39 AM
Yes, exactly.
07-04-2024 10:08 AM - edited 07-04-2024 10:09 AM
07-04-2024 10:19 AM
@raphschru wrote:
@santo_13 wrote:
You can use the rectangular bounds to see if the width is larger than the height.
Won't work in case you have a tank that looks like this:
Regards,
Raphaël.
That code is risky because the bit definitions are subject to change between versions of LV. The attached code is much less fragile.
07-04-2024 10:16 PM
I've not done enough with Scripting to be familiar with "Basic Object Flags". Am I correct that Paul's "better solution" involves creating two "test cases", a "known horizontal" slider and a "Known vertical" slider and using their (known, and presumably different) "Basic Object Flags" to distinguish Horizontal from Vertical sliders?
Bob Schor
Noto to self -- learn more about scripting, which I used many years ago to write LabVIEW code that looked at a 4-Worksheet Excel Template and built LabVIEW code appropriate for using this Template to record multiple trials in a behavioral "Where is the Target?" study.
07-05-2024 05:09 AM
@Bob_Schor wrote:
I've not done enough with Scripting to be familiar with "Basic Object Flags". Am I correct that Paul's "better solution" involves creating two "test cases", a "known horizontal" slider and a "Known vertical" slider and using their (known, and presumably different) "Basic Object Flags" to distinguish Horizontal from Vertical sliders?
I would say yes, it is using templates to distinguish between vertical and horizontal slides
07-05-2024 06:57 AM - edited 07-05-2024 07:04 AM
to add my 2 cents, we could calculate the eigenvalues of the centered bounding box coordinates of the slide control, because:
- The larger eigenvalue indicates the direction of the longer side. If the larger eigenvalue indicates the variance in the y-direction, then the rectangle is vertically oriented.
- If the larger eigenvalue indicates the variance in the x-direction, then the rectangle is horizontally oriented.
- This is a simplification that assumes the eigenvalues correctly reflect the variance along the principal axes, which is the case for a rectangle with known opposite corners and orthogonal sides