LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Programmatically change the width of block diagram elements

Any thoughts on...

 

Programmatically change the width of block diagram elements

0 Kudos
Message 1 of 7
(3,004 Views)

For the string box: there is an option if you right click it "Size to text"

For FOR Loop: "Auto grow"

Nghtcwrlr

---------------------------------------------------------------------------------------------
*************************************
---------------------------------------------------------------------------------------------
0 Kudos
Message 2 of 7
(2,995 Views)

In my post, I've used a term 'Programmatically' also I'm interested to match the width of all three elements...
Neither 'Size To Text' nor 'Auto Grow' will help.

0 Kudos
Message 3 of 7
(2,991 Views)

I stumbled on this post, which was very helpful in how I solved this. It is not easy, there is a lot of things to be added to the case structure but it is possible.

Hope this helps.

setwidth_BD.png


CLA CTAChampionI'm attending the GLA Summit!
Subscribe to the Test Automation user group: UK Test Automation Group
0 Kudos
Message 4 of 7
(2,971 Views)

You've stumbled upon a little-known fact -- programmatically getting a String Indicator to "fit the string" at run-time is a fairly difficult proposition.  I posted some code on the Forum to do that, but it was complicated and not very "obvious".  It also was (as I recall) somewhat dependent on which set of Front Panel Palettes (Classic, System, Modern, Silver) you were using ...

 

Bob Schor

Message 5 of 7
(2,946 Views)

@.aCe. wrote:

setwidth_BD.png


A couple of comments on this code:

 

  1. You probably don't need to extract the width from the master rect, since you get it as a property.
  2. I would highly recommend not doing the transition through the flattened string. The best option is To More Specific Class. In some classes, the relevant properties exist but are not exposed through VI Server and then you can sometimes access them by type casting the reference to a class which does have them (which is basically what you're doing), but that's potentially dangerous and should generally be avoided.
  3. The basic idea behind the code is that there are no general width and height properties that you can use to set this. Each class has specific properties for this, which is why you need the cast.

 

If this is something that the OP wants to do often, making it into a right click shortcut (in LV 2015) or a Quick Drop keyboard shortcut is advisable.


___________________
Try to take over the world!
0 Kudos
Message 6 of 7
(2,933 Views)

@tst wrote:

A couple of comments on this code:

  1. You probably don't need to extract the width from the master rect, since you get it as a property.
  2. I would highly recommend not doing the transition through the flattened string. The best option is To More Specific Class. In some classes, the relevant properties exist but are not exposed through VI Server and then you can sometimes access them by type casting the reference to a class which does have them (which is basically what you're doing), but that's potentially dangerous and should generally be avoided.
  3. The basic idea behind the code is that there are no general width and height properties that you can use to set this. Each class has specific properties for this, which is why you need the cast.

If this is something that the OP wants to do often, making it into a right click shortcut (in LV 2015) or a Quick Drop keyboard shortcut is advisable.


Hello tst,

Thanks for the comments, I'd like to explain why I did what I did.

1. As a matter of fact, Area Width is the wrong property to look at as it may include width of labels etc if present. So width from Master Rectangle is what should be used for comparison.

2. I am aware of this. As mentioned in my post and by Bob, the link explains why 'To More Specific Class' (Which I have used in the ForLoop without any issues as expected) throws an error.

 

 


CLA CTAChampionI'm attending the GLA Summit!
Subscribe to the Test Automation user group: UK Test Automation Group
0 Kudos
Message 7 of 7
(2,927 Views)