tbexon Posted January 29, 2021 Share Posted January 29, 2021 So I have an event enabled PIO with a couple of Boolean parameters. Up until now I've been using the below to get the parameter's current state by converting the string to bool, as GetRField returns strings, which I thought was fine. show_weight_bool = strtobool(vs.GetRField(objectHand, objectName, "Show Weight")) HOWEVER An unexpected bug has come up, from someone who tried this plug in on a non english version of Vectorworks (it was German in this particular instance). The error thrown from the strtobool function, was: ValueError: invalid truth value 'wahr' From what I can gather, the GetRField seems to be returning the localized value for the checkbox (in this instance 'wahr' which I'm given to understand from a quick google means True), rather than, as I was hoping just a pythonic True, but in string form. Firstly is this working as intended? I presume so as it would make sense that if you were extracting the string you would want said string to be in the localized language rather than always in english... SO does anyone have any clever ways around this? I've been hunting through the Function Reference but nothing obvious has jumped out at me, I was hoping it might be as simple as there was a vs.GetRBool or something similar that returns a BOOLEAN value, but so far I can't find it (I'm certainly not saying it's not there, just that I have not been able to locate it!) I'm hoping there's a super obvious answer that I'm just missing here! Quote Link to comment
JBenghiat Posted January 29, 2021 Share Posted January 29, 2021 This is expected. The stored string is localized. You need to localize True/False for criteria strings as well. I use this to retrieve the localized string: vs.EvalStr(vs.Handle(0), 1=1) I believe Concat(True) will also work. Quote Link to comment
tbexon Posted January 29, 2021 Author Share Posted January 29, 2021 Ok cool so i can use vs.EvalStr(vs.Handle(0), 1=1) to get the localized string for True and then just compare that to the results from the records? Quote Link to comment
JBenghiat Posted January 30, 2021 Share Posted January 30, 2021 Yes, should work. The sample file that came to mind was VS and not python, so double check the syntax, but that should work. Also 1==0 should give you false. (I can already see that it should be 1==1 above) 1 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.