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.