Page 1 of 1
Yes/No Variable Type in PDM
Posted: Wed Dec 11, 2024 11:18 am
by charlesculp
I making some significant improvements to a PDM system. I know 10 years ago, using the variable type "Yes/No" was a mistake, because the different systems (Dispatch, PDM, Solidworks) used different values for what Yes/No means. One used 1,0, another -1,0, another "Yes" and "No".
In this new system, since 10 years has passed, I have wistfully assumed that they fixed it somehow. Why, I don't know. But now comes the real question, what do I put in this "Value" field?
Re: Yes/No Variable Type in PDM
Posted: Wed Dec 11, 2024 11:30 am
by charlesculp
Answering my own question. Checked one box and not the others on a test data card. Found it from the Preview tab showing the variables.
-1 is Yes, 0 is no.
- image.png (2.35 KiB) Viewed 356 times
Re: Yes/No Variable Type in PDM
Posted: Wed Dec 11, 2024 12:58 pm
by AlexB
It seems to stem from the inconsistencies within different programming languages themselves. Boolean (1 is true, 0 is false) vs. Variant_Bool (-1 is true, 0 is false) each seem to be used throughout the API and likely add-ins such as Dispatch or even PDM/Solidworks. I don't foresee this being something that gets fixed, rather a pain we have to work around.
Re: Yes/No Variable Type in PDM
Posted: Wed Dec 11, 2024 1:08 pm
by jcapriotti
@charlesculp The ghost of this issue has been around a long time. I only see a -1 value if using dispatch to set the variable. There is a hotfix I just noticed for this for 2023 sp5....and its labeled fixed in in 2024 sp1.
My Dispatch script that checks this value is written to check both:
Then I have cases where the variable type is Yes/No but I don't use a checkbox....I have a droplist with Yes/No and a blank line. In that case, I want to force the user to make a decision so it defaults to an empty value, then the transition checks to ensure there is a value. Can't really do that with a checkbox. However that complicates the DB by now have yes/no/blanks in the table.
Re: Yes/No Variable Type in PDM
Posted: Wed Dec 11, 2024 4:00 pm
by charlesculp
jcapriotti wrote: ↑Wed Dec 11, 2024 1:08 pm
@charlesculp The ghost of this issue has been around a long time. I only see a -1 value if using dispatch to set the variable. There is a hotfix I just noticed for this for 2023 sp5....and its labeled fixed in in 2024 sp1.
My Dispatch script that checks this value is written to check both:
image.png
Then I have cases where the variable type is Yes/No but I don't use a checkbox....I have a droplist with Yes/No and a blank line. In that case, I want to force the user to make a decision so it defaults to an empty value, then the transition checks to ensure there is a value. Can't really do that with a checkbox. However that complicates the DB by now have yes/no/blanks in the table.
Thanks Jason, great information.
Re: Yes/No Variable Type in PDM
Posted: Wed Dec 11, 2024 4:13 pm
by charlesculp
After testing this afternoon, checkboxes in a data card do not appear to be compatible with Yes/No variable type and a custom property set to Yes/No.
I feel like I was able to get this to work before, but maybe the data type for the variable was Text in PDM.
When I edit the data card in the File Explorer Extension, it works fine. When I use the PDM Add-in in Solidworks, it doesn't work! With variable type set to Text, or to Yes/No; same functionality. Wild, seems more like a bug. More research is needed, but I am using SW2022 SP5.
Re: Yes/No Variable Type in PDM
Posted: Wed Dec 11, 2024 5:13 pm
by jcapriotti
Definitely some inconsistency in how its handled.
Here's some values. Two different variables (256, 360), both are set to Yes/No data types. One uses a drop list with Yes/No, the other is a checkbox (0,1). Not sure how this affect PDM functionality. All variable values are stored several times depending on data type and the card control (checkbox, drop list, etc.). Seems every variable's value is stored as a text string in "Value Text" and "ValueCache". I guess this comes into play when searching depending on the search card control type.