LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Scripting: Enum RingText.SizeToText Error 1029

Im using Scripting in LabVIEW 2023:

RingText.SizeToText can be set to write without a broken arrow. Also Help indicates that Permissions are Read/Write.

codelux_1-1736939247518.png

 

But when I run the script I get Error 1029: VI Server property is read-only.

Is this a Bug or am I missing something?

0 Kudos
Message 1 of 10
(127 Views)

Does your script attempt to change the properties of a control on its own front panel?  I expect the error is because the control is only editable during edit-time and your script is trying to do it during run-time.

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 2 of 10
(108 Views)

No it is adding to a newly created VI. The first Property Node is working as intended...

0 Kudos
Message 3 of 10
(90 Views)

The help for 'Size to Text?' says: 

Sets whether the size of the text object changes according to the text included. You can write this property only for free labels, control labels, and captions.

 

See https://www.ni.com/docs/en-US/bundle/labview-api-ref/page/properties-and-methods/vi-server/generic/g... 

0 Kudos
Message 4 of 10
(75 Views)

It is true that the help specifies: "Permissions: Read/Write" on this property, which effectively allows you to put the property node is the "Write" direction at edit time. However, it does not mean it is always writable at runtime. The help also clearly states: "You can write this property only for free labels, control labels and captions"... so not for a ring text.

 

Since LabVIEW uses the same generic "Text" class for labels, captions, ring texts, ... the compiler cannot know in advance whether this will be an instance of label, caption, ring text, or whatever... so the error will only happen at runtime. This is also coherent with the manual editing, since there is no option "Size To Text" when you right-click an Enum control.

 

The only option I see would be to precompute and write the ring text width according to the biggest item name.

"Get Text Rect.vi" from the Picture functions can help you compute the apparent size of any text, given the desired font, orientation, etc... :

 

raphschru_1-1736949752927.png

 

 

 

Regards,

Raphaël.

Message 5 of 10
(74 Views)

@raphschru wrote:

It is true that the help specifies: "Permissions: Read/Write" on this property, which effectively allows you to put the property node is the "Write" direction at edit time. However, it does not mean it is always writable at runtime. The help also clearly states: "You can write this property only for free labels, control labels and captions"... so not for a ring text.

 

Since LabVIEW uses the same generic "Text" class for labels, captions, ring texts, ... the compiler cannot know in advance whether this will be an instance of label, caption, ring text, or whatever... so the error will only happen at runtime. This is also coherent with the manual editing, since there is no option "Size To Text" when you right-click an Enum control.

 

The only option I see would be to precompute and write the ring text width according to the biggest item name.

"Get Text Rect.vi" from the Picture functions can help you compute the apparent size of any text, given the desired font, orientation, etc... :

 

raphschru_1-1736949752927.png

 

 

 

Regards,

Raphaël.


To make it more generic, I suggest this:

rt.png

Message 6 of 10
(60 Views)

Thanks Raphaël and Paul for your nice workaround solution. 😀

 

I still think LabVIEW behaves not as expected, as I did not choose SizeToText but RingText.SizeToText - so the RingText is explicitly there at edit time!

 

By the way: what would the result of  Read RingText.SizeToText mean? It seems to always be False...

0 Kudos
Message 7 of 10
(43 Views)

unfortunately I´m not successful at importing Paul´s snippet - does it work for somebody else?

0 Kudos
Message 8 of 10
(41 Views)

@code-lux wrote:

unfortunately I´m not successful at importing Paul´s snippet - does it work for somebody else?


Right-click on the image; select "Open Image in New Tab" (or New Window).

Edit the URL: Delete everything from "/image-size/" on (leaving only https://forums.ni.com/t5/image/serverpage/image-id/342889i1B7CE5371E58862D)

Now you can drag that image onto a block diagram.

0 Kudos
Message 9 of 10
(38 Views)

@code-lux  wrote:

I still think LabVIEW behaves not as expected, as I did not choose SizeToText but RingText.SizeToText - so the RingText is explicitly there at edit time!


Strictly speaking, LabVIEW could forbid configuring "RingText.SizeToText?" in write mode, or even hide that item from the properties submenu, but here are some insights on why (in my opinion) this is not the case:

 

1. Class "Text" is a generic class that represents a basic text component, either on the front panel or on the diagram.

 

2. Class "Enum" has properties such as "Label", "Caption", "UnitLabel", "RingText" which are all Text objects. These objects are sometimes called "nested objects", since their references are accessible through the properties of the owning object (Enum).

 

3. You can access the reference to these Text objects by selecting the Enum's properties: Label / Caption / UnitLabel / RingText > "Reference". Then you can use a second property node to access the Text properties. In this way, you are explicitly accessing the property of a nested object. This is sometimes called a "nested property".

 

4. To ease the access to nested properties, LabVIEW usually (not always) displays the properties of the nested objects in submenus, allowing to access them implicitly with a single property node. But still, this is equivalent to using 2 successive property nodes.

 

So the reasons to LabVIEW allowing to configure a nested property in write mode even if it can never be written at runtime could be:

 - Because the code that displays nested properties in the submenus is generic, it just displays the properties of the nested object's class. NI maybe don't want to complicate that code with exceptions for each possible owner class.

 - Even if writing this nested property was disallowed at edit-time, you could still try to write it explicitly with 2 successive property nodes. Here the compiler has no way to know whose the Text ref belongs to. Having the same behavior between the explicit and implicit access can be seen as a choice of consistency.

 

Regards,

Raphaël.

0 Kudos
Message 10 of 10
(9 Views)