Jump to content

EvalStr in VW2022 returning different results


tbexon

Recommended Posts

Hello All

 

Some potential 2022 funkyness. I use the EvalStr function to get the localized string for "True" to then use this to compare to the results from Checkboxes using GetRField. (For more information on the method/reasoning see the below thread where @JBenghiatvery kindly showed me this method in the first place)  

 

Since migrating my plug ins to VW2022 I have noticed that EvalStr is now returning a boolean not a string, and thus causing all my comparisons to fail. 

localized_True_Bool = vs.EvalStr(vs.Handle(0), "1=1")  # Gets Localised True Bool
vs.AlrtDialog(str(type(localized_True_Bool)))

I have tried the above test script in both 2021 and 2022. in 2021 it returns the Expected results of the String "True", however in 2022 it returns a Boolean of True.

 

My questions are:

A) Can anyone else replicate this and get the same results?

B) Is this working as intended, or a bug?  I can't see anything on the Function Reference suggesting that this has been changed in 2022, however maybe @Vlado or @K.Lalkovskimight be able to shed some light?

 

Thanks in advance!

Link to comment
  • Vectorworks, Inc Employee
On 10/31/2021 at 10:35 AM, tbexon said:

 

 

On 10/31/2021 at 10:35 AM, tbexon said:

Hello All

 

Some potential 2022 funkyness. I use the EvalStr function to get the localized string for "True" to then use this to compare to the results from Checkboxes using GetRField. (For more information on the method/reasoning see the below thread where @JBenghiatvery kindly showed me this method in the first place)  

 

Since migrating my plug ins to VW2022 I have noticed that EvalStr is now returning a boolean not a string, and thus causing all my comparisons to fail. 

localized_True_Bool = vs.EvalStr(vs.Handle(0), "1=1")  # Gets Localised True Bool
vs.AlrtDialog(str(type(localized_True_Bool)))

I have tried the above test script in both 2021 and 2022. in 2021 it returns the Expected results of the String "True", however in 2022 it returns a Boolean of True.

 

My questions are:

A) Can anyone else replicate this and get the same results?

B) Is this working as intended, or a bug?  I can't see anything on the Function Reference suggesting that this has been changed in 2022, however maybe @Vlado or @K.Lalkovskimight be able to shed some light?

 

Thanks in advance!

 

Link to comment
  • Vectorworks, Inc Employee

Hi TBexon,
if you run this  on 2022 it is going to work(returns true):

localized_True_Bool = vs.EvalStr(vs.Handle(0), "1=1")  # Gets Localised True Bool
 vs.AlrtDialog(str(localized_True_Bool))/*I removed type() here*/

Regards,

Konstantin

 

Link to comment

Hi Konstantin

 

Sorry I should have Explained my issue a bit better, when I get a checkbox using the GetRField Command, I then have to compare it to the localized string for True. I do this using the below function:

 

def check_locallised_bool(objectHandle,objectName,Field):
    localized_True_Bool = vs.EvalStr(vs.Handle(0), "1=1")  # Gets Localised True Bool
    boolraw = vs.GetRField(objectHandle, objectName, Field)  # Gets the Raw Bool result
    if boolraw == localized_True_Bool:  # If raw string value is equal to localized version of True
        localbool = True
    else:  # If raw string value is NOT equal to localized version of True
        localbool = False
    return localbool

 

At the moment because in 2021, and according to the Developer page EvalStr returns a string so I am doing a string comparison, to compare the Result of the GetRField to the what I have established to being the String value for True in whatever Language the particular VW user is using. 

 

In 2022 EvalStr has started returning a Boolean rather than a string, meaning that a String comparison will always return False regardless. My question is whether this is an intended change or a bug? E.g Do I now need to change the logic to instead compare a Boolean result?

 

Cheers

Tom  

Link to comment
  • Vectorworks, Inc Employee

Hi @tbexon

 

Yes, unfortunately this is a regression that we need to investigate further.

 

For now, you can use the following code the check this:

str = vs.GetVWRString('Vectorworks/Strings/2103 *', '6') # The localized 'True' value
vs.AlrtDialog(str)

str = vs.GetVWRString('Vectorworks/Strings/2103 *', '7') # The localized 'False' value
vs.AlrtDialog(str)

 

This is the actual string returned by vs.GetRField, and it would be better to use anyway instead of the vs.EvalStr workaround.

 

Also, this is compatible with previous versions of Vectorworks.

 

Regards,

Vlado

Link to comment

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...