01-15-2025 05:12 AM
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.
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?
01-15-2025 06:40 AM
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.
01-15-2025 06:59 AM
No it is adding to a newly created VI. The first Property Node is working as intended...
01-15-2025 08:04 AM
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.
01-15-2025 08:07 AM
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... :
Regards,
Raphaël.
01-15-2025 09:32 AM
@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... :
Regards,
Raphaël.
To make it more generic, I suggest this:
01-15-2025 11:16 AM
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...
01-15-2025 11:42 AM
unfortunately I´m not successful at importing Paul´s snippet - does it work for somebody else?
01-15-2025 11:49 AM
@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.
01-15-2025 04:06 PM
@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.