Hey,
I have tested these lines and I think it's a bug. It happens only when testing suppression state of a feature. Or Can anyone explain what is happening below:
'This is the correct behaviour
Debug.Print True = True
Debug.Print Not True = False
'This is wrong behaviour
Debug.Print swFeat.IsSuppressed = True
Debug.Print Not swFeat.IsSuppressed = True
'It makes this kind of use impossible because condition is always True
If Not swFeat.Issuppressed Then
'code here
End If
'Anyhow, this was the solution to the problem. I don't understand how this is different to code above.
If swFeat.IsSuppressed = False Then
'code here
End If
VBA True or Not False
VBA True or Not False
A lot of times, the NOT operator doesn't really do what I'm looking for. In those cases, I'll use the <> operator.
For example:
Go to full postFor example:
Code: Select all
If myFeature.IsSuppressed <> True Then
'Do something when suppression state is false
End If
Best Regards,
SolidKeke
SolidKeke
- AlexLachance
- Posts: 2244
- Joined: Thu Mar 11, 2021 8:14 am
- Location: Quebec
- x 2434
- x 2076
Re: VBA True or Not False
I think this might answer your question:
Sheet are named "Feuille#" by default on a French SolidWorks.
A sheet must be named "Feuille#" for it to be concidered a "black and white drawing"
If the sheet contains DXF in it's name, our print task will not print it. It will be later 'printed' by our task that creates our DXF.
If a sheet contains "COLOR" in it's name, our print task will know this sheet requires to be printed in color.
So any sheet used to generate a DXF will not create a PDF, any sheet that needs colors will have their sheet name accordingly.
By default every drawing prints in black and white because of the default name of the sheet. If they require colors, then the name of their sheet is adjusted accordingly. We also have a sort of macro that creates our drawing sheet for DXF purposes.
Here's an example we use in here.There are precedence rules that govern the order in which operations are performed, when an expression contains more than one operator. In the case of this expression …
False and not True or True
not has highest precedence, so its operation is performed first.
and is performed next.
or has the lowest precedence, so it is performed last.
Here, parentheses have been added to clarify the order of the operations:
(False and (not True)) or True
So, stepwise, the expression is evaluated like this:
1: (False and (False)) or True
2: (False) or True
3: True
Sheet are named "Feuille#" by default on a French SolidWorks.
A sheet must be named "Feuille#" for it to be concidered a "black and white drawing"
If the sheet contains DXF in it's name, our print task will not print it. It will be later 'printed' by our task that creates our DXF.
If a sheet contains "COLOR" in it's name, our print task will know this sheet requires to be printed in color.
So any sheet used to generate a DXF will not create a PDF, any sheet that needs colors will have their sheet name accordingly.
By default every drawing prints in black and white because of the default name of the sheet. If they require colors, then the name of their sheet is adjusted accordingly. We also have a sort of macro that creates our drawing sheet for DXF purposes.
Re: VBA True or Not False
A lot of times, the NOT operator doesn't really do what I'm looking for. In those cases, I'll use the <> operator.
For example:
For example:
Code: Select all
If myFeature.IsSuppressed <> True Then
'Do something when suppression state is false
End If
- Frederick_Law
- Posts: 1965
- Joined: Mon Mar 08, 2021 1:09 pm
- Location: Toronto
- x 1654
- x 1489
Re: VBA True or Not False
It always safer to compare two variable.
If the code can be optimize, the complier will do so.
I think the reason is object and method.
myFeature.IsSuppressed return a boolean, it itself is not a boolean.
So (Not myFeature.IsSuppressed) got ignored. It should throw an error.
If the code can be optimize, the complier will do so.
I think the reason is object and method.
myFeature.IsSuppressed return a boolean, it itself is not a boolean.
So (Not myFeature.IsSuppressed) got ignored. It should throw an error.
Re: VBA True or Not False
Please see this article in SW help. Short summary:
Do not use logical operators with returns of these functions. Always compare returned value to False.
https://help.solidworks.com/2019/englis ... _types.htm
Do not use logical operators with returns of these functions. Always compare returned value to False.
https://help.solidworks.com/2019/englis ... _types.htm