LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Scripting: find slide orientation programmatically

Solved!
Go to solution

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

_____________________________________
www.azinterface.net - Interface-based multiple inheritance for LabVIEW OOP
0 Kudos
Message 1 of 13
(439 Views)

You can use the rectangular bounds to see if the width is larger than the height.

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 2 of 13
(422 Views)

@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.

_____________________________________
www.azinterface.net - Interface-based multiple inheritance for LabVIEW OOP
0 Kudos
Message 3 of 13
(418 Views)

@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:

raphschru_0-1720102144870.png

 

Regards,

Raphaël.

0 Kudos
Message 4 of 13
(413 Views)

Yes, exactly.

_____________________________________
www.azinterface.net - Interface-based multiple inheritance for LabVIEW OOP
0 Kudos
Message 5 of 13
(394 Views)

The only way I found was by using the private "Basic Object Flags".

Not sure about the corner cases though:

 

raphschru_0-1720103914415.png

 

An officially supported method would be better...

Message 6 of 13
(376 Views)
Solution
Accepted by _Y_

@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:

raphschru_0-1720102144870.png

 

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.

paul_a_cardinale_0-1720106335509.png

 

Message 7 of 13
(369 Views)

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.

     

Message 8 of 13
(320 Views)

@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

0 Kudos
Message 9 of 13
(291 Views)

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

 

 

 

 

slide-orientation.png

0 Kudos
Message 10 of 13
(276 Views)